Local-first AI CLI usage analytics for agents.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
Local-first AI CLI usage analytics for developers and coding agents.
TokenTrace answers one practical question before the next expensive AI CLI run: is your local usage evidence ready to trust? It scans local Claude Code, Codex, structured usage logs, and usage-shaped local databases, then labels token and cost data as exact, estimated, unknown, cached, or non-cache. The dashboard opens on Today, with direct paths into Sessions, Evidence, and Fix Data.
TokenTrace is designed for local development machines first, with macOS-oriented defaults. It does not require a cloud account and does not send telemetry or logs anywhere.

tokentrace preflight --json or MCP get_preflight.Run without installing:
Or install globally:
The command starts the local dashboard, chooses an available localhost port starting at 3030, opens your default browser, and keeps the server running until you press Ctrl+C.
CLI commands:
Agents should start with the read-only discovery manifest:
The alias below returns the same manifest:
The manifest describes TokenTrace's local-first privacy model, safe JSON commands,
common workflows, Claude Code status-line setup, Codex sidecar fallback, and
guardrails such as never running tokentrace reset without explicit human
approval. The discovery command does not scan files, initialize the database, or
start the dashboard.
Package-level agent references are included for agents that inspect repository or npm package contents before invoking commands:
MCP-capable clients can start the local stdio server after installing or using the npm package:
Registry name: io.github.abhiyoheswaran1/tokentrace.
First MCP call for agents: get_agent_guide.
Self-test the local MCP entrypoint without scanning files:
The MCP server exposes the same local-first surfaces as tools: capabilities,
preflight, status, Scan Health, evidence, repair queue, reports, and an
explicit scan tool. It does not scan files on startup, and its scan tool requires
confirmLocalScan=true before reading local usage files or writing the local
database.
Before starting another long coding-agent run, use preflight:
In MCP clients, call get_preflight for the same proceed, caution, or blocked
decision with local scan freshness, confidence, guardrail, anomaly, and repair
findings. Preflight does not scan files or inspect raw prompts.
When the local dashboard is already running, agents can fetch the same manifest over localhost:
The Local Sources & Trust release handoff is also machine-readable:
Open http://localhost:3000.
Useful source commands:
TokenTrace now organizes the product around the daily loop:
Trust surfaces include:
TokenTrace labels the trust level behind imported numbers:
The dashboard surfaces a Data Confidence score on Today, Projects, Sessions, and Session Timeline pages. Scan Health also includes a supply-chain IOC check so package trust is visible in the product, not only in release scripts.
Public releases require maintainer approval. See docs/RELEASE_CHECKLIST.md before bumping versions, tagging, creating GitHub releases, or publishing npm.
In local development, the SQLite database defaults to .tokentrace/tokentrace.db. Override it with:
When installed from npm, TokenTrace stores runtime data outside the package folder:
~/Library/Application Support/TokenTrace/~/.local/share/tokentrace/%APPDATA%/TokenTrace/The CLI sets TOKENTRACE_DB and DATABASE_URL automatically. You can override the base directory with:
Default discovery checks these locations when present:
~/.claude/~/.config/claude/~/.codex/~/.config/codex/~/.openai/.claude, .codex, .openai, and .ai in the directory where tokentrace was invokedUse Settings to add custom folders, toggle raw message storage, and trigger scans. Use Scan Health, Discovery, Parsers, and Raw Data to inspect discovered files, parser decisions, warnings, failures, extracted metadata, and confidence levels.
Settings also supports optional local monthly usage guardrails. Set a cost limit, token limit, or both, and Today will show month-to-date progress from imported local CLI usage.
Sessions includes built-in and local saved views for recurring review paths: unknown cost, high-cost sessions, Claude/Codex this month, estimated tokens, guardrail review, and parser review. Open a session's Timeline link to see ordered interactions, model changes, token spikes, cache activity, tool calls, parser confidence, and unknown-cost events. Raw prompts and message bodies stay hidden by default.
TokenTrace's primary ingestion architecture is direct local filesystem ingestion:
TokenTrace does not use MITM proxies, packet sniffing, browser extensions, traffic interception, or cloud telemetry.
Each adapter detects compatibility, parses partial metadata where possible, and fails safely when a file format is unsupported. Imported interactions carry token confidence metadata:
exacthigh-confidence estimatelow-confidence estimateunknownExact and estimated token values are never mixed silently.
Filesystem ingestion is the primary product path. Wrapper mode is secondary and optional:
Wrapper mode launches the subprocess, measures duration, counts stdout/stderr bytes, detects structured JSON output when available, and writes a local JSONL diagnostic log under the app-data directory. It does not intercept network traffic.
Claude Code can run a local status-line command at the bottom of its terminal UI. TokenTrace supports that path directly:
Add the printed statusLine block to ~/.claude/settings.json. It points Claude Code at:
Claude Code sends session JSON to the command on stdin. TokenTrace reads the transcript path, model, context usage, and session cost, then prints one compact local line:
Do not set the Claude Code statusLine.command to plain tokentrace. Plain tokentrace starts the dashboard, while tokentrace statusline claude prints exactly one status-line response.
You can also inspect the same local status outside Claude Code:
Daily reporting commands stay deterministic and local:
Codex CLI status-line integration is intentionally deferred until its status-line and hook contracts are stable enough to support without fragile terminal output parsing. Use tokentrace watch --session --compact in a terminal split or tmux pane as the current fallback. See docs/CODEX_INTEGRATION_SPIKE.md for the current decision.
Dashboard views:




