YNAB MCP Server
ynab-mcp-服务器
使用 mcp-framework 构建的模型上下文协议 (MCP) 服务器。此 MCP 提供与 YNAB 预算设置( https://ynab.com)交互的工具。
为了让 AI 与此工具交互,您需要从 YNAB 获取您的个人访问令牌: https://api.ynab.com/#personal-access-tokens 。将此 MCP 服务器添加到任何客户端时,您需要以 YNAB_API_TOKEN 的形式提供您的个人访问令牌。此令牌绝不会直接发送给 LLM。它被私密地存储在环境变量中,以便与 YNAB API 一起使用。
设置
指定环境变量:
YNAB_API_TOKEN(必需)
YNAB_BUDGET_ID(可选)
Related MCP server: MCP YNAB Server
目标
该项目的目标是能够通过 AI 对话与我的 YNAB 预算进行交互。我希望启用以下几个主要工作流程:
工作流程:
首次设置
系统会提示您从可用预算中选择预算。如果您先尝试使用其他工具,则会出现此提示,要求您设置默认预算。
所需工具:ListBudgets
管理超支类别
添加新交易
批准交易
检查每月总支出与总收入
根据类别目标自动分配资金
当前状态
可用工具:
ListBudgets - 列出您帐户中的可用预算
预算摘要 - 提供资金不足的类别和低资金账户的摘要
GetUnapprovedTransactions - 检索所有未批准的交易
CreateTransaction - 为指定的预算和账户创建交易。
示例提示:
Add a transaction to my Ally account for $3.98 I spent at REI today需要先调用 GetBudget 才能知道账户 ID
ApproveTransaction - 批准 YNAB 预算中的现有交易
需要交易 ID 才能批准
可以与 GetUnapprovedTransactions 结合使用来批准待处理的交易
拨打获取未批准交易后,提示:
approve the transaction for $6.95 on the Apple Card
下一个:
一次通话即可批准多笔交易
updateCategory 工具 - 或者 updateTransaction 更通用的工具,如果我可以获得可选参数以便与 zod 和 mcp 框架正确配合使用
脱离 mcp 框架直接使用模型上下文协议 sdk?
快速入门
# Install dependencies
npm install
# Build the project
npm run build
项目结构
ynab-mcp-server/
├── src/
│ ├── tools/ # MCP Tools
│ └── index.ts # Server entry point
├── .cursor/
│ └── rules/ # Cursor AI rules for code generation
├── package.json
└── tsconfig.json添加组件
YNAB sdk 描述了可用的 api 端点: https://github.com/ynab/ynab-sdk-js 。
YNAB 开放 API 规范位于: https://api.ynab.com/papi/open\ _api\_spec.yaml 。这可用于提示 AI 生成新工具。光标代理的示例提示:
create a new tool based on the readme and this openapi doc: https://api.ynab.com/papi/open_api_spec.yaml
The new tool should get the details for a single budget您可以使用 CLI 添加更多工具:
# Add a new tool
mcp add tool my-tool
# Example tools you might create:
mcp add tool data-processor
mcp add tool api-client
mcp add tool file-handler工具开发
示例工具结构:
import { MCPTool } from "mcp-framework";
import { z } from "zod";
interface MyToolInput {
message: string;
}
class MyTool extends MCPTool<MyToolInput> {
name = "my_tool";
description = "Describes what your tool does";
schema = {
message: {
type: z.string(),
description: "Description of this input parameter",
},
};
async execute(input: MyToolInput) {
// Your tool logic here
return `Processed: ${input.message}`;
}
}
export default MyTool;发布到 npm
更新你的 package.json:
确保
name唯一并遵循 npm 命名约定设置适当的
version添加
description、author、license等。检查
bin指向正确的入口文件
本地构建和测试:
npm run build npm link ynab-mcp-server # Test your CLI locally登录 npm(如有必要,请创建帐户):
npm login发布你的包:
npm publish
发布后,用户可以将其添加到他们的 claude 桌面客户端(见下文)或使用 npx 运行它
与 Claude Desktop 一起使用
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 YNAB 预算助手:
npx -y @smithery/cli install @calebl/ynab-mcp-server --client claude本地开发
将此配置添加到您的 Claude Desktop 配置文件:
MacOS : ~/Library/Application Support/Claude/claude_desktop_config.json Windows : %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"ynab-mcp-server": {
"command": "node",
"args":["/absolute/path/to/ynab-mcp-server/dist/index.js"]
}
}
}发布后
将此配置添加到您的 Claude Desktop 配置文件:
MacOS : ~/Library/Application Support/Claude/claude_desktop_config.json Windows : %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"ynab-mcp-server": {
"command": "npx",
"args": ["ynab-mcp-server"]
}
}
}其他 MCP 客户端
检查https://modelcontextprotocol.io/clients以了解其他可用的客户端。
构建和测试
更改您的工具
运行
npm run build进行编译服务器将在启动时自动加载您的工具
了解更多
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/calebl/ynab-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server