claude-usage-mcp

claude-usage-mcp

Reports your Claude subscription usage (5-hour and weekly limits) with a forecast and velocity recommendation, using Claude Code's existing OAuth session without requiring an API key.

Category
访问服务器

README

claude-usage-mcp

A tiny MCP server that reports your Claude subscription usage — the 5-hour and weekly limit windows — with a forecast and a velocity recommendation. No API key required: it reuses the OAuth session that Claude Code already stores on your machine, exactly like Claude Code's own /usage command.

How it works

  1. Reads Claude Code's OAuth credentials from ~/.claude/.credentials.json (or the macOS Keychain item Claude Code-credentials), refreshing the access token when needed.
  2. Calls the undocumented usage endpoint GET https://api.anthropic.com/api/oauth/usage with Authorization: Bearer <token> and anthropic-beta: oauth-2025-04-20. The response contains five_hour, seven_day and seven_day_opus, each with utilization (0–100) and resets_at.
  3. Because Anthropic's edge fingerprints the TLS handshake and rejects Node's fetch with 403 "Request not allowed", the server tries fetch first and falls back to the system curl binary (which is accepted). curl ships with Windows 10+, macOS and Linux. Set CLAUDE_USAGE_FORCE_CURL=1 to skip straight to curl.

You must be signed in via Claude Code (claude) for this to work.

Tools

get_usage

No arguments. Returns every available window with: utilization, resetsAt, remainingHours, projectedEndUtilization (where you'd land at reset at the current pace), exhaustAt (when you'd hit 100% if you will), and velocityRecommendation.

get_velocity

Argument window: "5h", "weekly", or "weekly_opus". Returns just the velocity recommendation and forecast for that one window.

The velocity recommendation (0–120%)

A single number telling you how hard you can push. It compares the sustainable pace (the rate that exactly finishes the quota at reset) to your current average pace:

  • 100% — full speed. At your current pace you land exactly at the limit right when the window resets.
  • < 100% — the fraction of your current pace you should slow to in order not to run out early. e.g. 40% = go at roughly 40% of your current speed.
  • > 100% (capped at 120%) — you have so much headroom you can't burn through the quota at anything like this pace. Go all out.

The 5-hour and weekly windows are evaluated separately, so you get 5h and weekly velocities independently.

Math per window (length L = 5h or 168h, utilization u%, reset at R):

elapsed   = now - (R - L)
remaining = R - now
rate      = u / elapsed                       # % per hour
forecast  = u / (elapsed / L)                 # % at reset if pace continues
exhaustAt = now + (100 - u) / rate            # only if forecast > 100
velocity  = ((100 - u) / remaining) / rate * 100   # clamped to [0, 120]

Install & build

npm install
npm run build

Register with an MCP client

Claude Desktop (claude_desktop_config.json), or any stdio MCP client:

{
  "mcpServers": {
    "claude-usage": {
      "command": "node",
      "args": ["/absolute/path/to/claude-usage-mcp/dist/index.js"]
    }
  }
}

Caveats

  • The usage endpoint is undocumented and can change or disappear without notice — treat it as best-effort.
  • The server can read your Claude Code OAuth tokens (the same file Claude Code itself uses). It never sends them anywhere except Anthropic's own endpoints, and passes the bearer token to curl via a stdin config file so it never appears in the process list.
  • Velocity uses the average pace over the elapsed window (one snapshot per call). It's a guide, not a guarantee; a burst right before reset can still overshoot.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选