CLI startup and help:

Local scan output:

Optional wrapper diagnostics:

TOKENTRACE_DISABLE_PRICE_REFRESH=1 to use only bundled prices.Stop the server with Ctrl+C in the terminal where tokentrace is running.
preinstall, install, or postinstall scripts..next/server route bundles.tokentrace serve prepares the local dashboard build in the user's TokenTrace app-data directory the first time it is needed.npm run package:inspect fails if generated Next.js build output appears in the published tarball.npm run security:ioc scans lockfiles, workflows, and local Claude/VS Code hook files for high-signal supply-chain compromise indicators.npm audit --audit-level=moderate.npm run release:check fails when a gate command exits non-zero. The import graph is expected to remain free of circular dependencies; tests/import-boundaries.test.ts protects shared type/helper modules from importing higher-level orchestration barrels.See SECURITY.md for the full security and privacy model.
Model prices change. TokenTrace ships with bundled public list prices and can refresh them from a public TokenTrace model-rate manifest. Manual edits made in Model Rates are preserved by future refreshes.
The bundled catalog includes common OpenAI, Anthropic, Google Gemini, xAI, DeepSeek, Mistral, and Cohere models, checked on May 8, 2026.
Seed sources:
Review and update rates in Model Rates before treating cost estimates as financial truth, especially if you use batch processing, priority/flex modes, data residency, long-context surcharges, subscriptions, or provider-specific discounts.
Refresh from the dashboard or from the CLI:
Cost is calculated per interaction:
Cache read and cache write prices fall back to input price when a model has no separate cache rate. Anthropic seed rows use the 5-minute prompt cache write price by default. Rows are marked exact, estimated, or unknown depending on token availability and pricing configuration.
Adapters live under src/ingestion/adapters/:
claude-code.tscodex-cli.tsstructured-usage-log.tscursor-chat.tssqlite-history.tsgeneric-jsonl.tsgeneric-json.tsgeneric-log.tsFormats for Claude Code and Codex CLI can vary across versions, so these adapters are defensive and best-effort. Unknown files fail safely and show warnings in the Raw Data page.
TokenTrace keeps a visible support contract so daily scans are easier to trust:
| Surface | Support level | Notes |
|---|---|---|
| Claude Code project transcripts | Stable | Primary local CLI ingestion source. |
| Codex CLI session artifacts | Best-effort | Parsed defensively while CLI formats evolve. |
| Structured usage JSONL/NDJSON | Stable | Local wrapper and team logs with session, model, token, and source-cost fields. |
| Cursor-style chat exports | Best-effort | Imports local editor chat/composer exports without storing raw prompt text by default. |
| Usage-shaped SQLite histories | Best-effort | Reads local databases that expose session, model, token, or cost-like columns. |
| Generic JSONL, JSON, and text logs | Best-effort | Conservative usage-shaped records only. |
| Claude/Codex cache, plugin, todo, config, and support files | Ignored | Tracked as non-usage files, not parser failures. |
| Editable model pricing | Stable | Local pricing rows drive costs and unknown-cost repair queues. |
| Claude Code status line | Stable | Uses Claude Code's documented statusLine stdin contract. |
| Codex sticky status line | Best-effort fallback | Use tokentrace watch --session --compact in a split or tmux pane. |
| Desktop app scraping, browser extensions, proxying, packet capture, telemetry | Unsupported | Outside TokenTrace's product boundary. |
Example generic JSONL fixtures are in fixtures/generic-jsonl/.
The ingestion system is intentionally pluggable:
IngestionAdapter.src/ingestion/adapters/index.ts.tests/.Contributions are welcome. See CONTRIBUTING.md for local setup, parser guidelines, pricing update notes, and the release policy.
prebuild-install deprecation warning during installThis is a transitive dependency of better-sqlite3 (the native SQLite driver TokenTrace uses to store local data). The warning is harmless β the install completes normally and TokenTrace runs as expected. It will go away once better-sqlite3 upstream migrates to a different prebuilt binary loader; there is nothing to fix on the TokenTrace side.
better-sqlite3If the prebuilt binary cannot be downloaded (offline machine, restrictive proxy, unsupported Node ABI), better-sqlite3 will try to compile from source and may fail. Workarounds:
>= 20.0.0; Node 20 or 22 LTS is recommended).build-essential and python3 on Linux, or the "Desktop development with C++" workload on Windows.github.com so the prebuilt binary can be fetched.EBADENGINE warningsThese appear when your local Node version is older than the engines field of a transitive dependency. They are warnings, not errors. Upgrading to the latest Node LTS resolves them.
Open source by Abhi Yoheswaran. Released under the MIT License. See LICENSE.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/tokentrace)<a href="https://allmcps.com/mcp/tokentrace"><img src="https://allmcps.com/api/badge/tokentrace?style=directory" alt="TokenTrace on AllMCPs" /></a>