AI Usage

io.github.MohitBansal321由 GitHub 帳號 MohitBansal321 發布v0.16.1更新於 Oct 30, 2026

Reports real token usage and cost from Claude Code and OpenCode data. Nothing leaves your machine.

概覽

AI 產生的概覽

本機 MCP 伺服器,從電腦上既有的 Claude Code、OpenCode 與 Codex CLI 資料統計 token 用量與成本,並依工作階段、模型、專案與日期細分。

可以做什麼
  • 彙總某段期間的 token 用量與成本,依用戶端拆分,並區分輸入、輸出、快取讀取、快取寫入與推理 token
  • 檢視單一工作階段、最近的工作階段,以及依模型與依用戶端的用量
  • 依專案、依日或依一天中的時段拆分,也可用專案×日期等兩個維度交叉統計
  • 把已記錄的 token 依其他模型的牌價重新計價,並與實際成本比較
  • 找出工作階段中的提示快取中斷,並說明某段期間的用量去向與可調整之處
  • 回報 Claude Pro/Max 五小時與每週額度使用情況(以 Claude Code 最後回報為準),含重置時間與消耗速度
適用情境
適合讓助理回答關於自己編碼助理花費的問題:哪個模型或儲存庫最耗 token、某次工作階段為何失去快取、換較便宜的模型是否更省,以及距離訂閱額度還有多遠。
執行需求
透過 npx 以 stdio 在本機執行,需要 Node.js 22.13 或更新版本。不需帳號、API 金鑰或設定。它讀取 Claude Code、OpenCode 與 Codex CLI 已寫入本機的資料,首次執行會把歷史複製到本機 SQLite 資料庫。
安裝前請注意
它會讀取本機的編碼助理對話紀錄與工作階段資料庫,因此看得到提示內容、專案路徑與 git 分支,請留意本機資料庫的存放位置。有兩個對外 GET 請求(npm 版本檢查與公開價格表下載),每天最多各一次,可用 AI_USAGE_NO_UPDATE_CHECK=1 與 AI_USAGE_NO_PRICING_REFRESH=1 關閉。回報成本與估算成本基準不同,不可相加;Claude Code 的數字是依 API 價格換算的估算,並非訂閱實際支出。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

ai-usage-mcp

[npm version] [CI] [npm downloads] [node] [license]

Ask your coding agent what it has cost you — and where the money went. An MCP server that answers from the data Claude Code, OpenCode and Codex CLI already wrote to your machine. Nothing is uploaded, and there is no API key or account.

text
> Where are my tokens going, and what should I change?> Where did this session lose its prompt cache?> Which of my projects is getting more expensive, day by day?> What would last week have cost on Sonnet instead of Opus?

Three things it does that reading the transcripts cannot:

  • It keeps your history. Claude Code deletes transcripts after 30 days (cleanupPeriodDays). Every turn is copied into a local SQLite database as it is seen, so last quarter is still there after the source files are gone — and merges two machines into one total.
  • It finds where the cache broke. Cache tokens are where the money is — 94.7% of all tokens on the development machine. cache_health finds the turns where a session lost its cached prefix and paid to re-write the whole context, names the likely cause (a model switch, idling past the 5-minute TTL, an edited CLAUDE.md) and prices the premium.
  • It proves its numbers. Claude Code writes one JSONL line per content block, each repeating the same usage object, so summing lines inflates every figure 2–3×. ai-usage verify re-reads both sources with a second, independent implementation that shares no reduction code with the collectors, and diffs the result against its own database.
text
$ ai-usage verify
== claude-code ==  MATCH    claude JSONL, deduped by stop_reason line (independent rule)  INFO     claude JSONL, naive sum of every usage line (NOT used -- shows the double count)           delta:  cache-read 990,824,820 ...
RESULT: every client reconciles exactly against at least one independent read of its source.

