Local-first, read-only AI coding agent token and usage inspector.
Project description
TokenCat
TokenCat is a local-first CLI that shows how your AI coding agents use tokens across one machine, and optionally across trusted machines on your LAN.
Run tokencat to get a terminal dashboard for Codex, Claude Code, Gemini CLI, GitHub Copilot Chat/Agent, and GitHub Copilot CLI. TokenCat reads the telemetry files those tools already keep locally; it does not proxy requests, rewrite endpoints, read credentials, or print prompt and response bodies.
Why TokenCat
- One dashboard for several coding agents: Codex, Claude Code, Gemini CLI, VS Code Copilot Chat/Agent, and Copilot CLI.
- Zero-provider setup for normal use: install it and run
tokencat. - Privacy-first scanning: local files only, anonymous session IDs by default, no OAuth/session token reporting.
- Cost estimates with clear coverage: bundled pricing works offline, and unknown models stay visible instead of being guessed.
- Useful terminal views: dashboard, sessions, models, daily usage, doctor, pricing, and JSON output for scripts.
- Multi-machine rollups: trusted TokenCat nodes can be aggregated with
--lan, including SSH snapshot hosts from~/.ssh/config.
Install
TokenCat requires Python 3.9 or newer.
pipx install tokencat
Upgrade later with:
pipx upgrade tokencat
To try a checkout of this repository:
pipx install .
Quick Start
Open the default 7-day dashboard:
tokencat
Look farther back:
tokencat --since 30d
tokencat --since 2026-01-01
Check what TokenCat can see on this machine:
tokencat doctor
LAN and SSH Nodes
TokenCat can roll up trusted machines without sending prompts or responses. Each node exposes or returns a read-only snapshot.
SSH-configured machines and containers do not need a long-running HTTP server. If a host appears in ~/.ssh/config and has tokencat available remotely, tokencat nodes --trust can add it as an SSH snapshot node. Later, tokencat --lan runs ssh <host> tokencat snapshot --json and aggregates the returned snapshot.
Aggregate trusted nodes:
tokencat dashboard --lan
tokencat summary --lan
tokencat sessions --lan
Remove trusted nodes:
tokencat nodes --remove
You can also start an HTTP node on another machine:
export TOKENCAT_NODE_TOKEN="choose-a-shared-secret"
tokencat serve --lan
tokencat serve starts in the background by default:
tokencat serve --status
tokencat serve --logs
tokencat serve --stop
For foreground debugging:
tokencat serve --lan --foreground
Discover and trust nodes:
tokencat nodes --trust
If mDNS is blocked by Docker Desktop, VPNs, or network policy, trust a node by URL:
tokencat nodes --url http://127.0.0.1:8765 --trust
Advanced Usage
Focus on one provider:
tokencat dashboard --provider codex
tokencat sessions --provider claude --limit 20
tokencat models --provider gemini
tokencat daily --provider copilot
Change the terminal theme:
tokencat --theme light
tokencat dashboard --theme dark
Use structured output:
tokencat summary --json
tokencat sessions --json --show-title --show-path
JSON Output
Commands with --json emit stable envelopes with:
generated_atfiltersproviderssummaryoritemswarnings
This makes TokenCat easy to pipe into local scripts, dashboards, or personal automation.
Configuration
Most users do not need a config file. TokenCat discovers local agent data from the standard locations for each tool.
| Provider | What TokenCat Reads | Optional Configuration |
|---|---|---|
| Codex | ~/.codex/sessions/**/*.jsonl, ~/.codex/archived_sessions/*.jsonl, and ~/.codex/state_*.sqlite as a fallback. |
None. |
| Claude Code | projects/**/*.jsonl under the Claude config root. |
Set CLAUDE_CONFIG_DIR to one or more comma-separated roots. Without it, TokenCat checks $XDG_CONFIG_HOME/claude, ~/.config/claude, and legacy ~/.claude. |
| Gemini CLI | ~/.gemini/tmp/**/chats/session-*.json plus non-sensitive settings metadata from ~/.gemini/settings.json. |
None. |
| GitHub Copilot | VS Code `workspaceStorage//chatSessions/.json | .jsonland Copilot CLI shutdown summaries under~/.copilot/session-state//events.jsonl`. |
Common environment variables:
| Variable | Used For |
|---|---|
CLAUDE_CONFIG_DIR |
Overrides Claude Code data roots. Multiple roots can be separated with commas. |
COLORFGBG |
Helps --theme auto detect light terminals. TokenCat falls back to the dark palette when it cannot tell. |
TOKENCAT_NODE_NAME |
Sets the display name for this machine when using TokenCat nodes. Defaults to the hostname. |
TOKENCAT_NODE_TOKEN |
Default bearer-token environment variable for HTTP LAN nodes. |
Local TokenCat state is kept under ~/.tokencat/:
~/.tokencat/pricing/stores the refreshed pricing cache.~/.tokencat/node.jsonstores this machine's node identity.~/.tokencat/nodes/trust.jsonstores trusted LAN or SSH nodes.~/.tokencat/logs/node.logand~/.tokencat/node.pidare used by the detached node server.
Commands
| Command | Purpose |
|---|---|
tokencat / tokencat dashboard |
Terminal dashboard with provider health, token totals, pricing coverage, timeline, top models, and recent sessions. |
tokencat summary |
Compact totals by provider, model count, tokens, and estimated API cost. |
tokencat sessions |
Session list with anonymous IDs by default. Use --show-title and --show-path when you want local metadata. |
tokencat models |
Model-level aggregation across providers. |
tokencat daily |
Daily usage totals for the selected window. |
tokencat doctor |
Detection and health report for local providers and pricing data. |
tokencat pricing show |
Inspect catalog freshness, coverage, and unknown models. |
tokencat pricing refresh |
Refresh the user pricing cache under ~/.tokencat/pricing/. |
tokencat serve |
Start a read-only local snapshot node. |
tokencat nodes |
Discover, trust, inspect, or remove LAN and SSH nodes. |
tokencat snapshot --json |
Emit a machine-readable snapshot for remote aggregation. |
Useful flags:
--provider codex|claude|gemini|copilot
--since 7d
--until 2026-05-31
--daily | --weekly | --monthly # dashboard usage buckets
--theme auto|dark|light
--json
--no-price
--lan
Session listings also support:
--limit 50
--model gpt-5-codex
--show-title
--show-path
Pricing
TokenCat estimates API-equivalent cost when a model can be matched to known pricing data.
- Pricing works offline with the bundled catalog shipped in the package.
- On first pricing use, TokenCat silently tries to refresh a local cache under
~/.tokencat/pricing/. - If the refresh fails, it quietly falls back to the bundled catalog.
tokencat pricing refreshrefreshes the local cache manually.- Resolution is source-aware: direct source pricing first, then official API pricing for the model family, then OpenRouter as the marketplace fallback.
- JSON output includes
pricing_sourceandpricing_modelwhen a row is priced. - Unknown, renamed, redirected, or unattributed models remain visible with explicit pricing status.
Current pricing references:
- OpenAI API pricing
- OpenAI Codex pricing
- Gemini API pricing
- Anthropic models and pricing
- xAI models
- OpenRouter pricing
- GitHub Copilot plans
Privacy
TokenCat is intentionally conservative.
- Reads local telemetry files only.
- Does not proxy, intercept, or replay model requests.
- Does not rewrite provider endpoints.
- Does not read OAuth/session credentials for reporting.
- Does not print raw prompt or response bodies.
- Uses anonymous session IDs by default.
- Shows titles and paths only when you pass
--show-titleor--show-path.
Limits
- TokenCat supports macOS and Linux, including typical Docker/containerized Linux environments where the relevant agent state is mounted or available locally.
- Windows is not yet supported.
- LAN discovery uses mDNS, which can be unreliable through Docker Desktop, VPNs, or restrictive networks. Use
tokencat nodes --url ... --trustor SSH nodes in those environments. - Copilot CLI usage is counted from shutdown summaries; active CLI sessions without shutdown summaries are detected but not counted yet.
- Cost is an estimate, not your actual bill.
License
TokenCat is licensed under GNU GPLv3. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tokencat-0.6.5.tar.gz.
File metadata
- Download URL: tokencat-0.6.5.tar.gz
- Upload date:
- Size: 137.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a17b683b89f06ae44b5b70663491668105d70b7ef9200e510c05ad122ce4fa1
|
|
| MD5 |
5137d0eea08f69e741478b30b1591659
|
|
| BLAKE2b-256 |
c353de881c6076cb15a8bd48481bd81fdb6e585c7101ed33f1487e7546444e38
|
File details
Details for the file tokencat-0.6.5-py3-none-any.whl.
File metadata
- Download URL: tokencat-0.6.5-py3-none-any.whl
- Upload date:
- Size: 127.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bc1880c639e068a7dcddf471a48ce1b8b61f64d8980f86b6476608758d8ce3f
|
|
| MD5 |
e0fda4cfdd7faca0398cf194e234accc
|
|
| BLAKE2b-256 |
84ba61abacc5f5f5ad24bf1c1449a81eab647da132521311622a1c2bc733b1c8
|