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 集成