Also: your Pro/Max plan limits — the 5-hour and weekly percentages Claude Code reports, kept by a status line and projected to the time you would hit 100% — plus counterfactual_cost (these exact tokens at another model's rates), budgets with run rate and forecast, project × day breakdowns, and CSV/JSON export. It supports Claude Code and OpenCode, and exposes twelve MCP tools plus resources, prompts and a debug CLI that prints the same text the tools return.

It never fabricates a number. If a source does not record something, it is reported as unavailable — not as zero.

What the output looks like (sample data)
text
$ ai-usage stats --todayUsage summary -- today (local time)Subagent/sidechain turns: INCLUDED (3 main + 1 subagent turns).
Records: 4   Sessions: 2
Tokens (all clients):  Input:        1,871  Output:       16,909 (16.9K)  Cache read:   2,452,000 (2.45M)  Cache write:  37,300 (37.3K)  Reasoning:    2,600  Total:        2,508,080 (2.51M)
  Cost (reported by client, exact): $0.41  [1 records]  Cost (estimated, API-equivalent):  $1.50  [3 records]
By client:  claude-code  --  3 records, 1 sessions    Cache read:   2,238,000 (2.24M)    Total:        2,280,001 (2.28M)    Cost (estimated, API-equivalent):  $1.50  [3 records]
  opencode  --  1 records, 1 sessions    Cache read:   214,000 (214.0K)    Total:        228,079 (228.1K)    Cost (reported by client, exact): $0.41  [1 records]

The two cost lines are never added together, and never will be — see How cost is reported.

Try it in one command

There's nothing to configure and no account to create. It reads what Claude Code and OpenCode have already written to this machine:

bash
npx -y -p ai-usage-mcp ai-usage report

The first run copies your history into a local database, which takes a few seconds. The report gives a verdict for the last 7 days, says where the tokens went, and lists what to change. To ask your agent questions like the ones above, install it as an MCP server.

ai-usage or ccusage?

ccusage is the established tool, and a good one: it covers far more agents, and its Claude Code token counts agree with this package's exactly — every token class, every day, checked against ccusage 20.0.26 on the development machine for 21–25 September 2026. For a quick report across many agents, use it.

Use this one when you want what a report over the current transcripts cannot give: history that outlives Claude Code's 30-day cleanup, cache breaks found and priced, counterfactual pricing, budgets, cross-dimension breakdowns, reported and estimated cost kept apart, and token totals proved against a second read by verify.


Install

Requires Node.js 22.13+. No compiler, build tools or particular npm version needed: storage uses Node's built-in node:sqlite, which is unflagged from 22.13.0 onward. There is no mandatory native dependency.

better-sqlite3 remains an optional fallback for hosts whose Node predates that. It is never required — if it cannot be built, npm skips it and the server still runs.

Claude Code

As a plugin — recommended. Run these two inside Claude Code:

text
/plugin marketplace add MohitBansal321/ai-usage-mcp/plugin install ai-usage@ai-usage-mcp

That wires up the MCP server and installs the three prompts as real slash commands — /ai-usage:daily-review, /ai-usage:why-was-today-expensive, /ai-usage:project-cost — which most clients never surface from MCP prompts alone. If the install summary says Run /reload-plugins to activate., run that. The equivalent from your shell is claude plugin marketplace add MohitBansal321/ai-usage-mcp.

The plugin declares npx -y ai-usage-mcp as its server, so the server itself still comes from npm and re-resolves on each cold start. Updating the plugin and updating the server are therefore independent — see Updating.

Or as a plain MCP server, if you would rather not add a marketplace. Nothing to install first — npx fetches it on demand:

bash
claude mcp add ai-usage -s user -- npx -y ai-usage-mcp

On native Windows (not WSL), wrap it in cmd /c instead:

bash
claude mcp add ai-usage -s user -- cmd /c npx -y ai-usage-mcp

Why: on Windows npx is npx.cmd, and the MCP TypeScript SDK spawns servers with shell: false. Node cannot execute a .cmd file that way — its docs say such files "can be invoked using child_process.spawn() with the shell option set … or by spawning cmd.exe and passing the .bat or .cmd file as an argument". cmd /c is that second form. This applies to every SDK-based client below, not just Claude Code.

-s user makes it available in every project. Drop it to add the server to the current project only. Then run /mcp inside Claude Code to confirm it connected.

No claude command? (VS Code / JetBrains extension users)

The extension reads the same configuration as the CLI, so you can add the server by editing a file — no CLI needed. Pick whichever scope you want:

For one project — create .mcp.json in the project root:

json
{  "mcpServers": {    "ai-usage": {      "command": "npx",      "args": ["-y", "ai-usage-mcp"]    }  }}

Claude Code asks you to approve a project-scoped server the first time it loads it. This file is safe to commit if you want your team to get it too.

For all your projects — add the same mcpServers block at the top level of ~/.claude.json (%USERPROFILE%\.claude.json on Windows):

json
{  "mcpServers": {    "ai-usage": {      "command": "npx",      "args": ["-y", "ai-usage-mcp"]    }  }}

That file already exists and holds other settings — add the mcpServers key alongside them rather than replacing the file.

Then reload the window (Developer: Reload Window in VS Code) and run /mcp. Configuration is read when a session starts, so an already-open session will not pick it up.

OpenCode

bash
opencode mcp add ai-usage       # choose a local server, command: ai-usage-mcp

Or add it to ~/.config/opencode/opencode.jsonc:

jsonc
{  "mcp": {    "ai-usage": {      "type": "local",      "command": ["npx", "-y", "ai-usage-mcp"],    },  },}

Confirm with opencode mcp list.

Codex CLI

bash
codex mcp add ai-usage -- npx -y ai-usage-mcp

Codex usage is read from ~/.codex/sessions (or $CODEX_HOME). Codex records no cost, so its cost is an API-equivalent estimate, or unavailable for a model the pricing table lacks. Support is new and verified against two sessions so far; ai-usage verify checks it on yours.

Other MCP clients

Cursor, Google Antigravity, Windsurf and Claude Desktop take the same npx -y ai-usage-mcp block; only the config file differs. The client you ask from does not have to be one you measure: ask from Cursor, and you still get your Claude Code numbers. Paths and details are in docs/INSTALL.md.

The debug CLI

The MCP server needs no install. To also get the ai-usage CLI on your PATH:

bash
npm install -g ai-usage-mcpai-usage status

Or run it without installing:

bash
npx -y -p ai-usage-mcp ai-usage stats --today

Windows: no longer needs a particular npm. The node-gyp failure that used to break this install came from the native better-sqlite3 dependency, which is now optional and unused on Node 22.13+. If npm still reports a build failure for it, that message is a skipped optional dependency, not a failed install — ai-usage status will show SQLite driver: node:sqlite and everything works.

Updating

npx -y ai-usage-mcp re-resolves the version on every cold start, so restarting your client picks up a release. A global install is pinned: npm install -g ai-usage-mcp@latest. ai-usage status and the MCP server both tell you when you are behind. docs/INSTALL.md says what each kind of install needs, and describes the one request the check makes.

Compatibility

Both source formats are internal and unversioned, so a client update can change them. This is what has been checked, and how:

ClientLast verifiedEarlier verifications
Claude Code2.1.308, 2026-10-232.1.2xx, 2.1.251
OpenCode2.0.32, 2026-10-231.18.25, 2.0.30
Codex CLI0.162.0-alpha.17.2 and 0.114.0, 2026-10-23 (two sessions)
Node.js22.13+ and 24, in CI
OSLinux, macOS and Windows, in CI

"Verified" means ai-usage verify matched every token class exactly against an independent re-read of the client's own data (715 MB of Claude Code transcripts, a 251 MB opencode.db, and Codex's session rollouts). It compares the same bytes the sync read, so a session still writing does not show up as a mismatch. If a client update breaks collection, ai-usage status warns that the client keeps writing but no new turns arrive.

