Skip to main content
Glama
monzo-mcp

monzo-mcp

monzo-mcp

CI License: GPL v3 Python 3.13+ Glama MCP Server

用于 Monzo 银行 API 的 MCP 服务器。通过 Claude Code 或任何 MCP 客户端,以只读方式访问账户、余额、储蓄罐、交易和消费分析。

与其他使用原始 bearer 令牌(6 小时即过期)的 Monzo MCP 实现不同,此服务器处理完整的 OAuth 并自动刷新令牌。

功能

  • 7 个只读工具 - 无写入操作,无资金移动

  • 带自动刷新的 OAuth - 令牌自动刷新,无需手动重新生成

  • 本地交易缓存 - SQLite 数据库可保留 Monzo 90 天 SCA 窗口之外的数据

  • 按需自动同步 - 读取缓存的工具会在缓存当天未同步时自动执行增量同步,因此你很少需要手动调用 monzo_sync

  • 消费分析 - 类别细分、主要商家、逐月对比

  • 交易搜索 - 按商家、收款人(交易对手)、描述或备注搜索缓存历史

  • 收款人详情 - 银行转账(快速支付、P2P、Bacs)会缓存收款人姓名、分类代码和账号

Related MCP server: monzo-mcp

工具

工具

描述

数据来源

monzo_list_accounts

列出账户及类型和 ID

实时 API

monzo_get_balance

当前余额和今日支出

实时 API

monzo_list_pots

储蓄罐及余额

实时 API

monzo_sync

将交易同步到本地缓存

实时 API -> SQLite

monzo_list_transactions

列出/筛选缓存交易

本地缓存(过期时自动同步)

monzo_search_transactions

按商家/收款人/描述/备注搜索

本地缓存(过期时自动同步)

monzo_spending

带类别细分的消费分析

本地缓存(过期时自动同步)

前提条件

安装

git clone https://github.com/partymola/monzo-mcp.git
cd monzo-mcp
uv venv --python 3.13 .venv
uv pip install -e .

此包不在 PyPI 上——该名称属于一个无关项目。改为发布容器镜像;请参阅 Docker。

设置

1. 注册 Monzo OAuth 客户端

前往 developers.monzo.com 创建 OAuth 客户端:

  • 将重定向 URL 设置为 http://localhost:6600/callback

  • 记下你的 Client ID 和 Client Secret

2. 认证

monzo-mcp auth

这将打开浏览器进行 Monzo OAuth。授权后,请在 Monzo 应用中于 5 分钟内批准登录,以获得完整的交易历史访问权限(Monzo 的 SCA 窗口)。

3. 注册到 Claude Code

claude mcp add -s user monzo -- /path/to/monzo-mcp/.venv/bin/monzo-mcp

在 Windows 上,控制台脚本位于 .venv\Scripts\monzo-mcp.exe。

4. 首次同步

在 Claude Code 中运行 monzo_sync 以填充本地交易缓存。请在认证后立即执行此操作,以利用 SCA 窗口(最多 11 个月的历史)。

Docker

镜像发布到 ghcr.io/partymola/monzo-mcp。标签带有 v 前缀(:vX.Y.Z),:latest 跟随最新版本。

容器需要挂载卷。 凭据和交易缓存位于 /data 下;若未挂载任何内容,容器仍会启动,但每个工具都会报告未配置,且你授权的任何内容都会在容器被替换时丢失。

首先按照设置步骤 1 中所述注册 OAuth 客户端——auth 会提示输入 Client ID 和 secret,之后无法再提供。重定向 URL 为 http://localhost:6600/callback,与源码安装相同。

认证一次,写入命名卷。运行前请决定是否要使用绑定挂载——之后切换意味着需要重新授权:

docker volume create monzo-mcp-data
docker run --rm -it \
  -v monzo-mcp-data:/data \
  -p 127.0.0.1:6600:6600 \
  ghcr.io/partymola/monzo-mcp:latest auth

发布端口仅在此步骤需要,以便 OAuth 重定向能到达容器。将其绑定到 127.0.0.1 可使回调监听器不暴露在你的网络上。不会打开浏览器——容器没有浏览器——因此请复制其打印的 URL。然后在 Monzo 应用中于 5 分钟内批准登录(请参阅 Monzo SCA 窗口)。

然后注册服务器,复用同一卷:

claude mcp add -s user monzo -- \
  docker run --rm -i -v monzo-mcp-data:/data ghcr.io/partymola/monzo-mcp:latest

-i 是必需的——服务器通过 stdin 和 stdout 使用 JSON-RPC 通信。

