预算管理协议服务器

为YNAB(You Need A Budget)提供模型上下文协议(MCP)服务器,使AI助手能够读写用户的预算、交易、类别和收款人信息。

  • by jonathanspiva
  • Swift
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 jonathanspiva/swift-ynab-mcp

使用说明

YNAB MCP Server

A Model Context Protocol (MCP) server for YNAB (You Need A Budget).

Gives AI assistants like Claude read and write access to your YNAB budgets, transactions, categories, and payees.

Tools

Read Tools (11)

Tool Description
list_budgets List all budgets with names, IDs, and currency
list_accounts List accounts in a budget with balances
list_categories List category groups and categories with balances
get_budget_summary Budget overview with accounts and category groups
list_recent_transactions Recent transactions (filterable by account, date range, approval status)
get_month_summary Category breakdown for a specific month
get_transaction Full transaction details by ID
list_payees List all payees in a budget
get_transactions_by_payee Transaction history for a specific payee
get_transactions_by_category Transaction history for a specific category
list_scheduled_transactions List upcoming scheduled transactions

Write Tools (5)

Tool Description
create_transaction Create a new transaction (amount in dollars)
update_transaction Update an existing transaction (amount, payee, category, flag, approval)
bulk_update_transactions Update multiple transactions at once
rename_payee Rename a payee across all transactions
update_category_budget Set the budgeted amount for a category in a given month

Requirements

Build

swift build -c release

The binary will be at .build/release/ynab-mcp.

Configure

Add to your Claude Code MCP config (~/.claude.json or project .claude/settings.json):

{
  "mcpServers": {
    "ynab": {
      "command": "/path/to/ynab-mcp",
      "env": {
        "YNAB_TOKEN": "your-token-here"
      }
    }
  }
}

1Password integration

If you use 1Password, you can avoid storing the token in plaintext by using op run:

{
  "mcpServers": {
    "ynab": {
      "command": "op",
      "args": ["run", "--no-masking", "--", "/path/to/ynab-mcp"],
      "env": {
        "YNAB_TOKEN": "op://Your Vault/YNAB Token/credential"
      }
    }
  }
}

Limitation: op requires an active biometric session. Claude Code spawns MCP servers non-interactively, so op can't prompt for authentication. If your session has expired, the MCP server will silently fail to connect, and /mcp reconnect won't help either.

To fix this, run any op command in a terminal first to establish a session, then restart Claude Code:

op read "op://Your Vault/YNAB Token/credential" > /dev/null

This is a known limitation of how Claude Code launches subprocesses. Native op:// resolution in MCP config would eliminate this problem.

Rate Limiting

200 requests per hour (in-memory, resets on restart). This matches the YNAB API limit of 200 requests per hour per token.

Dependencies

Important: Back up your budget

This server includes write tools that modify your live YNAB data. Export your budget before using write tools for the first time. In the YNAB web app, click your budget name in the top-left corner and choose "Export Budget."

Notes

  • Only tested with Claude Code. It should work with any MCP client, but your mileage may vary.
  • Write tools modify your actual YNAB data. Use with care.
  • Transaction amounts are in dollars (e.g., 25.50), not YNAB's native milliunits.
  • Budget and category IDs can be discovered using the read tools (list_budgets, list_categories, etc.).

License

MIT