Skip to main content
Glama
upbank-mcp

upbank-mcp

by uiux-me

upbank-mcp

一个将 Up Banking API 暴露给 LLM 客户端的 Model Context Protocol 服务器,使用 FastMCP 构建并打包为 Docker。

它提供 19 个工具 和 2 个资源,覆盖 Up API 的完整公开表面——账户、交易、类别、标签、附件和 Webhook——响应针对 token 效率进行了重塑,游标分页端到端保留,并在速率限制时自动重试。


目录


Related MCP server: Up Bank MCP Server

要求

Up 账户

来自 https://api.up.com.au/getting_started 的个人访问令牌。令牌形如 up:yeah:…。

Docker

Docker Engine 20.10+ 及 Compose v2(docker compose,而非 docker-compose)。

Python

3.11+ — 仅当在 Docker 之外运行时需要。

Up API 可供澳大利亚的 Up 客户使用。令牌仅授予对签发客户自身数据的访问权限。


快速开始

git clone git@github.com:uiux-me/upbank-mcp.git
cd upbank-mcp
cp .env.example .env          # paste your token into UP_API_TOKEN
docker compose up --build

服务器监听于 http://127.0.0.1:8000/mcp。验证它:

docker compose exec upbank-mcp python -c "
import asyncio, upbank_mcp
from fastmcp import Client
async def main():
    async with Client(upbank_mcp.mcp) as c:
        print((await c.call_tool('ping')).data)
asyncio.run(main())"

健康的响应包含你的客户 id 和一个状态表情符号:

{'ok': True, 'id': 'eb59f467-…', 'status_emoji': '⚡️'}

配置

所有配置均通过环境变量进行。Compose 会自动从项目目录读取 .env。

变量

默认值

描述

UP_API_TOKEN

(必填)

个人访问令牌。服务器读取凭据的唯一变量。Compose 没有它则拒绝启动;直接运行时,服务器会启动并在第一次工具调用时失败。

UP_API_BASE

https://api.up.com.au/api/v1

API 基础 URL。仅用于针对 mock 进行测试时覆盖。

MCP_TRANSPORT

stdio

本地 MCP 客户端使用 stdio,网络可寻址服务器使用 http。Compose 设置为 http。

MCP_HOST

0.0.0.0

HTTP 传输的绑定地址,在容器内部。

MCP_PORT

8000

HTTP 传输的监听端口,在容器内部。

MCP_HOST_PORT

8000

仅限 Compose。 发布在 127.0.0.1 上的主机端口。如果 8000 已被占用,请更改此项。


运行服务器

HTTP,通过 Compose

最适合在你的机器上由多个客户端共享的长期运行服务器。

docker compose up --build          # foreground
docker compose up -d --build       # detached
docker compose logs -f             # follow logs
docker compose down                # stop and remove

端口仅发布在 127.0.0.1 上。参见 安全。

stdio,通过 Docker

最适合将服务器作为子进程启动的 MCP 客户端。构建镜像一次:

docker build -t upbank-mcp:latest .

镜像默认使用 MCP_TRANSPORT=stdio,因此无需覆盖传输设置。

不使用 Docker

pip install -e .
export UP_API_TOKEN=up:yeah:...
upbank-mcp

设置 MCP_TRANSPORT=http 以通过 HTTP 提供服务,而非 stdio。


连接 MCP 客户端

Claude Code

claude mcp add upbank \
  -e UP_API_TOKEN=up:yeah:... \
  -- docker run -i --rm -e UP_API_TOKEN upbank-mcp:latest

Claude Desktop,或任何使用 mcpServers 配置的客户端

{
  "mcpServers": {
    "upbank": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "UP_API_TOKEN", "upbank-mcp:latest"],
      "env": { "UP_API_TOKEN": "up:yeah:..." }
    }
  }
}

-i 是必需的——服务器通过 stdin/stdout 通信。--rm 在客户端断开连接时清理容器。

通过 HTTP

在 Compose 栈运行时,将客户端指向 http://127.0.0.1:8000/mcp。


工具参考

必需参数为粗体。每个列表工具都接受 cursor;参见 分页。

工具

工具

参数

返回

ping

—

{ok, id, status_emoji}。验证令牌和 API 可达性。

账户

工具

参数

返回

list_accounts

