Tokmeter
Tokmeter
Every AI coding agent you run, on one ledger.
Tokmeter reads the session files your agents already write to disk and turns them into token and cost totals by project, model, provider, and day — across Claude Code, Codex, Gemini CLI, Cursor, and twenty more (now including Muse, Cline, Augment, Copilot CLI, and Kimi Code). An agent it has no built-in parser for can register a path and emit a simple usage line to show up too. No API keys, no telemetry, no account. Your data never leaves the machine.
Why
Every agent bills you separately and shows you its own slice. Claude Code knows what Claude Code cost. Codex knows what Codex cost. Nothing knows what today cost, or which project is quietly burning the most, or whether the model you switched to is actually cheaper for the work you do.
Tokmeter answers that from data already on your disk. It parses each agent's local session logs, prices them against a live model catalog, and keeps an append-only daily ledger so history survives even after the agents rotate their own logs away.
npx @sriinnu/tokmeter --todayDocs and the theme gallery: tokmeter.srinivas.dev.
Related MCP server: contextburn
What it looks like
CLI — usage by project, model and provider | Digest — a weekly report card |
macOS menubar — today's tokens and cost, always visible
There is also a terminal UI (tokmeter-tui), a local web dashboard, a statusline for Claude Code, and an MCP server so an agent can query its own spending.
Install
Requires Node.js 18+. Reading session files needs no provider credentials; pricing lookups fetch a public catalog, and --light skips them entirely.
# Try it without installing
npx @sriinnu/tokmeter --today
# Install the CLI, and the daemon/MCP server
npm install -g @sriinnu/tokmeter @sriinnu/tokmeter-mcpPackage | Contents |
Core API, CLI, and terminal UI | |
MCP server, daemon, statusline, and live terminal UI |
packages/core, packages/cli, and packages/tui are private workspace packages bundled into @sriinnu/tokmeter. packages/web is a separate private workspace app run from source.
To keep the daemon always-on (so the menubar and statusline survive reboots), install the launchd agent once: tokmeter-mcp daemon install-agent (macOS). It auto-starts at login and respawns on crash.
Claude Code and Codex are the primary validation targets. See provider compatibility for the other parsers and their known limits.
CLI
tokmeter --today
tokmeter models --project my-app --json
tokmeter daily --week
tokmeter projects
tokmeter stats --month
tokmeter digest --period week
tokmeter pricing sonnetFilters include --project, --claude, --codex, --week, --month, and --since YYYY-MM-DD --until YYYY-MM-DD. Use --json for machine-readable output and --light for token-only reports.
Aliases: merge display names, tag projects, or hide them from lists.
Backup and restore: portable snapshots, cleanup preview, restore. Cleanup deletes source files; keep the confirmation and backup steps.
CLI reference: every command with examples.
How the numbers work: what each bucket means and where estimates enter.
TypeScript API
The root export provides the core API. Convenience query helpers use the /cli subpath.
import { TokmeterCore } from "@sriinnu/tokmeter";
import { loadTokmeterSummary } from "@sriinnu/tokmeter/cli";
const core = new TokmeterCore();
await core.scan({ providers: ["codex", "claude-code"], today: true });
const models = core.getModelCosts();
const daily = core.getDailyBreakdown();
const summary = await loadTokmeterSummary({ week: true, light: true });Reuse one core scan when querying several breakdowns. See integration guidance, core API usage, and SKILL.md for agent-facing integration instructions.
Daemon, MCP, and statusline
tokmeter-mcp daemon start
tokmeter-mcp daemon status
tokmeter-mcp serve # MCP server over stdio
tokmeter-mcp statusline # one statusline tick
tokmeter-mcp live # live terminal UIThe daemon uses local HTTP port 9877 for queries and WebSocket port 9876 for live registration. The macOS app, statusline, and MCP server consume its shared state. Daemon commands belong to @sriinnu/tokmeter-mcp; install it for these surfaces.
MCP tools use the tokmeter_ prefix and cover usage queries, comparisons, forecasts, export, and confirmed cleanup/restore operations. See the MCP tool reference for all 24 tools grouped by purpose, and the package MCP README for configuration and programmatic exports.
tokmeter-mcp editors lists installer targets. tokmeter-mcp install-mcp and tokmeter-mcp install-statusline write editor configuration; inspect the generated settings for your editor. For Claude Code, register the MCP server with claude mcp add tokmeter --scope user -- npx -y @sriinnu/tokmeter-mcp serve (from 1.15.0, install-mcp runs claude mcp add itself; 1.14.1 and earlier wrote the entry to ~/.claude/settings.json, which Claude Code doesn't read). See architecture for registration, authentication, refresh, storage, and daemon lifecycle details.
Terminal and web interfaces
# After installing @sriinnu/tokmeter
tokmeter-tui
# Without a global install
npx -p @sriinnu/tokmeter tokmeter-tuiThe terminal UI supports overview, model, daily, statistics, and cleanup views. See its keys and commands.
Run the web workspace from a source checkout:
bun install
bun run dev:webOpen http://localhost:3000. See web setup and data sources.
macOS app
Release builds target Apple silicon and macOS 14+. Node.js 18+ with npx is also required for the local daemon.
Install @sriinnu/tokmeter-mcp, run tokmeter-mcp daemon start, then open TokmeterBar from /Applications. Download the app from GitHub Releases.
The popup gives today's tokens and estimated API cost equal prominence, with models and projects below. Chart hover cards show exact daily tokens and cost. Usage details expands lifetime totals, trends, and signals. Themes: Terminal, Paper, Prism, Lagoon, Carbon, Glass, and (since 1.15.0) the instrument themes Meter, Pump, Rams, Deck, and Passbook. A $/M button in the models header shows each model's list price per million tokens (input, output, cache read, cache write) and where that price came from, and the dashboard port is configurable. The Hub provides larger breakdowns and settings. Settings → Open web dashboard starts its local server on demand; Stop web dashboard or quitting the app stops it.
See macOS build and runtime details, first-use checks, and popover validation. The completion tracker records remaining fresh-machine, reliability, update, accounting, accessibility, and trial gates.
The synthetic walkthrough documents how the example images were generated; it is not a capture of a current local candidate.
Documentation
MCP tool reference — all 24
tokmeter_tools, groupedConsuming tokmeter — MCP, daemon HTTP, CLI, and in-process integration
How the numbers work — bucket semantics and where estimates enter
Backup, snapshot & restore — the confirmation/backup model and cross-machine restore
Troubleshooting — daemon, bar updates, "shrinking" history, performance
Architecture — daemon lifecycle, storage, refresh
Privacy
Everything runs on your machine. Tokmeter reads session files your agents
already wrote, needs no provider credentials, sends no telemetry, and
requires no account. The only outbound request is an optional fetch of a
public model-price catalog, which --light skips entirely. Your usage data
never leaves the device.
Support
Tokmeter is free and open source. If it saves you money, consider chipping in to keep it maintained:
License
AGPL-3.0-only. See licensing notes for what that means if you embed Tokmeter in another product.
This server cannot be deployed
Maintenance
Related MCP Connectors
Exact Claude API cost calc with real cache economics, plus a tiktoken-misuse scanner.
Find AI model pricing, estimate token costs and compare offers. No API key required.
Cost per run, tool, model and day for AI agents, from one call or an OpenTelemetry export.
Compare up-to-date pricing for 40+ LLMs (incl. Chinese) & estimate cost from tokens. EN/zh.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAnalyzes Claude Code session token usage and cost locally — where spend actually lands across cache-read, cache-write and output, and what is consuming the context window. Read-only and offline: it parses your own session files and exposes analyze_claude_cost, get_cost_benchmark and tokenscope_share_summary.39 npm4MIT
- AlicenseBqualityBmaintenanceLets a coding agent inspect its own run efficiency mid-session from local Claude Code transcripts, exposing the share of paid tokens that became model output versus context re-reading. Ships two stdio tools — one returning the shares as structured data and one returning the full cost-weighted report — with no network calls.238 PyPIMIT
- AlicenseAqualityAmaintenancePrices your Claude Code and Codex sessions from the transcripts on disk, shows what each agent cost over any period, and tells you in plain English what would have been cheaper. CLI, Browser UI and MCP server.85MIT
- AlicenseNot gradedqualityAmaintenanceReads the Claude Code, Codex and OpenCode usage logs already on your machine and reports token totals, per-day and per-hour activity, a per-agent and per-model breakdown, and a year-in-review recap. It makes no network request at all — a test fails if any source file in the package can open a socket.414MIT