Ask it things

Once connected, ask in plain language:

text
How many tokens have I used today?Show my usage for this session.Which model consumed the most tokens?How much did Claude Code cost me today?Show all usage from the last 7 days.Which repository is my spend going to?Break my last 7 days down day by day.

MCP tools

ToolReturns
usage_reportStart here: verdict, where usage went, heaviest sessions, what to change
usage_summaryTotals for a period, split by client, tokens + cost
session_usageOne session: client, model, duration, token breakdown, cost
model_usagePer-model tokens and cost
client_usagePer-client (Claude Code vs OpenCode) tokens and cost
recent_sessionsRecent sessions with project, client, tokens, cost
project_usagePer-project tokens and cost, by the directory a turn ran in
daily_usagePer-day tokens and cost, newest day first
usage_breakdownTwo or more dimensions at once -- project × day, model × day, client × day
counterfactual_costThese tokens at another model's list rates, beside what they actually cost
cache_healthOne session's cache breaks: when the cached prefix was lost, why, and cost
plan_usagePro/Max 5-hour and weekly limit usage, when each resets, and the pace

Start here: usage_report

On a Pro, Max or Team plan the price is fixed, so "what did it cost" is the wrong question. The useful one is how much of your limit went to real work. usage_report (or ai-usage report) answers it for the last 7 days by default:

text
Verdict: High waste -- a large share of this usage re-read or rebuilt old context.
Where it went (share of usage, weighted by API-equivalent price):   37.1%  re-reading context above 100k tokens (1,021 turns; largest context 735.2K)   10.2%  rebuilding a lost cache (12 times, 12 after an idle break)
What to change:  1. Compact earlier. ... 5 session(s) grew past 200k tokens of context ...  2. Don't resume a session that has gone cold. ...
Heaviest sessions:   47.7%  Admission transfer tariff services and roles linking  [development, claude-code]

It measures two kinds of waste from token counts alone. Context carry exists because every message re-sends the whole conversation, so a turn at 300k context re-reads 300k tokens to take one step; the part above 100k is what compacting earlier would not have carried. Cache rebuilds are turns where the cached prefix was lost and the whole context was re-written (the same detection as cache_health). Sessions are named by the title the client gave them and the git branch they ran on, or no branch when Claude Code recorded none (usually a session started outside a git repo). Neither kind of waste is claimed as wholly avoidable, and the shares are a guide to where usage went, not exact limit consumption: Anthropic does not publish how subscription limits weight each token type.

Plan limits, the status line and the context warning

Claude Code writes your Pro/Max 5-hour and weekly limits to no file, but it passes them to a status line. With ai-usage statusline as yours, the limits are recorded, with the reset times and when the current pace would reach 100%. Today's cost and the session's cache hit rate and breaks are shown beside them, and plan_usage answers the same from inside a conversation. ai-usage hook warns before a prompt when the session's context has grown expensive to re-send. ai-usage status says whether each one is switched on. Setup and details are in docs/STATUS_LINE.md.

Resources and prompts

Three resources can be pulled into a conversation with an @ mention, instead of asking for a tool call:

ResourceContents
usage://todayToday's totals, split by client
usage://session/latestThe most recent session in detail
usage://statusWhich build is answering, its sources, and whether it is stale

Three prompts appear as slash commands in a client that surfaces them:

PromptAsks
daily-reviewWhat did I spend today, and on what
why-was-today-expensiveWhich model, session and project drove today's cost
project-costWhat one project has cost over a period

Each prompt names the tools to call and carries the reported-vs-estimated cost rule with it, so a paraphrased summary cannot quietly merge the two cost bases.

Most clients do not surface MCP prompts, which is why the Claude Code plugin ships the same three as real slash commands (/ai-usage:daily-review and friends). They are the same feature through two surfaces, and a test asserts the two lists cannot drift apart.

Debug CLI

Same service layer, different frontend — so the two can never disagree.