account_type(SAVER | TRANSACTIONAL | HOME_LOAN)、ownership_type(INDIVIDUAL | JOINT)、page_size(1–100,默认 30)、cursor

带余额的账户页。

get_account

account_id

单个账户。

交易

工具

参数

返回

list_transactions

account_id、status(HELD | SETTLED)、since、until、category、tag、page_size(1–100,默认 30)、cursor

交易页,最新的在前。省略 account_id 可跨所有账户搜索。

get_transaction

transaction_id

单笔交易,包括 hold、round-up 和 cashback 详情。

since 和 until 以闭区间约束 createdAt。category 接受父 id,该 id 会匹配其所有子类别。

类别

工具

参数

返回

list_categories

parent

类别树,或某个父类别的子类别。不分页。

get_category

category_id

单个类别及其父、子 id。

categorize_transaction

transaction_id、category_id

设置类别,当 category_id 为 null 时清除类别。

类别由 Up 固定,无法创建。Id 是诸如 restaurants-and-cafes 的 slug。只有 is_categorizable: true 的交易才能被更改,并且只接受叶子类别——传递诸如 good-life 的父类别会返回 HTTP 403。

标签

工具

参数

返回

list_tags

page_size(1–100,默认 50)、cursor

标签页。标签的 id 即其标签名。

add_tags_to_transaction

transaction_id、tags(列表)

添加标签,创建任何不存在的标签。

remove_tags_from_transaction

transaction_id、tags(列表)

从交易中移除标签。

一笔交易最多持有 6 个标签。没有剩余交易的标签会从 list_tags 中消失。

附件

工具

参数

返回

list_attachments

page_size(1–100,默认 30)、cursor

附件页。

get_attachment

attachment_id

单个附件。

file_url 是一个签名 URL,在 file_url_expires_at 时过期。请及时获取,或重新请求附件。

Webhook

工具

参数

返回

list_webhooks

page_size(1–100,默认 30)、cursor

Webhook 页。

get_webhook

webhook_id

单个 Webhook。

create_webhook

url、description(≤64 字符)

新的 Webhook,包括 secret_key。

delete_webhook

webhook_id

{ok, deleted}。永久删除。

ping_webhook

webhook_id

发送测试 PING 事件。

list_webhook_logs

webhook_id、page_size(1–100,默认 30)、cursor

最近的投递尝试,包含响应代码和响应体。

secret_key 仅在创建时返回,之后不再返回。请存储它,以验证传入投递上的 X-Up-Authenticity-Signature 头(SHA-256 HMAC)。


资源

URI

内容

up://accounts

每个账户及其当前余额,作为单个 JSON 快照。

up://categories

完整的类别树,用于解析有效的 category 筛选值。

两者均按需读取,反映读取时的状态。


响应约定

形状

Up 返回 JSON:API,它将每个字段嵌套在 attributes/relationships 下,并在每个资源上重复自链接。本服务器将每个资源扁平化为紧凑的 dict,并在可选字段不存在时省略它们,这显著降低了 token 成本,同时不丢失调用者所需的信息。

{
  "id": "45b83097-c97d-40da-9790-254056f03d40",
  "status": "SETTLED",
  "description": "Google One",
  "amount": { "value": "-2.49", "currency": "AUD", "base_units": -249 },
  "created_at": "2026-08-20T06:53:17+10:00",
  "settled_at": "2026-08-20T06:53:17+10:00",
  "account_id": "90c0fffc-bed6-4214-9450-6a76cd39957b",
  "category_id": "games-and-software",
  "parent_category_id": "good-life",
  "tags": [],
  "is_categorizable": true
}

诸如 foreign_amount、hold_info、round_up、cashback、card_purchase_method、note 和 message 等字段仅在交易具有它们时出现。

金额

每个金额都是一个对象:

{ "value": "-2.49", "currency": "AUD", "base_units": -249 }

value 是十进制字符串,base_units 是整数最小单位(AUD 为分)。借记为负数。 进行算术运算时优先使用 base_units,以避免浮点错误。

分页

列表工具返回:

{ "items": [ ... ], "next_cursor": "https://api.up.com.au/...", "prev_cursor": null }

要翻页,请将返回的游标作为同一工具的 cursor 参数传入。 游标是 Up 自己的不透明 URL,已经编码了过滤条件和页面大小,因此 当设置了 cursor 时,所有其他参数都会被忽略。cursor 为 null 表示该方向 没有更多页面。

