Token Meter
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
> Track Claude Code, Codex & Cursor token usage and cost locally — no account, no cloud.
>
> One local dashboard for your **Claude Code** and **Codex** token usage.
> Free, MCP-aware, MIT-licensed core.
>
> npm: @whdrnr2583/token-meter · GitHub: whdrnr2583-cmd/token-meter · Site: token-meter.dev
Token Meter parses the JSONL files that Claude Code and Codex already write to
disk and turns them into a real dashboard: cost per project, per model, per MCP
tool, per hour. Your data never leaves your machine.
Run your first audit
Scans your ingested Claude Code + Codex history for expensive sessions,
oversized tool responses, slow tools, repeated calls, and cache waste, ranked
by cost and confidence. Runs entirely against your local SQLite database —
same local-first, no-cloud processing as the rest of Token Meter. Add
--json for machine-readable output; see docs/audit.md for
the full flag list and JSON schema.
When to use this
Use Token Meter if you:
- want to know how many tokens and dollars your Claude Code or Codex sessions are costing — broken down by project, model, and MCP tool
- are on a flat-fee plan (Claude Max, etc.) and want to see what the equivalent API cost would be
- want to find which MCP server or tool is eating the most tokens, or which hour of the day is most expensive
- want to resume a recent session and need the claude --resume / codex resume command handy
- want all of the above offline, with no account and nothing uploaded
Not a fit if you need billing-grade numbers validated against your Anthropic or OpenAI invoice — Token Meter computes estimates from local JSONL files only.
MCP tools
When Token Meter is wired as an MCP server (install-mcp all), four tools become available to your AI assistant:
| Tool | What it returns |
|---|---|
| usage_summary | Daily table of token counts, USD-equivalent cost, and call counts — broken down by day and model |
| recent_sessions | Latest sessions with paste-ready claude --resume / codex resume commands |
| session_tools | Per-tool breakdown inside a session: call count, total tokens, average latency, response size |
| refresh_data | Re-scans your local JSONL logs for new activity, then returns a fresh summary |
All four are read-only. No data leaves your machine.
Example prompts
Copy-paste any of these into Claude Code or Cursor after installing the MCP server:
Quick start
> The package is published under an npm scope (@whdrnr2583/) because the
> bare token-meter name collides with an existing similar name on npm. The
> CLI binary is still called token-meter after install.
Connect Token Meter to your AI tool (MCP)
One command registers Token Meter with every supported client on your machine:
Handles Claude Code, Cursor, and Claude Desktop — idempotent, backs up existing
config, preserves other MCP servers. Single-client variants:
install-mcp claude-code | cursor | claude-desktop. Add --dry-run to preview.
> **Or have your LLM do it.** Open Claude Code / Cursor / Claude Desktop and ask:
> *"Read https://raw.githubusercontent.com/whdrnr2583-cmd/token-meter/main/docs/mcp-server.md
> and set up token-meter as my MCP server."*
Manual one-liners (if you'd rather not run our installer):
| Client | Command / config |
|---|---|
| **Claude Code** | claude mcp add token-meter -- npx -y @whdrnr2583/token-meter mcp then claude mcp list to verify |
| **Cursor** | Edit ~/.cursor/mcp.json (Windows: %USERPROFILE%\.cursor\mcp.json) — see docs/mcp-server.md |