mcp-ynab
A. 模型上下文协议 服务器
你需要一个预算 (您需要预算)API。允许MCP客户端(Claude
桌面、Claude Code、定制代理)读取您的预算、账户和
交易,并通过结构化工具创建或重新分类交易。
安装
该项目由以下人员管理 紫外线 和
任务。此仓库中的所有Python命令都经过
uv run.```bash
uv sync # install dependencies
task install # install the mcp-ynab CLI into the venv
## 配置
在环境中(或在 `.env` 文件在
回购根):```bash
export YNAB_API_KEY=your-personal-access-token
获取令牌 .
运行服务器```bash
mcp-ynab # production
task dev # dev mode + MCP Inspector in the browser
## 工具与资源
服务器通过MCP公开以下内容:
**只读工具**
|工具|目的|
| ---- | ------- |
| `get_budgets` |以低价列出所有预算|
| `get_accounts` |列出预算中的科目,按类型分组并汇总|
| `get_account_balance` |返回单个账户的当前美元余额|
| `get_transactions` |账户最近的交易;可选的 `since_date` |
| `get_transactions_needing_attention` |未分类/未批准交易的筛选器|
| `get_categories` |按类别组分组的预算中的所有类别|
**突变工具**
|工具|目的|
| ---- | ------- |
| `create_transaction` |在YNAB中创建新交易|
| `categorize_transaction` |为现有交易分配类别|
| `set_preferred_budget_id` |缓存默认目标工具的首选预算ID|
| `cache_categories` |在本地缓存预算的类别列表|
**资源**
- `ynab://preferences/budget_id` --当前首选预算ID
- `ynab://categories/{budget_id}` --预算的缓存类别
## 发展```bash
task fmt # ruff format + check --fix
task lint # ruff check + format --check (no auto-fix)
task typecheck # mypy
task docstrings # interrogate (fails under 80%)
task test # unit tests only (default; integration excluded)
task coverage # unit tests with coverage report
集成测试
集成测试在后面进行 pytest.mark.integration 并被排除在外
默认值 task test 跑。他们会给你的YNAB账户打电话,所以他们
需要 YNAB_API_KEY.```bash
YNAB_API_KEY=your-token task test:integration
默认集成套件为 **只读**.变异数据的测试
(create_transaction,categorye_transaction)需要额外的选择加入:```bash
YNAB_API_KEY=your-token YNAB_INTEGRATION_ALLOW_WRITES=1 \
task test:integration
许可证
麻省理工学院