游标在跟随前会针对配置的 API 主机进行验证,因此 游标无法将客户端重定向到其他服务器。

日期

since 和 until 接受 YYYY-MM-DD 或完整的 RFC-3339 时间戳。裸 日期和 naive 日期时间会锚定到 Australia/Sydney,这与 Up 在应用中的展示方式一致;对于所涉日期会应用正确的偏移量, 因此夏令时也能正确处理。无法解析的输入会在请求发出前被拒绝, 而不是在发出后以不透明的 HTTP 400 形式浮出。


错误处理与速率限制

  • API 错误会以 ToolError 形式抛出,包含 HTTP 状态码以及 Up 自己的错误标题 和详细信息,例如: HTTP 403 — Forbidden: Top-level categories cannot be set directly on transactions.

  • 429 和 5xx 响应会以指数退避方式重试最多 3 次, 并在存在 Retry-After 头时予以遵循。

  • 网络故障会在浮出前按相同计划重试。

  • 除 429 之外的 4xx 响应不会重试——它们表示请求有误。


项目结构

src/upbank_mcp/
├── client.py     Async HTTP client: auth, retry/backoff, date normalisation,
│                 cursor host validation
├── shapes.py     JSON:API → flat dict transforms, one per resource type
├── server.py     FastMCP instance, tool and resource definitions, entrypoint
├── __init__.py   Exports `mcp` and `main`
└── __main__.py   Enables `python -m upbank_mcp`

这种分离是刻意的:client.py 只了解 HTTP,与 MCP 无关; shapes.py 是纯粹的数据转换;server.py 持有工具契约。 每个模块都可以独立测试。


开发

pip install -e .
export UP_API_TOKEN=up:yeah:...
upbank-mcp                              # stdio
MCP_TRANSPORT=http upbank-mcp           # http on :8000

使用 FastMCP 客户端以进程内方式驱动服务器:

import asyncio
from fastmcp import Client
import upbank_mcp

async def main():
    async with Client(upbank_mcp.mcp) as client:
        print(await client.list_tools())
        result = await client.call_tool("list_accounts", {"account_type": "TRANSACTIONAL"})
        print(result.data)

asyncio.run(main())

更改后重建镜像:

docker compose up -d --build

安全

令牌威力强大。 Up 个人访问令牌不能移动资金——API 没有 支付或转账端点——但它们可以读取你的完整交易 历史,并修改类别、标签和 Webhook。请像对待密码一样对待它。

  • HTTP 传输本身没有认证。 任何能访问 该端口的人都可以读取你的银行数据。因此 Compose 只发布到 127.0.0.1。除非在它前面加上认证,否则不要将其绑定到 0.0.0.0, 也不要通过隧道或反向代理暴露它。

  • 令牌绝不会被烘焙进镜像。 .env 被列在 .dockerignore 中, 令牌在运行时提供。它不会出现在任何镜像层中,因此 该镜像可以安全地推送到注册表。

  • .env 已被 gitignore,.env.example 只包含占位符。

  • 容器以非 root 用户运行(uid 10001)。

  • 如果令牌曾经暴露,请立即轮换,参见 https://api.up.com.au/getting_started。 令牌不会自行过期。


故障排除

症状

原因与修复

No Up API token configured

UP_API_TOKEN 未设置或为空。检查 .env,并确保 Compose 是从项目目录运行的。

Compose 以 set UP_API_TOKEN in .env 退出

原因相同,发生在容器启动时而非首次调用时。

Bind for 127.0.0.1:8000 failed: port is already allocated

另一个进程占用了 8000 端口。在 .env 中设置 MCP_HOST_PORT。

HTTP 401 — Unauthorized

令牌无效或已被吊销。请重新签发。

HTTP 403 — Top-level categories cannot be set…

categorize_transaction 被传入了父类别。请使用 list_categories 中的叶子类别 ID。

HTTP 404 但 ID 看起来有效

ID 是按客户区分的。请确认该 ID 来自此令牌自己的数据。

反复出现 HTTP 429

持续触发速率限制。减小 page_size 并降低请求频率;重试已是自动的。

客户端不显示任何工具

客户端必须使用 -i 运行容器。没有它,stdio 会立即关闭。


参考

Available Tools

19 tools
add_tags_to_transactionAdd Tags To TransactionC