立即同步。 11 个月的回填窗口会在你在 Monzo 应用中批准后 5 分钟关闭(请参阅 Monzo SCA 窗口),且此路径比源码安装更长——因此请在服务器注册后立即调用 monzo_sync。错过则只会静默获得 90 天数据,且无任何错误。

若要将文件放在可读取的位置,请使用绑定挂载而非命名卷。容器以 root 身份运行,且凭据仅限所有者写入,因此若不使用 --user,文件最终会归 root 所有:

mkdir -p ~/monzo-mcp-data/config
docker run --rm -it \
  -v ~/monzo-mcp-data:/data \
  --user $(id -u):$(id -g) \
  -p 127.0.0.1:6600:6600 \
  ghcr.io/partymola/monzo-mcp:latest auth

将相同的 -v 和 --user 传递给服务器命令。请先创建目录——对命名卷使用 --user 会失败,因为卷会从镜像初始化并归 root 所有。

CLI

monzo-mcp              Start the MCP server (stdio transport)
monzo-mcp auth         Interactive OAuth setup (opens the browser)
monzo-mcp --version    Print the installed package version

配置

所有配置均通过环境变量进行(可选):

变量

默认值

描述

MONZO_MCP_CONFIG_DIR

<package>/config/

OAuth 凭据和令牌的目录

MONZO_MCP_DB_PATH

<package>/monzo.db

SQLite 交易缓存的路径

MONZO_MCP_CALLBACK_HOST

localhost

auth 回调服务器绑定的接口。重定向 URI 不受影响

容器镜像将前两个设置为 /data 下的路径,因为包相对默认值会解析到解释器的 lib 目录中,而该目录无法挂载。第三个设置为 0.0.0.0,因为发布端口到达容器的桥接接口,而 localhost 绑定会拒绝它。

凭据文件(由 monzo-mcp auth 创建):

  • config/monzo_client.json - OAuth 客户端 ID 和 secret

  • config/monzo_tokens.json - 访问和刷新令牌(自动刷新)

Monzo SCA 窗口

Monzo 的强客户认证(SCA)限制交易历史访问:

  • 应用批准后 5 分钟内:最多约 11 个月的历史

  • 窗口过期后:仅最近 90 天

本地 SQLite 缓存会永久保留所有已同步的交易,因此请在 monzo-mcp auth 后立即运行 monzo_sync。

要回填特定范围,请向 monzo_sync 传递 since——ISO 日期(2026-01-01)或日期时间(2026-01-01T14:30:00Z)。回溯超过约 90 天仅在 SCA 窗口内有效;窗口外仅返回最近 90 天。

较旧的缓存交易仅在重新获取时才会获得新版本中添加的字段(例如银行转账的收款人/支付对象详情),认证后的完整同步会为重新拉取的历史数据执行此操作。

安全性

  • 零写入工具 - 无法发送资金、在储蓄罐之间移动资金或修改交易

  • Monzo API 本身无法向外部账户发送资金

  • 令牌以 JSON 文件形式存储在 config/ 目录中(已加入 gitignore)

  • 所有 API 调用均为带 Bearer 令牌认证的 GET 请求

故障排除

  • "SCA required" 或仅 90 天历史 - 重新运行 monzo-mcp auth 并在 Monzo 应用中于 5 分钟内批准登录,然后立即同步(请参阅上面的 SCA 窗口)。

  • 令牌过期 / 无刷新 - 重新运行 monzo-mcp auth 以重新授权。

  • "No transaction data available" - 缓存为空;认证后调用一次 monzo_sync(或任何读取缓存的工具,它们会自动同步)。

  • 在 Docker 下每个工具都报告 "not configured",或认证在重启后不保留 - /data 下未挂载任何内容。请参阅 Docker;必须将相同的卷传递给 auth 运行和服务器。

  • 批准后 auth 停留在 "Waiting for callback..." - 回调未送达。按 Ctrl-C 并重新运行。在 Docker 下,检查端口是否已发布(-p 127.0.0.1:6600:6600)。

贡献

请参阅 CONTRIBUTING.md 了解开发设置、测试工作流和 pre-commit 钩子。变更记录在 CHANGELOG.md 中。

许可证

GPL-3.0-or-later。请参阅 LICENSE。

Available Tools

7 tools
monzo_get_balanceA

Get current balance for a Monzo account.

Args: account_type: "personal" or "joint" (default: "personal")

Returns balance, spend today, and currency. Also records a balance snapshot.

Inputs: account_type.

monzo_list_accountsA

List all Monzo accounts with their types and IDs.

Returns account details including whether each is personal or joint, and whether it is open or closed. Any other kind of account keeps Monzo's own type name (e.g. "uk_rewards") and is not synced.