bash
ai-usage report      # start here: verdict, where usage went, what to change (last 7 days)ai-usage status      # collectors, data stores, db path, record counts, last sync, hooks on/offai-usage sync        # run the collectorsai-usage stats       # totals   (--today, --days N, --since/--until)ai-usage models      # per-modelai-usage clients     # per-clientai-usage projects    # per-project  (--limit N)ai-usage sessions    # recent sessionsai-usage session ID  # one session in detailai-usage daily       # per-day breakdownai-usage counterfactual  # these tokens on another model (--target-models a,b)ai-usage verify      # re-read the sources and diff them against the local databaseai-usage hook        # Claude Code UserPromptSubmit hook: warns when context is large

Add --json to any command for machine-readable output.

More in docs/CLI.md:

  • narrowing to several projects, models or clients
  • CSV and JSON export
  • keeping history after Claude Code's 30-day cleanup, and merging two machines
  • cache economics
  • budgets with run rate and forecast
  • a single value and an exit code for scripts and alerts
  • project × day breakdowns, trends, period comparisons, and paging

How cost is reported

Cost is never a single blended number. Every figure carries a basis:

BasisMeaning
reportedThe client told us the cost. OpenCode does this. Exact.
estimatedComputed from a versioned pricing table. Claude Code records no cost.
unavailableWe could not produce an honest number (e.g. no price for that model).

Alongside those, every report counts records whose model has no pricing-table entry, so a model that is genuinely free is distinguishable from one nobody has priced. A client that reports its own cost files a perfectly ordinary $0 for an unpriced model, which otherwise reads exactly like free:

text
opencode  --  6,841 records, 280 sessions  Cost (reported by client, exact): $0.48  [6,841 records]  No estimate attempted for 6,813 record(s) -- no price in table builtin-2026-10-23 for  that model: big-pickle, gpt-5.5, z-ai/glm-5.2 and 16 more. Any $0 above covers only what  was reported, not those records.

In --json and in MCP structuredContent these are cost.unpricedRecords and cost.unpricedModels. Both are absent rather than 0 when the caller supplied no list of priced models: "not asked" is not the same as "none".

The Claude Code figure is an "API-equivalent estimated cost" — what those tokens would cost at Anthropic API list prices. If you are on a Claude Pro or Max subscription, your marginal cost per request is $0, and this number is not what you paid. It is useful for comparing workloads, not for reconciling a bill.

Reported and estimated costs are shown on separate lines and must not be added together.

Cache tokens are priced properly rather than lumped in with input:

  • cache read bills at 0.1× the input rate on most models, 0.05× on Opus 5.5 / Sonnet 5.5 and 0.025× on Fable 5.1 / Mythos 5.1
  • cache write bills at 1.25× (5-minute TTL) or 2× (1-hour TTL)

The two cache-write TTLs are tracked separately because both occur heavily in practice — on the machine this was developed against, 18.0M of 27.2M cache-write tokens used the 1-hour TTL, so averaging the rates would have understated cost substantially.

Which models ship with prices, how a model released after this package is priced automatically, and how to add or correct a price yourself are covered in docs/PRICING.md.

Why token counts here are trustworthy

Both source formats are internal and undocumented, and both contain traps that produce badly wrong numbers if taken at face value. What this tool does about them:

  • Claude Code writes one line per content block, repeating the same usage object with a cumulative output_tokens. Summing those lines inflates every figure by 2.15×-3.05× depending on the token class (measured). Records are deduplicated on requestId + message.id, taking the maximum of each field.
  • usage.iterations[] is already included in the top-level totals and is never summed.
  • Subagent turns live in separate files (<session>/subagents/…), not behind the isSidechain flag — which is never set in practice. They are classified by path.
  • <synthetic> is not a model and is excluded.
  • OpenCode's session rollup columns can be stale. They are a cached aggregate; on the development machine they had lost 545,977 input tokens across 4 sessions. This tool reads the message grain instead, which is corroborated byte-for-byte by the independent part table. OpenCode 2.x writes that grain to session_message instead (and no longer writes part rows), so newer turns have no second table to corroborate them.
  • Reasoning tokens mean different things per client. In Claude Code, thinking tokens are inside output_tokens; in OpenCode, reasoning is a sibling of output. Totals are computed per client accordingly, so reasoning is never double-counted.
  • Cache tokens dwarf everything else (800M cache-read vs 24K input is a real ratio), so token classes are always broken out and never presented as one blended total.

