patch-usage-mcp

patch-usage-mcp

Enables Claude to read your Patch API budget usage, including spend, burn rate, and account details, directly from chat.

Category
访问服务器

README

Patch Usage for Claude

Ask Claude how much of your Patch API budget you have used, straight from your chat. No more opening the dashboard and squinting at charts.

"How much of my Patch budget is left this month?"

"Am I going to run out before it resets?"

"Show me my spend for the last week."

This is a small MCP server. MCP (Model Context Protocol) is just a safe way to give Claude an extra skill. Once it is installed, Claude can read your Patch usage for you. It can only read your data unless you explicitly ask it to do something more (see Safety).

What it shows you

It reads the exact same numbers you see on your Patch dashboard:

The Patch usage dashboard

Plus a few things the dashboard does not show, like a projection of when you will run out at your current pace.


Setup (about 5 minutes, no coding needed)

There are two steps: (1) install a small helper program, then (2) give Claude your Patch sign-in so it can read your usage.

Step 1: Install uv (one time)

uv is a tiny tool that runs the server. You only ever do this once.

Open PowerShell (press the Windows key, type PowerShell, press Enter) and paste this line:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Close and reopen PowerShell when it finishes. (On a Mac, paste curl -LsSf https://astral.sh/uv/install.sh | sh into the Terminal instead.)

Step 2: Get your Patch token

This is the key that lets the server read your usage and nobody else's.

  1. Go to https://oai.joinpatch.org and sign in.
  2. Press F12 to open the developer panel, then click the Console tab.
  3. Click into the console, type this, and press Enter:
    localStorage.getItem('patch_token')
    
  4. It prints a long line of letters in quotes (it starts with eyJ...). Copy everything between the quotes.

Keep that copied. You need it in the next step.

Step 3: Connect it to Claude

In PowerShell, paste the command below, but replace PASTE_YOUR_TOKEN_HERE with the token you just copied:

claude mcp add patch-usage --scope user --env PATCH_TOKEN=PASTE_YOUR_TOKEN_HERE -- uvx --from git+https://github.com/h1kv/patch-usage-mcp patch-usage-mcp

uvx downloads and runs the server straight from GitHub, so there is nothing to clone and no folder to keep track of. Because this repository is private, your machine needs to be signed in to GitHub first (if git clone https://github.com/h1kv/patch-usage-mcp works for you, so will this).

That is it. Restart Claude (close it and open it again) and just ask: "How much of my Patch budget have I used?"

To check it worked, run claude mcp list and look for patch-usage: ... Connected.


Keeping it working: refreshing your token

Your Patch token expires every few days for security. When it does, Claude will tell you the token has expired and show you what to do. To fix it, get a fresh token (repeat Step 2 above) and run:

claude mcp remove patch-usage --scope user

Then run the Step 3 command again with the new token. That is the whole refresh.


What you can ask for

Every value is in US dollars. Everything in the first three groups is read-only.

Usage and account

Ask Claude about... Tool What you get
Budget, spend, percent used get_usage_summary Monthly limit, spend this month, all-time spend, reset date, throttle status, remaining, percent used
Spend per day get_usage_daily The last ~30 days, one figure per day
Spend per hour get_usage_hourly The last ~24 hours, one figure per hour
Your account get_account Your name, email, when you joined
Your API keys list_api_tokens Each key's name, prefix, and dates (never the full secret)
Your limit requests list_rate_limit_requests Each budget-increase request and whether it was approved

Smart insights

Ask Claude... Tool What you get
"Will I run out before reset?" get_burn_rate Average daily spend, projected month-end total, projected overage, and the date you are on track to run dry
"Give me the full picture" get_spend_report Everything above in one tidy summary, ready to read

Managing API keys (optional, guarded)

Ask Claude... Tool Notes
"Create a new API key" create_api_token Makes a live key. The secret is shown only once.
"Revoke a key" revoke_api_token Permanently deletes a key.

Safety

The two key-management tools can change your account, so they have two locks on them:

  1. They are flagged as destructive, so Claude asks your permission before running them.
  2. They do nothing on the first call. They only show you a preview of what would happen. They act only when you confirm. So a key can never be created or deleted by accident.

For the strongest protection, do not add create_api_token or revoke_api_token to any "always allow" list, so Claude always asks first.

A few things were left out on purpose:

  • Requesting a budget increase is not included, because a real person on the Patch team reviews those. Asking for one should be a deliberate human action, not something Claude does. You can still see your requests with list_rate_limit_requests.
  • Admin tools are not included. This account is not an admin, so they would not work anyway.

For developers

src/patch_usage_mcp/
  client.py      Authenticated HTTP client. Maps every failure to a clear message.
  analytics.py   Pure functions for burn-rate and spend-report math (no network).
  server.py      The MCP server: wires endpoints to tools, sets safety annotations.
tests/           Unit tests (mocked HTTP, no live token needed).

Run the test suite:

uv sync --extra dev
uv run pytest

To run your local working copy instead of the published GitHub version, clone the repo and point uv at the folder:

git clone https://github.com/h1kv/patch-usage-mcp
cd patch-usage-mcp
uv run patch-usage-mcp

Configuration is via environment variables:

  • PATCH_TOKEN (required): your Patch session JWT.
  • PATCH_BASE_URL (optional): defaults to https://oai.joinpatch.org/api.
  • PATCH_CLIENT_ID (optional): value of the X-Patch-Client header sent on every request, so Patch can tell MCP traffic apart from human browser traffic in its logs. Defaults to patch-usage-mcp. Set a custom value (for example a machine name) to tag your own requests, or set it empty to drop the header. The request User-Agent is always patch-usage-mcp/<version> either way.

If you prefer to register the server by hand, add this to your MCP config instead of using claude mcp add:

{
  "mcpServers": {
    "patch-usage": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/h1kv/patch-usage-mcp", "patch-usage-mcp"],
      "env": { "PATCH_TOKEN": "eyJhbGci...yourtoken..." }
    }
  }
}

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选