token-meter
The token-meter server lets you monitor and analyze your local Claude Code and Codex token usage and estimated costs directly from your AI tool — all data stays on your machine.
usage_summary– Get a spending and token count summary for a chosen period (today,week, ormonth), broken down by model, project, and hour.recent_sessions– List recent Claude Code/Codex sessions within a configurable time window (up to 720 hours), useful for finding and resuming accidentally closed sessions.session_tools– Drill into a specific session to see which MCP servers and built-in tools were used, including call counts, response sizes, and average latency — helpful for diagnosing expensive or slow sessions.refresh_data– Re-scan~/.claude/projectsand~/.codex/sessionsto ingest the latest activity so all other tools return up-to-the-minute numbers.
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: sessionmem
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| within_hours | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint and destructiveHint, making the safety profile clear. The description adds value by specifying the output includes resume commands, but does not elaborate on other behavioral aspects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence with no extraneous content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given two optional parameters and no output schema, the description omits parameter details, making it incomplete for effective use without external context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description must explain parameters but fails to mention 'within_hours' or 'limit' at all, leaving their semantics unclear.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool lists recently-active sessions with a specific output format (resume commands), distinguishing it from sibling tools like session_tools and usage_summary.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives such as session_tools or usage_summary.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate idempotentHint=true and destructiveHint=false. Description adds that it re-scans for new activity, which is consistent but does not disclose additional behavioral traits beyond what annotations provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences, each adding value: first states the action, second provides usage context. No wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple parameterless tool with annotations and no output schema, the description sufficiently covers purpose and usage, leaving no gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
No parameters exist, and schema coverage is 100%. Description does not need to add parameter info; baseline for 0 params is 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 're-scan' and the resource 'local Claude Code / Codex JSONL', and implies its role as a preparatory refresh action, which distinguishes it from sibling tools like recent_sessions or usage_summary.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says 'Run before other tools for up-to-the-minute numbers', providing clear usage context. Lacks explicit when-not or alternatives, but the guidance is strong.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| session_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate the tool is read-only, non-destructive, and idempotent. The description adds useful behavioral context by specifying the metrics returned (call counts, response sizes, average latency), going beyond what annotations provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that conveys the core purpose and output, with no extraneous information. It is front-loaded and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the purpose and output metrics but lacks parameter explanations and output format details. Given no output schema, an agent may need more context on the exact data structure. Adequate but with gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. However, the description does not explain the 'session_id' or 'limit' parameters. It adds no meaning beyond what the schema provides (parameter names and types).
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it provides a per-session breakdown of call counts, response sizes, and average latency, with a stated purpose of debugging slow/expensive sessions. This differentiates it from siblings like 'recent_sessions' and 'usage_summary'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says to use it to 'debug a slow/expensive session,' providing clear context for use. While it doesn't explicitly mention when not to use or alternatives, the context is sufficient for an agent to decide.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| scope | No | which source to include — "auto" filters by current process.platform; "all" disables the filter | auto |
| period | No | week |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true, so the tool is safe and idempotent. The description adds behavioral context by explaining the split and pairing with latency, and notes the need for prior data refresh. No contradictions with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is three sentences and front-loads the primary function. It is clear and to the point, though the second sentence could be slightly more concise. Still, it earns its place without unnecessary verbosity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has three optional parameters and no output schema, the description adequately conveys what the tool returns (split spend, list of priciest sub-agents, latency pairing) and the prerequisite action. It is complete enough for an agent to invoke correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is only 33% (scope has a description). The tool description does not elaborate on the three parameters (limit, scope, period), leaving the agent to rely solely on schema defaults and enum options. This is insufficient given low coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool splits spend into main-session vs sub-agent work, lists priciest sub-agents, and pairs with latency. It answers a specific question ('are my sub-agents worth what they cost') and distinguishes itself from sibling tools like usage_summary or recent_sessions by focusing on sub-agent cost analysis.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description advises running `refresh_data` or `ingest --force` to ensure older rows are tagged, providing a clear prerequisite. It also frames the tool's purpose as answering a specific cost-value question. However, it does not explicitly mention when to avoid this tool or suggest alternatives among siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | which source to include — "auto" filters by current process.platform (recommended); "all" disables the filter | auto |
| period | No | today | |
| insights | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, and the description adds that the data is an 'API-equivalent estimate, local data only' and provides a table with advisory narrative. This adds useful behavioral context without contradicting annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single dense paragraph that could be broken into cleaner sections. While not overly long, it uses parentheticals and dashes that reduce readability. Concise but could be better structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, the description adequately outlines the output as a 'table by day × models' plus narrative. It covers key parameters and their defaults. Missing explicit details about the exact shape or granularity of the output, but sufficient for an agent to understand what to expect.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is low (33%), but the description explains `scope` filtering and `insights` toggle. The `period` parameter is self-explanatory via enum values. The description offsets the schema gaps by clarifying the non-obvious behaviors of scope and insights.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool provides a summary of token usage ('What you spent, where it went, and what was slow') for Claude Code and Codex. It implicitly differentiates from siblings by focusing on aggregated data, but explicit comparison to `recent_sessions` or `refresh_data` is missing.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains the scope parameter's default behavior and the effect of 'all' vs 'auto', and mentions insights toggle, but does not advise when to prefer this tool over siblings or when not to use it. Contextual usage guidance is present but not comprehensive.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v0.1.21- Added
subagent_costs
4 tool updates
v0.1.17- Added
recent_sessions - Added
refresh_data - Added
session_tools - Added
usage_summary
4 tool updates
v0.1.16- Removed
recent_sessions - Removed
refresh_data - Removed
session_tools - Removed
usage_summary
2 tool updates
v0.1.15- Changed
recent_sessions1 field changed- changed
Input schema / properties / limit / defaultPrevious value: -15New value: +5
- Changed
usage_summary1 field changed- added
Input schema / properties / insightsAdded value: +{ + "default": false, + "type": "boolean" +}
1 tool update
v0.1.12- Changed
session_tools1 field changed- added
Input schema / properties / limitAdded value: +{ + "default": 20, + "maximum": 100, + "minimum": 1, + "type": "integer" +}
4 tool updates
v0.1.0- First observed
recent_sessions - First observed
refresh_data - First observed
session_tools - First observed
usage_summary
TDQS
Each tool has a clearly distinct purpose: listing sessions, refreshing data, per-session analysis, and usage summary. No overlap or ambiguity.
All tool names use consistent snake_case with a verb_noun or adjective_noun pattern (e.g., recent_sessions, refresh_data). No deviations.
4 tools is ideal for a focused monitoring server. Each tool serves a necessary function without redundancy or bloat.
The tool surface covers all core operations: listing sessions, refreshing data, per-session breakdowns, and overall usage summary. No obvious gaps.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Exact Claude API cost calc with real cache economics, plus a tiktoken-misuse scanner.
Read-only analytics for Convex apps, queryable via MCP from Claude, Cursor, and other clients.
Agent Cost Allocator MCP — multi-tenant LLM cost attribution for chargeback billing. Companion to
Related MCP Servers
- AlicenseBqualityFmaintenanceTrack LLM token costs across Claude, GPT and Gemini. MCP server + CLI with optimization hints and $ savings estimates.8151MIT
- AlicenseAqualityAmaintenanceLocal-first MCP server that watches your coding sessions and injects a compact summary at the start of each new session. 85.6% token reduction, SQLite storage, no cloud. Works with Claude Code, Cursor, Cline, and Windsurf.13288MIT
- AlicenseNot gradedqualityCmaintenanceReal-time analytics dashboard for Claude Code, tracking sessions, tool usage, file changes, and token costs via an MCP server.31MIT
- AlicenseAqualityAmaintenanceA 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.73MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/whdrnr2583-cmd/token-meter'
If you have feedback or need assistance with the MCP directory API, please join our Discord server