Run ai-usage verify to check this yourself. It re-reads both sources with a second, independent implementation that shares no reduction code with the collectors, and diffs the result against the database:

text
== opencode ==  MATCH    opencode.db message grain (what we collect)  MATCH    opencode.db part/step-finish grain (independent corroboration)  INFO     opencode.db session rollup grain (what `opencode stats` headline shows)           delta:  input -545,977 ...
== claude-code ==  MATCH    claude JSONL, deduped by stop_reason line (independent rule)  INFO     claude JSONL, naive sum of every usage line (NOT used — shows the double count)           delta:  cache-read 990,824,820 ...
RESULT: every client reconciles exactly against at least one independent read of its source.

verify syncs first and compares only activity before a shared cutoff — both clients append to their stores while we read them, so without a cutoff the source always looks a few requests ahead.

It compares only sessions the source still holds. Both clients delete their own history -- Claude Code removes transcripts after cleanupPeriodDays, 30 days by default -- while the local database keeps what it collected, so after a month the database legitimately holds more than the source. Those sessions are listed on a separate Retained, not compared line instead of being counted as a mismatch. Any source record missing from the database still fails the check, because the source side is never narrowed.

Subagent turns

Included by default, because they are real spend. Every report says which way it went, and --no-subagents / includeSubagents: false excludes them. session_usage always shows the main/subagent split separately.


What stays on your machine

Everything. Your usage data never leaves the machine.

  • No telemetry, no analytics, no crash reporting, no phone-home.
  • No cloud sync, no accounts, no API keys — the tool never calls an LLM API.
  • Two outbound requests exist, both plain GETs of public files that send no usage data and no identifiers, both at most once a day, and both disabled by AI_USAGE_NO_UPDATE_CHECK=1:
    • the update check asks the npm registry for the latest published version number (ai-usage status, and the MCP server in the background after its handshake);
    • the price refresh downloads LiteLLM's public price list, so models released after the built-in table are priced (ai-usage sync, and the MCP server in the background after its handshake). AI_USAGE_NO_PRICING_REFRESH=1 turns off just this one.
  • No conversation content is read into the database. The collectors extract token counts, model ids, timestamps, session ids and project paths. Prompts, completions, tool inputs and file contents are skipped.
  • Source data is opened read-only. A running OpenCode is never disturbed: the collector opens its database with a read-only connection, and falls back to a temporary snapshot copy (.db + -wal + -shm) only if that fails.
  • Everything is stored in one local SQLite file:
text
~/.local/share/ai-usage-mcp/usage.db          # override with AI_USAGE_DB

Delete that file to erase everything the tool knows.

Note: the database path deliberately ignores XDG_DATA_HOME. A sandboxed launcher (the VSCode snap, for example) exports its own XDG_DATA_HOME, which is exactly how OpenCode's history ended up split across two databases on the development machine. The MCP server and the CLI must always agree on one file.


Troubleshooting

docs/TROUBLESHOOTING.md covers:

  • a collector reported as unavailable
  • numbers lower than opencode stats
  • additional stores
  • /mcp showing the server as failed
  • node-gyp errors
  • models with no estimate
  • totals that changed after a re-sync
  • a client that keeps writing while no new turns arrive

Development

bash
npm installnpm run check          # typecheck, lint, format check, build, tests -- what CI runs

Individually:

bash
npm run typecheck      # tsc, covering src and testsnpm run lint           # eslint (type-aware)npm run format         # prettier --writenpm run build          # emit dist/npm test               # collectors, services, formatter, MCP integration, parity, packagingnpm run test:coverage  # with coverage report

Architecture — the one rule that matters is that MCP never knows where data comes from:

text
MCP tools ─┐           ├─> UsageService ─> collectors ─> Claude Code JSONL / OpenCode SQLitedebug CLI ─┘        │                    └─> local SQLite

Business logic lives in src/services/. The MCP handlers and the CLI commands are both thin frontends over UsageService, and they render through the same formatter.

See docs/DATA_SOURCES.md for the verified on-disk formats of both sources, including everything that had to be corrected by inspecting real data, and docs/PUBLISHING.md for the release process.

Contributing

Issues and pull requests are welcome. Two expectations specific to this project:

  1. Never fabricate a number. If a source does not record something, it must surface as unavailable, not as zero.
  2. If your change touches a collector, ai-usage verify must still report a zero delta, and if it changes how an on-disk format is understood, update docs/DATA_SOURCES.md in the same change. Both source formats are internal and unversioned, so that file is the only record of what was actually observed.

npm run check runs everything CI runs. CONTRIBUTING.md has the setup, the layout and the pull request checklist.

Links

License

MIT — see LICENSE.

來源:README.md,提交 1c79f16

工具

12

usage_summary

Usage summary

Total token usage and cost for a period, split by client (Claude Code, OpenCode, Codex). Tokens are broken out into input / output / cache-read / cache-write / reasoning, because cache tokens typically dwarf input and a single blended total is misleading. Reported cost (from OpenCode) and estimated cost (computed for Claude Code and Codex, which record none) are always listed separately and must not be summed. Also reports the cache hit rate and reads-per-write, which are what say whether the cache is paying for itself -- the raw cache counts alone cannot.

輸入參數dayssincetodayuntilclientmodelscompareprojectPathprojectPathsincludeSubagents

session_usage

Session usage

Usage for one session: client, model(s), duration, token breakdown and cost. Accepts a full session id or an unambiguous fragment of one. Subagent turns are reported separately from main-thread turns.

輸入參數sessionId必填includeSubagents

model_usage

Usage by model

Per-model token usage and cost, highest token count first. Use this to answer "which model consumed the most tokens". Cost is labelled reported vs estimated per model.

輸入參數dayssortlimitsincetodayuntilclientmodelsoffsetprojectPathprojectPathsincludeSubagents

client_usage

Usage by client

Token usage and cost per coding agent (Claude Code, OpenCode, Codex). Note that the two cost figures are not comparable as a single number: OpenCode reports actual charged cost, while the Claude Code and Codex figures are API-equivalent estimates (a subscription has $0 marginal cost per request).

輸入參數dayssortlimitsincetodayuntilmodelsoffsetprojectPathprojectPathsincludeSubagents

project_usage

Usage by project

Per-project token usage and cost, highest token count first. A project is the working directory a turn ran in. Use this to answer "which repository is my spend going to". Turns whose project could not be resolved are grouped as (unknown) rather than dropped, and cost is labelled reported vs estimated per project.

輸入參數dayssortlimitsincetodayuntilclientmodelsoffsetprojectPathprojectPathsincludeSubagents

daily_usage

Usage by day

Token usage and cost bucketed on the time axis, newest first. Use this for "how much did I use yesterday", for a trend over a period, or -- with grain "hour-of-day" -- for "when during the day do I burn tokens". Buckets with NO activity are included and flagged `zeroFilled`, because omitting them hides the gaps and makes an ordinary bucket look like a spike beside one weeks earlier. All buckets are local time, so they agree with the period filter rather than drifting by a timezone offset. Cost is labelled reported vs estimated per bucket.

輸入參數daysgrainsincetodayuntilclientmodelsprojectPathprojectPathsincludeSubagents

usage_breakdown

Usage broken down by two dimensions

