Skip to main content
Glama
lukew0824

plaid-mcp

by lukew0824

plaid-mcp

一个自托管的 MCP 服务器,让 Claude 能够通过 Plaid 查询您的银行账户、余额和交易。

工具

工具

描述

accounts

所有关联的银行账户

balances

当前/可用余额及信用额度

transactions

指定日期范围内的完整交易记录

total_spending

按类别细分的总支出

transactions_by_category

按 Plaid PFC 类别筛选交易

merchants

指定日期范围内的所有商户,按总支出排序

transactions_by_merchant

按商户名称筛选交易

工作原理

  • OAuth 2.1 + PKCE,使用 Google 作为身份提供商

  • 电子邮件白名单作为安全边界

  • Claude.ai 获取一个 30 天的承载令牌(bearer token);您的 Plaid 访问令牌永远不会离开您的服务器

  • Caddy 部署在 FastAPI 前端,在 443 端口终止 TLS,使用自动配置的 Let's Encrypt 证书,并反向代理到 localhost:8080

要求

  • 一台具有公网 IP 的 Linux 服务器(本指南使用 AWS EC2 t3.micro)

  • 指向该服务器的域名(本指南使用免费的 DuckDNS 子域名)

  • 一个拥有生产环境访问权限的 Plaid 开发者账户

  • 一个用于 OAuth 客户端的 Google Cloud 账户

设置

1. Plaid

  1. 在 dashboard.plaid.com 创建一个 Plaid 账户

  2. 在仪表板中申请 Production access(Plaid 将审核您的申请——这可能需要几天时间)

  3. 审核通过后,从 Team Settings → Keys 保存您的 client_id 和 Production 密钥

2. Google OAuth

  1. console.cloud.google.com → 创建一个项目

  2. APIs & Services → OAuth consent screen → 设置一个“外部”应用,将您自己添加为测试用户

  3. APIs & Services → Credentials → Create credentials → OAuth client ID

  4. 应用类型:Web application

  5. Authorized redirect URIs:https://yourdomain.com/auth/google/callback (使用下文第 4 步中的真实域名)

  6. 保存 Client ID 和 Client secret

3. 服务器

本指南假设使用 AWS EC2:

  1. 启动一个 t3.micro Ubuntu 24.04 实例

  2. 安全组:入站 TCP 22(来自您 IP 的 SSH)、80、443

  3. 分配一个弹性 IP 并将其关联到该实例

  4. SSH 登录:ssh -i your-key.pem ubuntu@<elastic-ip>

4. 域名

使用 DuckDNS 的免费选项:

  1. 使用 Google/GitHub/Reddit 登录

  2. 预留一个子域名(例如 plaid-yourname)

  3. 将 IP 设置为您的弹性 IP

  4. 您的域名现在是 plaid-yourname.duckdns.org

回到第 2.5 步,将重定向 URI 设置为 https://plaid-yourname.duckdns.org/auth/google/callback。

5. 安装

在服务器上:

git clone https://github.com/lukew0824/plaid-mcp.git
cd plaid-mcp
cp .env.example .env
nano .env   # fill in everything
./install.sh

该脚本:

  • 安装 Python、Caddy 和依赖项

  • 设置 systemd 服务 (plaid-mcp)

  • 将 Caddy 配置为反向代理,并通过 Let's Encrypt 实现自动 HTTPS

6. 在 Claude.ai 中连接

  1. Claude.ai → Settings → Connectors → Add custom connector

  2. URL:https://yourdomain.com/mcp

  3. 点击 Connect

  4. 使用与 ALLOWED_EMAIL 匹配的 Google 账户登录

  5. 仅首次使用:会出现一个 Plaid Link 弹出窗口 — 连接您的银行

  6. 完成。尝试:“我上个月在餐饮上花了多少钱?”

配置

.env 中的值:

键

描述

PLAID_ENV

production

PLAID_CLIENT_ID

来自 Plaid 仪表板

PLAID_PRODUCTION_SECRET

来自 Plaid 仪表板

GOOGLE_CLIENT_ID

来自 Google Cloud Console

GOOGLE_CLIENT_SECRET

来自 Google Cloud Console

ALLOWED_EMAIL

允许进行身份验证的唯一 Google 邮箱

BASE_URL

此服务器的公共 HTTPS URL(末尾不带斜杠)

DATABASE_URL

sqlite:///./plaid_mcp.db(默认值适用于自托管)

许可证

MIT

Related MCP Connectors