See what your AI-coding session actually cost — and what is eating your context. Local, read-only CLI for Claude Code.
- ✓Open-source license (MIT)
- ✓Actively maintained (<30d)
- ✓Clear description
- ✓Topics declared
claude mcp add tokenscope -- npx -y @wartzar-bee/tokenscope{
"mcpServers": {
"tokenscope": {
"command": "npx",
"args": ["-y", "@wartzar-bee/tokenscope"]
}
}
}Resumen de MCP Servers
# tokenscope ⏣
**See what your AI-coding session actually cost — and what's eating your context.**
A local, read-only CLI that parses your Claude Code session logs and shows where the money goes: model output vs. context being **re-sent every turn** (the hidden 60%+ of most bills).
```
$ npx @wartzar-bee/tokenscope
tokenscope ⏣ latest session
──────────────────────────────────────────────────────
Total cost $868.84 over 967 model turns
Where the money went
output (model writing) ████░░░░░░░░░░░░░░░░░░░░ 16% $137.24
cache read (re-sent ctx) ████████████████░░░░░░░░ 66% $577.59
cache write (new ctx) ████░░░░░░░░░░░░░░░░░░░░ 18% $153.67
Context size per turn (peak 822k · avg 404k · now 822k tokens)
▁▁▁▁▁▂▂▂▂▂▂▂▃▃▃▃▃▃▃▄▄▄▄▄▅▅▅▅▅▆▆▆▆▇▇▇▇▇▇█
Insights
• Re-sent (cached) context cost $577.59 (66% of spend) — context re-read every turn.
• Peak context ~822k tokens — /compact or a fresh session would cut per-turn cost.
• Only 16% of spend is the model's actual output.
```
*(A real session, default Opus pricing. Your numbers will differ — prices are overridable.)*
## Why
Agentic coding (Claude Code, etc.) produces surprise bills, and the cause is mundane: as a session grows, the **whole context is re-sent every turn**, so cost balloons even when the model writes little. Existing dashboards show *totals*; tokenscope shows the **attribution** — output vs. cache-read vs. cache-write vs. fresh input, the per-turn context-growth curve, cost by model, subagent spend, and which tools fill your context — with concrete "trim this" insights.
## Try it in 10 seconds (no Claude Code logs needed)
```
npx @wartzar-bee/tokenscope --demo
```
Runs on a bundled sample session so you see the full report before pointing it at your own logs — no setup, nothing to configure. (The sample is synthetic, for demonstration.)
## Install / run
No install — runs via npx:
```
npx @wartzar-bee/tokenscope # your most recent Claude Code session
npx @wartzar-bee/tokenscope --demo # a bundled sample session — no logs needed
npx @wartzar-bee/tokenscope --all # aggregate every session
npx @wartzar-bee/tokenscope <file|dir> # a specific session .jsonl
npx @wartzar-bee/tokenscope --json # machine-readable
npx @wartzar-bee/tokenscope --share # privacy-safe shareable summary (markdown + SVG card)
npx @wartzar-bee/tokenscope --share-svg # just the SVG "cost report card"
```
Reads `~/.claude/projects/**/*.jsonl`. **Read-only, local, no network, no telemetry** — open the source; nothing leaves your machine.
## Share your bill (privacy-safe)
`--share` emits a compact summary built from **aggregate numbers only** — **no file paths, no prompt/response content** — so it's safe to paste in public:
- **Markdown** for Reddit / Discord / a GitHub issue (total, the output/cache-read/cache-write/fresh split with %, peak/avg context, and the headline "X% of spend was re-sent context").
- A self-contained **SVG "cost report card"** (`--share-svg`) — no binary deps; renders inline on GitHub and is trivially shareable.
- **How you compare** — both forms now answer "is my session unusual?" against a shipped, offline reference set of real sessions (e.g. _"more cache-efficient than ~80% of measured sessions; median session re-sends 24%"_). It's a reference yardstick, not a census — full honest distribution at [tokenscope.pages.dev/benchmark](https://tokenscope.pages.dev/benchmark/).
Prefer not to touch a terminal flag? The same render runs **entirely in your browser** at the web surface in [`web/`](web/): paste your `--json` output and it draws the full report + the SVG card locally — nothing is uploaded.
## Use it from an AI agent (MCP server)
There's an [**MCP server**](mcp/) that exposes the same engine to AI agents / MCP clients (Claude Desktop, Claude Code, etc.) as tools: `analyze_claude_cost`, `get_cost_benchmark`, and `tokenscope_share_summary`. Add it to your MCP config:
```json
{ "mcpServers": { "tokenscope": { "command": "npx", "args": ["-y", "@wartzar-bee/tokenscope-mcp"] } } }
```
Then ask your agent *"use tokenscope to analyze my last Claude Code session."* It's the same local, read-only engine — see [`mcp/README.md`](mcp/README.md).
## Pricing
Uses documented default prices (Anthropic cache multipliers: write 1.25×/2×, read 0.1× of input). **Verify and override** for your exact model/tier via `./.tokenscope.json`:
```json
{ "pricing": { "claude-opus-4": { "in": 15, "out": 75 } } }
```
Unknown models are flagged (never silently counted as $0). Token counts are read straight from the logs; cost = those counts × the prices shown.
## Status / roadmap
- v0.1: Claude Code session cost + context attribution + insights. **20/20 unit tests** on the cost math (`npm test`).
- Next (evidence-driven): per-tool/-file token attribution; daily/budget alerts; a `--watch` live meter; OpenAI/Codex log support.
MIT. Not affiliated with Anthropic.
Lo que la gente pregunta sobre tokenscope
¿Qué es wartzar-bee/tokenscope?
+
wartzar-bee/tokenscope es mcp servers para el ecosistema de Claude AI. See what your AI-coding session actually cost — and what is eating your context. Local, read-only CLI for Claude Code. Tiene 4 estrellas en GitHub y se actualizó por última vez today.
¿Cómo se instala tokenscope?
+
Puedes instalar tokenscope clonando el repositorio (https://github.com/wartzar-bee/tokenscope) o siguiendo las instrucciones del README en GitHub. ClaudeWave también te ofrece bloques de instalación rápida en esta misma página.
¿Es seguro usar wartzar-bee/tokenscope?
+
Nuestro agente de seguridad ha analizado wartzar-bee/tokenscope y le ha asignado un Trust Score de 87/100 (tier: Trusted). Revisa el desglose completo de comprobaciones superadas y flags en esta página.
¿Quién mantiene wartzar-bee/tokenscope?
+
wartzar-bee/tokenscope es mantenido por wartzar-bee. La última actividad registrada en GitHub es de today, con 0 issues abiertos.
¿Hay alternativas a tokenscope?
+
Sí. En ClaudeWave puedes explorar mcp servers similares en /categories/mcp, ordenados por popularidad o actividad reciente.
Despliega tokenscope en tu cloud
Lleva este repo a producción en minutos. Cada plataforma genera su propio entorno con variables de entorno editables.
¿Mantienes este repo? Añade un badge a tu README
Pega el badge en tu README de GitHub para mostrar que está auditado por ClaudeWave. Cada badge enlaza de vuelta a esta página y muestra el Trust Score actual.
[](https://claudewave.com/repo/wartzar-bee-tokenscope)<a href="https://claudewave.com/repo/wartzar-bee-tokenscope"><img src="https://claudewave.com/api/badge/wartzar-bee-tokenscope" alt="Featured on ClaudeWave: wartzar-bee/tokenscope" width="320" height="64" /></a>Más MCP Servers
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
An open-source AI agent that brings the power of Gemini directly into your terminal.
The fastest path to AI-powered full stack observability, even for lean teams.
Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface
🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!