Add one or more tags to a transaction.

Inputs: tags (required), transaction_id (required). Returns: object

categorize_transactionCategorize TransactionA

Set or clear a transaction's category.

Only transactions with is_categorizable: true can be changed.

Inputs: transaction_id (required), category_id. Returns: object

create_webhookCreate WebhookA

Register a webhook for transaction events.

The response contains secret_key, which is returned only once — store it now to verify the X-Up-Authenticity-Signature header on incoming deliveries.

Inputs: url (required), description. Returns: object

delete_webhookDelete WebhookB

Permanently delete a webhook. This cannot be undone.

Inputs: webhook_id (required). Returns: object

get_accountGet AccountC

Retrieve a single account by id.

Inputs: account_id (required). Returns: object

get_attachmentGet AttachmentB

Retrieve a single attachment by id.

Inputs: attachment_id (required). Returns: object

get_categoryGet CategoryB

Retrieve a single category by id.

Inputs: category_id (required). Returns: object

get_transactionGet TransactionB

Retrieve a single transaction by id, including hold, round-up and cashback detail.

Inputs: transaction_id (required). Returns: object

get_webhookGet WebhookC

Retrieve a single webhook by id.

Inputs: webhook_id (required). Returns: object

list_accountsList AccountsB

List the customer's Up accounts with their current balances.

Inputs: cursor, page_size, account_type, ownership_type. Returns: object

list_attachmentsList AttachmentsB

List transaction attachments. File URLs are signed and expire shortly.

Inputs: cursor, page_size. Returns: object

list_categoriesList CategoriesA

List the category tree. Categories are fixed by Up, not user-defined.

Inputs: parent. Returns: object

list_tagsList TagsB

List all tags the customer has created. A tag's id is its label.

Inputs: cursor, page_size. Returns: object

list_transactionsList TransactionsA

List transactions, newest first, optionally filtered by account, status, date range, category or tag.

Inputs: tag, since, until, cursor, +4 more. Returns: object

list_webhook_logsList Webhook LogsA

List recent delivery attempts for a webhook, to debug failing deliveries.

Inputs: webhook_id (required), cursor, page_size. Returns: object

list_webhooksList WebhooksC

List configured webhooks.

Inputs: cursor, page_size. Returns: object

pingPingA

Check that the configured Up API token is valid and the API is reachable.

Inputs: no named parameters. Returns: object

ping_webhookPing WebhookA

Send a test PING event to a webhook to verify it is reachable.

Inputs: webhook_id (required). Returns: object

remove_tags_from_transactionRemove Tags From TransactionC

Remove one or more tags from a transaction.

Inputs: tags (required), transaction_id (required). Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 19 tools

    Disambiguation5/5

    Each tool targets a distinct resource and action (accounts, transactions, categories, tags, attachments, webhooks), with clear separation between list/get/create/delete/add/remove/ping operations. Overlap is minimal and descriptions explicitly differentiate ambiguous pairs like ping vs ping_webhook.

    Naming Consistency4/5

    Nearly all tools follow a consistent snake_case verb_noun pattern (list_accounts, get_transaction, create_webhook, add_tags_to_transaction). The sole minor deviation is 'ping', which lacks a noun but remains unambiguous and predictable.

    Tool Count4/5

    19 tools across six resource groups is slightly above the typical 3–15 sweet spot, but each tool maps to a distinct, necessary operation for a banking API. No tool appears redundant or trivially thin.

    Completeness4/5

    Coverage is broad: full webhook lifecycle plus ping/logs, transaction list/get/categorize, tag add/remove/list, and read operations for accounts, categories, and attachments. Minor gaps exist, notably no attachment upload/delete, but core workflows are otherwise well-covered.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      D
      quality
      D
      maintenance
      A Model Context Protocol server that allows AI assistants to connect to and manage Israeli bank accounts, fetch transactions, and handle authentication for all major Israeli banks and credit card companies.
      2
      38
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP wrapper for Up Bank's API that allows Claude and other MCP-enabled clients to manage accounts, transactions, categories, tags, and webhooks from Up Bank.
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables interaction with You Need A Budget (YNAB) via their API, allowing users to manage budgets, accounts, categories, and transactions through natural language.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that allows AI assistants to interact with Lunch Money accounts, enabling management of transactions, categories, budgets, and other financial data through natural language commands.
      MIT