预算管理扩展

一个与You Need A Budget无缝集成的Claude桌面扩展,支持通过YNAB API直接在对话中管理预算、账户、类别和交易。

  • by mbmccormick
  • JavaScript
  • 本地部署
  • 10 星标
  • 更新于
在 GitHub 查看 mbmccormick/ynab-mcpb

使用说明

你需要一个预算(非官方)-Claude桌面扩展

一个全面的Claude桌面扩展,提供与You Need A Budget的无缝集成,使您能够使用YNAB API直接从Claude对话中管理完整的预算工作流程。

备注:这是一个非官方的扩展,与您需要预算无关或不受其支持。

快速开始

安装

  1. 获取YNAB API代币 从 YNAB开发人员设置

    • 点击“新建令牌”
    • 给它起个名字(例如,“克劳德桌面”)
    • 复制生成的令牌
  2. 下载 这 ynab-mcpb.mcpb 文件来自 最新版本

  3. 安装 在克劳德桌面(设置→ 扩展→ 安装扩展)

    • 选择已下载的 .mcpb 文件
    • 提示时,粘贴您的YNAB API令牌
  4. 开始使用 YNAB工具在您的对话中!

💡 专业建议:使用 'last-used' 作为budget_id访问您最近使用的预算。

特征

🎯 核心功能

  • 全面预算管理:查看和管理您的所有预算
  • 账户操作:访问所有帐户、创建新帐户和查看余额
  • 品类管理:查看类别、设置预算金额和跟踪支出
  • 事务管理:创建、读取、更新和删除事务
  • 高级筛选:按账户、类别、收款人或日期范围筛选交易

🔍 发现与导航

  • 收款人管理:查看所有收款人及其交易历史记录
  • 定期交易:访问和审查经常性交易
  • 月度预算:查看任何月份的预算快照
  • 多预算支持:无缝处理多个预算

🛠️ 高级功能

  • 灵活的更新:通过完全参数控制修改交易和类别预算
  • 数据完整性:全面的输入验证和错误处理
  • 安全:安全的API令牌身份验证
  • 交叉平台的:适用于macOS、Linux和Windows

API 参考

📊 预算

get_budgets -获取所有预算

参数:无

get_budget -获取预算详细信息

必需的: budget_id (使用 'last-used' 最近)

get_budget_settings -获取预算设置

必需的: budget_id

💰 账户

get_accounts -获取所有帐户

必需的: budget_id

get_account -获取特定帐户

必需的: budget_id, account_id

create_account -创建新帐户

必需的: budget_id, name, type, balance 类型: checking, savings, creditCard, cash, lineOfCredit, otherAsset, otherLiability, mortgage, autoLoan, studentLoan, personalLoan, medicalDebt, otherDebt

📁 分类

get_categories -获取所有类别

必需的: budget_id

get_category -获取特定类别

必需的: budget_id, category_id

get_category_for_month -获取特定月份的类别

必需的: budget_id, month (YYYY-MM-DD), category_id

update_category_for_month -更新类别预算

必需的: budget_id, month (YYYY-MM-DD), category_id, budgeted (单位:毫单位)

💳 交易

备注:对于下面的交易列表工具,如果 since_date 省略了YNAB API仅返回最后一年的交易。提供明确的 since_date 以检索较旧的交易历史记录。

get_transactions -获取预算的交易记录

必需的: budget_id 可选的: since_date (YYYY-MM-DD), type (未分类、未批准)

get_transaction -获取特定交易

必需的: budget_id, transaction_id

get_transactions_by_account -获取账户交易记录

必需的: budget_id, account_id 可选的: since_date

get_transactions_by_category -获取类别的交易记录

必需的: budget_id, category_id 可选的: since_date

get_transactions_by_payee -为收款人获取交易记录

必需的: budget_id, payee_id 可选的: since_date

create_transaction -创建新交易

必需的: budget_id, account_id, date (YYYY-MM-DD), amount (单位:毫单位) 可选的: payee_id, payee_name, category_id, memo, cleared, approved, flag_color

update_transaction -更新交易记录

必需的: budget_id, transaction_id 可选的: account_id, date, amount, payee_id, category_id, memo, cleared, approved, flag_color

delete_transaction -删除交易记录

必需的: budget_id, transaction_id

🔄 定期交易

get_scheduled_transactions -获取所有计划交易

必需的: budget_id

get_scheduled_transaction -获取特定的计划交易

必需的: budget_id, scheduled_transaction_id

👥 收款人

get_payees -获取所有收款人

必需的: budget_id

get_payee -获取具体收款人

必需的: budget_id, payee_id

📅 月份

get_months -获取所有月份

必需的: budget_id

get_month -获取具体月份

必需的: budget_id, month (YYYY-MM-DD或 'current')

使用示例

预算概览

Show me an overview of my current budget, including all categories and how much I've budgeted vs. spent

事务管理

Create a transaction for $45.32 at Whole Foods in my checking account, categorized as Groceries, dated today

