token-meter
This MCP server gives an AI assistant read-only, local access to your Claude Code and Codex token-usage data — costs, sessions, tools, and sub-agents — plus a refresh tool to rescan your logs.
usage_summary— Get a day-by-model table of token counts, API-equivalent USD cost, and call counts with an advisory narrative; filter by scope (auto/all/platform/source) and period (today/week/month), and optionally add heuristic insights.recent_sessions— List recently active Claude Code / Codex sessions with paste-readyclaude --resume/codex resumecommands; control withlimit(1–50) andwithin_hours(1–720).session_tools— Break down a single session (by requiredsession_id) into per-MCP / built-in tool call counts, response sizes, and average latency to debug slow or expensive sessions.subagent_costs— Split spend between main-session and sub-agent (Task/Agent) work, rank the priciest sub-agents by model mix, tokens, and cache, and pair them with parent-side invocation latency.refresh_data— Re-scan local Claude Code / Codex JSONL logs for new activity so subsequent queries return up-to-the-minute numbers.All tools are local-first:
readOnlyHintis true for every tool exceptrefresh_data, nothing is uploaded, and no outbound network access is used.
Monitors token usage and estimates costs for Codex (OpenAI's code generation model) sessions by parsing local JSONL logs, providing breakdowns by model and project.
Token Meter
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
npx -y @whdrnr2583/token-meter auditScans 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.
Related MCP server: hivecode
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 resumecommand handywant 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 |
| Daily table of token counts, USD-equivalent cost, and call counts — broken down by day and model |
| Latest sessions with paste-ready |
| Per-tool breakdown inside a session: call count, total tokens, average latency, response size |
| 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:
Show me my token usage and cost for the last 7 days.List my recent sessions so I can pick one to resume.Show the tool breakdown for my most recent session — which tool used the most tokens?Refresh token-meter data, then tell me which model cost the most this week.Which hour of the day am I spending the most tokens on?Quick start
npx @whdrnr2583/token-meter ingest # scan ~/.claude/projects + ~/.codex/sessions
npx @whdrnr2583/token-meter stats 30 # CLI summary for last 30 days
npx @whdrnr2583/token-meter serve # http://localhost:8765 dashboard
npx @whdrnr2583/token-meter mcp # run as an MCP server for Claude Code / CursorThe package is published under an npm scope (
@whdrnr2583/) because the baretoken-metername collides with an existing similar name on npm. The CLI binary is still calledtoken-meterafter install.
Connect Token Meter to your AI tool (MCP)
One command registers Token Meter with every supported client on your machine:
npx -y @whdrnr2583/token-meter install-mcp allHandles 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 |
|
Cursor | Edit |
Claude Desktop | Edit |
ChatGPT | Stdio-only for now; HTTP wrapper recipe in docs/mcp-server.md |
Other (Continue, Zed, custom) |
|
Then ask: "Use token-meter to show my recent sessions" or "Use token-meter usage_summary for this week".
Claude Code shortcut: run
npx -y @whdrnr2583/token-meter install-command claude-codeonce to register the/token-meterslash command. After reopening your session, type/token-meterfor a one-shot summary without natural language.
Full setup + verification + troubleshooting: docs/mcp-server.md.
Storage: ~/.tokenpulse/usage.db (SQLite). Remove the folder to start over.
The folder name will become ~/.tokenmeter/ in a future release with an
automatic migration; until then the v0.1 directory keeps its original name.
What you see
USD-equivalent cost per day, model, project. Useful if you're on a Max plan and want to know what the API would have cost.
MCP and tool breakdown: which MCP server is eating tokens, how slow each tool is on average, response sizes per call.
Hourly distribution of output tokens.
Claude Code + Codex side-by-side, in one view.
A note on the dollar figures
Costs are estimates computed locally from the token counts that Claude Code and Codex already write to their JSONL files, multiplied by the model's published per-million-token rate. They are not validated against your actual Anthropic / OpenAI invoice and may diverge for several reasons:
Vendors change pricing; the table in
src/pricing.tsis a snapshotSubscription plans (Pro / Max) bill a flat fee — the on-screen $ is what the API would have cost, not what you pay
Some token categories (server-side tool use, cache write variants) are approximated
Treat the numbers as relative signal for spotting waste, not as billing-grade accounting. Token Meter ships a regression test that the calculation is reproducible, and an audit script that checks invariants; neither verifies the rates against vendor invoices.
Why local-first
Your JSONL contains source code, prompts, and tool results. Token Meter never uploads any of it. Heuristics, regex, and SQL aggregation only.
No SDK to integrate, no proxy to configure for the free tier.
The CLI and dashboard core are MIT licensed.
Pricing
Tier | Price | What you get |
Free | $0 | Claude Code + Codex parsing, MCP/tool breakdown, hourly/model/project breakdown, 7-day history, 1 desktop alert |
Pro | $5/mo | Everything in Free, reframed as a monthly spend review: 30-day history (this month vs last), per-session/per-message drill-down to the run that blew the budget, cache-efficiency dollars saved, waste signals (oversized tool responses + cache that didn't pay off), plus unlimited smart alerts (desktop + webhook) |
Pro+ | later | Local LLM proxy (Ollama / LM Studio / llama.cpp / vLLM), GPU/VRAM tracking, auto actions |
Pro is the difference between glancing at last week's number and reviewing where the month's spend leaked. Pro is live — Subscribe at token-meter.dev.
Pro+ ships once Pro sign-ups + community demand confirm the segment.
Roadmap
M1 ✅ Claude Code parsing, MCP/tool breakdown, hourly stats
M2 ✅ Codex integration
M3 ✅ Pro tier ($5), Polar.sh billing, license activation
M4+ Pro+ (local LLM proxy, GPU tracking), conditional on demand
Privacy & security
Tokens are counted from the JSONL files Claude Code and Codex already write. Token Meter does not touch network APIs of either vendor.
No prompt or response bodies are stored by default — only metadata (timestamps, token counts, tool names, response lengths).
The database lives under
~/.tokenpulse/; delete it to wipe. (Renamed to~/.tokenmeter/in a future release with an automatic migration.)
Changelog
See CHANGELOG.md for release notes and breaking changes.
License
MIT for the CLI, dashboard, and parsers. Pro-tier features ship in a separate package under a closed source license.
Available Tools
5 toolsrecent_sessionsrecent sessions (Token Meter)BRead-onlyIdempotent
List recently-active Claude Code / Codex sessions with ready-to-paste resume commands.
Inputs: limit, within_hours.
refresh_datarefresh data (Token Meter)AIdempotent
Re-scan local Claude Code / Codex JSONL for new activity. Run before other tools for up-to-the-minute numbers.
Inputs: no named parameters.
session_toolssession tools (Token Meter)ARead-onlyIdempotent
Per-session MCP / built-in tool breakdown: call counts, response sizes, average latency. Debug a slow/expensive session.
Inputs: session_id (required), limit.
subagent_costssub-agent costs (Token Meter)ARead-onlyIdempotent
Split spend into main-session vs sub-agent (Task/Agent) work, list the priciest sub-agents (model mix · tokens · cache), and pair them with parent-side invocation latency. Answers "are my sub-agents worth what they cost". Run refresh_data (or ingest --force once) so older rows get the sub-agent tag.
Inputs: limit, scope, period.
usage_summaryusage summary (Token Meter)ARead-onlyIdempotent
What you spent, where it went, and what was slow — Claude Code + Codex. API-equivalent estimate, local data only. Table by day × models (ccusage-style) + advisory narrative. scope defaults to "auto" (filter to current platform); pass "all" to see everything. insights=true adds heuristic tips.
Inputs: scope, period, insights.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct focus: aggregate usage, session listing, per-session tool stats, subagent cost split, and data refresh. There is mild overlap between usage_summary and subagent_costs since both report spend, but the descriptions clearly delineate the scope.
All names use snake_case and mostly follow a noun-phrase pattern like usage_summary, recent_sessions, and session_tools. refresh_data breaks the pattern as an imperative verb, but the overall naming style is still coherent and predictable.
Five tools is a well-scoped count for a focused usage/cost monitoring server. Each tool addresses a distinct analytical need without unnecessary bloat.
The tool surface covers the core workflow: refresh local data, view aggregate usage, list sessions, inspect per-session tool activity, and analyze subagent costs. Missing advanced capabilities like time-range filtering or raw data export feel like minor gaps rather than fundamental omissions.
Maintenance
Related MCP Connectors
Analytics for MCP servers. Query your tool calls, first-call success, retries and schema cost.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Related MCP Servers
- AlicenseBqualityDmaintenanceTrack LLM token costs across Claude, GPT and Gemini. MCP server + CLI with optimization hints and $ savings estimates.81MIT
- AlicenseNot gradedqualityDmaintenanceReal-time analytics dashboard for Claude Code, tracking sessions, tool usage, file changes, and token costs via an MCP server.1MIT
- AlicenseAqualityBmaintenanceA local-first, multi-provider cost meter for LLM usage, exposed as MCP tools. Captures every call into a local SQLite ledger and lets any coding agent query spend, compare providers, and get recommendations — no cloud, no account. First-class support for Chinese providers (Qwen, DeepSeek) alongside Anthropic and OpenAI.744 PyPI6MIT
- FlicenseAqualityDmaintenanceA local MCP server that tracks token usage and costs for Claude Desktop and Claude Code, providing a live dashboard at localhost:6789.57 npm-