YNAB MCP Server

by calebl
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports publishing the MCP server as an npm package for easier distribution and installation

  • Used for building tools that interact with YNAB's API through typed interfaces

  • Utilized for schema validation of tool inputs when interacting with YNAB data

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(可选)

目标

该项目的目标是能够通过 AI 对话与我的 YNAB 预算进行交互。我希望启用以下几个主要工作流程:

工作流程:

首次设置

  • 系统会提示您从可用预算中选择预算。如果您先尝试使用其他工具,则会出现此提示,要求您设置默认预算。
    • 所需工具:ListBudgets

管理超支类别

添加新交易

批准交易

检查每月总支出与总收入

根据类别目标自动分配资金

当前状态

可用工具:

  • ListBudgets - 列出您帐户中的可用预算
  • 预算摘要 - 提供资金不足的类别和低资金账户的摘要
  • GetUnapprovedTransactions - 检索所有未批准的交易
  • CreateTransaction - 为指定的预算和账户创建交易。
    • 示例提示: Add a transaction to my Ally account for $3.98 I spent at REI today
    • 需要先调用 GetBudget 才能知道账户 ID

下一个:

快速入门

# Install dependencies npm install # Build the project npm run build

项目结构

ynab-mcp-server/ ├── src/ │ ├── tools/ # MCP Tools │ └── index.ts # Server entry point ├── 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

  1. 更新你的 package.json:
    • 确保name唯一并遵循 npm 命名约定
    • 设置适当的version
    • 添加descriptionauthorlicense等。
    • 检查bin指向正确的入口文件
  2. 本地构建和测试:
    npm run build npm link ynab-mcp-server # Test your CLI locally
  3. 登录 npm(如有必要,请创建帐户):
    npm login
  4. 发布你的包:
    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以了解其他可用的客户端。

构建和测试

  1. 更改你的工具
  2. 运行npm run build进行编译
  3. 服务器将在启动时自动加载您的工具

了解更多

ID: k7h1fcvgs1