Claude Code Usage

io.github.wheelbarrel00由 GitHub 帳號 wheelbarrel00 發布v0.1.0更新於 Oct 24, 2026

Claude Code token usage, cost, and plan limits from local logs and Anthropic's usage API.

發布方自己的服務:Claude Platform Docs

概覽

AI 產生的概覽

一個本機 MCP 伺服器,從本機日誌和 Anthropic 用量 API 讀取 Claude Code 的 token 用量、預估費用與方案額度狀態。

可以做什麼
查看當天費用與 token、5 小時與每週方案額度使用率(含重置時間與進度預測)、近期消耗速率、上下文視窗占用,以及按量付費的額外用量,資料來自本機 Claude Code 日誌與用量 API。依模型、專案、工作階段或 git 分支拆分用量,或依本月每日、歷來每月的时间维度拆分。隨需回答例如目前用量或本月各專案花費之類的問題。
適用情境
適合希望助理在對話中直接回答自己的 Claude Code 消耗、花費與方案額度問題,或依專案、模型拆分這些花費的情境。
執行需求
以 stdio 方式在本機執行,通常透過 npm 套件 claude-code-usage-mcp 以 npx 啟動。需要已登入的 Claude Code 安裝,因為它會讀取 Claude Code 設定目錄下的憑證檔與專案日誌。選用環境變數可調整貨幣、小數位、是否使用即時 API、請求間隔、消耗視窗、專案分組與設定目錄。取得即時方案額度需要網路存取。
安裝前請注意
會讀取 Claude Code 的本機憑證檔與工作階段日誌,並把磁碟上的 OAuth 權杖傳送到 Anthropic 的用量端點以取得即時額度;權杖僅在記憶體中更新。用量與費用數字由本機日誌推算,屬於估算值。未描述任何寫入、傳送或刪除類工具。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Claude Code Usage,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Claude Code Usage

[npm version] [MCP Registry] [License: MIT]

An MCP server that surfaces your Claude Code token usage, estimated cost, and plan-limit status in any MCP client (Zed, Claude Desktop, Cursor, and others). It reads Claude Code's own logs (~/.claude/projects/**/*.jsonl) and Anthropic's usage API, then exposes the data as tools the agent can call.

Published on npm as claude-code-usage-mcp and in the official MCP registry as io.github.wheelbarrel00/claude-code-usage.

What you get

Two tools:

  • get_claude_usage — today's cost and tokens, 5-hour and weekly plan-limit utilization (with reset times and a pace projection), recent burn rate, current context-window fill, and pay-as-you-go extra usage.
  • get_usage_breakdown — usage grouped by model, project, session, or git branch, or over time (daily this month / monthly all-time).

Ask the agent things like "what's my Claude usage right now?" or "break down my Claude spend by project this month." MCP tools are queried on demand — there's no persistent status-bar display.

Install

sh
npx -y claude-code-usage-mcp

Register it with your client. For Zed (settings.json):

json
{  "context_servers": {    "claude-code-usage": {      "command": "npx",      "args": ["-y", "claude-code-usage-mcp"]    }  }}

For Claude Desktop (claude_desktop_config.json), use the same command under "mcpServers" instead of "context_servers".

Requirements

An authenticated Claude Code install — the server reads ~/.claude/.credentials.json and ~/.claude/projects, the same files the CLI writes.

Configuration

Optional environment variables:

VariableDefaultMeaning
CCU_CURRENCYUSDISO currency code for cost formatting.
CCU_DECIMALS2Decimal places for cost figures.
CCU_USE_LIVE_APItrueFetch live limits from Anthropic; falls back to the on-disk cache.
CCU_LIVE_MIN_INTERVAL_SECONDS180Minimum seconds between live usage requests.
CCU_BURN_WINDOW_MINUTES15Trailing window for the burn-rate calculation.
CCU_PROJECT_GROUPINGgitgit, folder, or flat grouping for the project breakdown.
CLAUDE_CONFIG_DIR~/.claudeOverride the Claude Code config directory.

How it works

Live plan limits come from api.anthropic.com/api/oauth/usage using the OAuth token already on disk; the access token is refreshed in memory only, so a running Claude Code session is never logged out. Token and cost figures are parsed from the local session logs.

Repository layout

  • mcp-server/ — the MCP server (TypeScript, bundled to dist/server.mjs).
  • extension.toml, Cargo.toml, src/lib.rs — a self-contained Zed extension that embeds and launches the server (an alternative to the npx install above).

Build from source

sh
cd mcp-servernpm installnpm run build      # bundles to dist/server.mjsnode dist/server.mjs --selftest

Zed extension (self-contained, no npm needed)

The Zed extension embeds the bundled server and launches it with Zed's own Node. Build the server first, install rustup and the WebAssembly target (rustup target add wasm32-wasip1), then in Zed open Extensions → Install Dev Extension and select this repository's root folder.

License

MIT

來源:README.md,提交 bca551d

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Claude 整合