支出分析

Show me all my dining out transactions from the past 30 days and calculate how much I've spent

品类管理

Set my Groceries category budget to $500 for this month

账户余额

What are the balances of all my accounts?

每月评论

Show me my budget for this month and highlight any categories where I'm overspending

重要概念

百万单位

YNAB API对所有货币金额使用“毫单位”:

  • 1000百万单位 = $1.00
  • 示例:45.32美元=45.32亿单位
  • 流入(收入)=正值
  • 流出(费用)=负值

预算编号

  • 使用 'last-used' 自动使用您最近访问的预算
  • 或者从以下位置提供具体的预算ID get_budgets

日期格式

  • 所有日期均采用ISO格式: YYYY-MM-DD
  • 例子: '2025-01-15' 2025年1月15日
  • 对于月份:使用月份的第一天(例如。, '2025-01-01' 2025年1月)

交易状态

  • 清除: cleared, uncleared, reconciled
  • 批准: true 或 false (默认值: false 新交易)
  • 旗杆_颜色: red, orange, yellow, green, blue, purple,或 null

需求

  • Node.js:18.0.0或更高版本
  • YNAB账户:活跃的YNAB订阅
  • YNA API令牌:来自的个人访问令牌 YNAB开发人员设置
  • 克劳德桌面版:与MCPB规范兼容
  • Internet连接:API访问必需

发展

从源头构建

# Clone the repository
git clone https://github.com/mbmccormick/ynab-mcpb.git
cd ynab-mcpb

# Install dependencies
npm install

# Validate the code
npm run validate

# Package the extension
npm run package

这将创建 ynab-mcpb.mcpb 您可以在Claude Desktop中安装。

运行测试

# Set your API token for testing
export YNAB_API_TOKEN="your-personal-access-token"

# Run validation tests
node test/test-validation.js

# Run error handling tests
node test/test-error-handling.js

获取您的API代币

  1. 访问 YNAB开发人员设置
  2. 点击“新建令牌”
  3. 给它起个名字(例如,“克劳德桌面”)
  4. 复制生成的令牌
  5. 在安装或测试过程中使用它

建筑

项目结构

ynab-mcpb/
├── manifest.json              # MCPB extension manifest
├── package.json               # Dependencies and scripts
├── README.md                  # Documentation
├── .mcp.json                  # MCP configuration
├── .gitignore                # Git ignore rules
└── server/
    ├── index.js               # Main MCP server
    ├── tool-definitions.js    # MCP tool schemas
    ├── ynab-client.js         # YNAB API client
    ├── server-config.js       # Configuration constants
    └── utils.js               # Utilities and helpers

关键设计原则

  • 关注点分离:模块化架构,责任明确
  • 安全第一:安全的API令牌处理和HTTPS通信
  • 友善:直观的参数名称和有用的错误消息
  • 稳健的错误处理:全面的错误捕获和报告
  • 交叉平台的:适用于所有主要操作系统
  • 可扩展:易于添加新工具和功能
  • 现代JavaScript:带有async/await的ES6模块

安全功能

  • API代币安全:令牌存储在环境变量中,从不存储在代码中
  • HTTPS通信:所有API请求都使用安全HTTPS
  • 输入验证:所有参数的类型和格式都经过验证
  • 错误处理:具有详细日志记录的结构化错误响应
  • 超时管理:防止挂起API请求(默认为30秒)
  • 速率限制:遵守YNAB API速率限制(200次请求/小时)

发展

以开发模式运行

# Enable debug logging
DEBUG=true npm start

# Or use the dev script
npm run dev

验证代码

npm run validate

测试扩展

# Start the server
npm start

# The server will listen on stdio for MCP requests

故障排除

常见问题

未设置API令牌

Error: YNAB_API_TOKEN environment variable is required
Solution: Set the YNAB_API_TOKEN environment variable or add it to .mcp.json

API令牌无效

Error: YNAB API error (401): Unauthorized
Solution: Verify your API token is correct at https://app.ynab.com/settings/developer

速率限制已超出

Error: YNAB API error (429): Too Many Requests
Solution: Wait a few minutes. YNAB allows 200 requests per hour per token.

网络错误

Error: YNAB API request failed
Solution: Check your internet connection and verify YNAB service status

调试信息

# Enable detailed logging
DEBUG=true npm start

获取帮助

  • YNAB API问题:检查 YNAB API文件
  • 克劳德桌面版:遵循Claude Desktop文档
  • 扩展问题:在项目存储库中创建问题

API费率限制

  • 限制:每个访问令牌每小时200个请求
  • 推荐:尽可能使用增量请求以减少API调用
  • 最佳实践:缓存频繁访问的数据

许可证

MIT许可证-详见package.json

致谢

  • 你需要一个预算 他们卓越的API和预算平台
  • 人类 用于模型上下文协议(MCP)SDK
  • 社区 获取反馈和贡献

内置于❤️ 克劳德桌面生态系统