Token usage and cost cut by two or more dimensions at once -- project x day, model x day, client x day -- as one tidy row set. Use this for "which of my projects is getting more expensive", which the single-axis tools cannot answer: project_usage gives a total with no trend, and daily_usage narrowed to one project gives one series, so answering it otherwise means enumerating projects and issuing one call each. Combinations with no activity are absent rather than returned as zero rows. Cost stays labelled reported vs estimated per row and the two are never summed.

輸入參數axes必填dayssortlimitsincetodayuntilclientmodelsoffsetprojectPathprojectPaths另有 1 個

counterfactual_cost

Cost on another model

What the tokens from a period would have cost at another model’s list rates, alongside what they actually cost. Use this for "would Sonnet have been cheaper than Opus for this". It re-prices the exact token counts that were recorded, grouped by client, model and speed so the fast-mode premium and the two different reasoning-token conventions are handled correctly. Also reports what the same tokens would have cost with NO prompt caching at all, per model -- which is the figure that says whether caching is paying for itself. IMPORTANT: the model scenarios are a counterfactual, not a saving — the same task on a different model generally takes a different number of turns with a different context on each, and nothing on disk can say what that would have been. Report it as such, keep every scenario labelled an estimate, and never subtract a scenario from the reported cost to claim a number.

輸入參數dayssincetodayuntilclientmodelsprojectPathfilterModelsprojectPathstargetModelsincludeSubagents

cache_health

Cache Health

Finds cache breaks in a session -- turns where the prompt-cache prefix was not reused, so the context was re-written at cache-write prices instead of read back cheaply. A break is a spike in cache writes AND a drop in cache reads; a write spike alone (e.g. reading one large file) is not one. Each break lists the turn, token counts, likely cause (model or speed switch, idle past the 5-minute TTL, or an early-context change such as an edited CLAUDE.md), and its API-equivalent write premium from the pricing table. Also returns the overall cache hit rate and reads-per-write.

輸入參數sessionId必填baselineWindowminCacheWritesspikeThresholdincludeSubagents

usage_report

Usage report

Where a period of usage went, how much of it did no new work, and what to change -- the first thing to run for "where are my tokens going" or "why do I hit my limit". Gives a verdict, the share of usage spent re-reading large contexts (every message re-sends the whole conversation) and rebuilding a lost prompt cache, the heaviest sessions by their own titles and git branches, usage per branch, and plain-language fixes. Shares are weighted by API-equivalent list price as a relative measure; on a subscription that figure is not money spent. Defaults to the last 7 days.

輸入參數dayssincetodayuntilclientmodelsprojectPathprojectPathsincludeSubagents

plan_usage

Plan Usage

How much of the Claude Pro/Max 5-hour and weekly usage limits is used, as Claude Code itself last reported it, with when each window resets. Also the average pace within the window and the time it would reach 100% at that pace (a projection, labelled as one), and the tokens and API-equivalent cost of this machine's Claude Code turns since the window began. The percentages are recorded only while `ai-usage statusline` is configured as the Claude Code status line; without it they are reported as unavailable, never as 0%. Answers "how close am I to my limit" and "will I run out before it resets".

輸入參數includeSubagents

recent_sessions

Recent sessions

Most recently active sessions with project path, client, model(s), duration, token breakdown and cost. Use the returned session id with session_usage for detail.

輸入參數dayssortlimitsincetodayuntilclientmodelsoffsetprojectPathprojectPathsincludeSubagents

版本歷史

9
  1. v0.16.1最新Oct 23, 2026
  2. v0.14.0Oct 16, 2026
  3. v0.13.0Oct 12, 2026
  4. v0.12.1Sep 28, 2026
  5. v0.11.2Sep 28, 2026
  6. v0.10.0Sep 26, 2026
  7. v0.9.0Sep 18, 2026
  8. v0.8.0Sep 17, 2026
  9. v0.7.0Sep 16, 2026

評分

已滿足適用檢查項的 90%

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

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

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

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分