Inputs: no named parameters.

monzo_list_potsA

List all pots (savings buckets) for a Monzo account.

Args: account_type: "personal" or "joint" (default: "personal")

Returns the account the pots belong to, plus pot names and balances. Also records balance snapshots.

Inputs: account_type.

monzo_list_transactionsA

List transactions from the local cache.

Auto-syncs if the cache is stale (last sync before today).

Queries the synced transaction database, not the live API. Bank transfers (faster payments, p2p, bacs) include a counterparty object with the payee name and, where the scheme provides them, sort code and account number.

Returns {"account_type": ..., "transactions": [...]}, where account_type echoes the filter applied and is null when unfiltered.

Args: account_type: "personal" or "joint" (default: all) since: Start date, e.g. "2026-01-01" (inclusive) before: End date, e.g. "2026-02-01" (exclusive) category: Exact category match, e.g. "groceries", "eating_out", "transport" merchant: Merchant name search (case-insensitive, partial match) limit: Max results (default 50)

Inputs: limit, since, before, category, +2 more.

monzo_search_transactionsA

Search cached transactions by merchant, counterparty (payee), description, or notes.

Auto-syncs if the cache is stale (last sync before today).

Case-insensitive partial match across merchant_name, counterparty_name, description, and notes fields. Counterparty matching finds bank transfers (faster payments, p2p, bacs) by payee name.

Returns {"account_type": ..., "transactions": [...]}, where account_type echoes the filter applied and is null when unfiltered.

Args: query: Search term account_type: "personal" or "joint" (default: all) since: Start date, e.g. "2026-01-01" (inclusive) before: End date, e.g. "2026-02-01" (exclusive) limit: Max results (default 30)

Inputs: query (required), limit, since, before, +1 more.

monzo_spendingA

Analyse spending from cached Monzo transactions.

Auto-syncs if the cache is stale (last sync before today).

Every result carries account_type, echoing the filter applied and null when unfiltered, so a zero total says which account it measured.

Args: month: Month in YYYY-MM format (default: current month) category: Filter by category, e.g. "groceries", "eating_out", "transport" account_type: "personal" or "joint" (default: all) detail: If true, return individual transactions instead of category summary

Inputs: month, detail, category, account_type.

monzo_syncA

Sync transactions, balances, and pots from the Monzo API into the local cache.

Fetches up to 11 months of history (within SCA window) or falls back to the last-synced timestamp / 90 days. Handles pagination and auth-hold deduplication automatically. Declined card attempts are not stored. Only current and joint accounts are synced; any other is listed as skipped.

Args: account_type: "personal", "joint", or None to sync both since: Optional ISO date ("2026-01-01") or datetime ("2026-01-01T14:30:00Z") to start the backfill from, overriding last-sync resumption. Reaching beyond ~90 days only works inside the post-auth SCA window.

Inputs: since, account_type.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools target clearly distinct resources/actions (accounts, balance, pots, sync, spending analysis). The main overlap is between monzo_list_transactions and monzo_search_transactions, since list_transactions also accepts a merchant filter, but the search tool's broader field coverage (counterparty, description, notes) and different default limit provide some separation.

    Naming Consistency4/5

    All names use a consistent monzo_ prefix and snake_case. Most follow verb_noun (list_accounts, get_balance, list_pots, list_transactions, search_transactions), with minor deviations for the bare verbs/nouns monzo_sync and monzo_spending.

    Tool Count5/5

    Seven tools is well-scoped for a read-only personal banking integration. Each tool covers a distinct area (accounts, balance, pots, sync, transaction listing, search, spending analysis) without obvious redundancy.

    Completeness4/5

    The surface covers the core read-only lifecycle: account discovery, balances, pots, transaction retrieval/search, sync, and spending analysis. Minor gaps remain, such as fetching a single transaction's full detail or editing transaction notes/tags, but agents can work around these using the listing and search tools.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides an MCP server for querying and managing Monarch Money personal finance data through a local SQLite mirror with read-only SQL access. It enables users to sync transaction history from the Monarch API and analyze accounts, categories, and tags.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Read-only Monzo banking integration for Claude Code that allows querying balances, transactions, pots, and spending analysis through natural conversation.
      69 PyPI
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables local read-only exploration of Quicken Simplifi financial data through MCP, with tools for searching transactions, categories, tags, and merchants, using a local SQLite cache and token-based authentication.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables read-only access to Monarch Money financial data, including accounts, transactions, cash flow, spending, and income, via MCP, with secure local credential storage.
      1
      MIT