Profile and optimize LLM context windows — see what's eating your tokens and fix it. CLI + MCP server for Claude, GPT, and any AI app.
- ✓Open-source license (MIT)
- ✓Actively maintained (<30d)
- ✓Clear description
- ✓Documented (README)
claude mcp add context-doctor -- npx -y context-doctor{
"mcpServers": {
"context-doctor": {
"command": "npx",
"args": ["-y", "context-doctor"]
}
}
}Resumen de MCP Servers
# context-doctor 🩺 [](https://github.com/KushalP1/context-doctor/actions) [](https://www.npmjs.com/package/context-doctor) [](https://www.npmjs.com/package/context-doctor) [](./LICENSE)  **Cut your Claude Code bill, measured on your own sessions.** ```bash npx context-doctor savings ``` One command shows, in dollars, what your recent sessions cost and what each lever below would have saved on them. Then the levers do it: an every-prompt hook, an auto-compact window, and a proxy that never makes a request more expensive. Long agent sessions fill up with tool output nobody reads again, and a 500k-token session re-reads all of it on every message. The most expensive moment is coming back after lunch: the prompt cache has expired, so the next message re-sends everything at full price. `context-doctor` measures this on your own sessions and acts on it at the moments that pay. - **Tells you when to `/compact`, at the moment it pays.** When you come back to a large session after the cache expired, the every-prompt hook gives the model the numbers and it offers `/compact` once. Replayed over 133 days of the author's Claude Code history: 401 such returns, and compacting then would have saved **$4,053 net at list price, about $914 a month**. It works in every Claude Code surface, including the desktop app. [What it saves →](#what-it-saves) - **Compacts earlier, automatically, in every Claude Code surface.** Claude Code auto-compacts near the full window (measured: ~970k tokens on a 1M model), so long sessions re-read 400k-900k tokens on every message. `context-doctor compact-window` replays your history at smaller windows and, if you choose, sets Claude Code's own `autoCompactWindow`. On the author's last 30 days: **a 400k window would have cut input cost 55%** ($6,119 to $2,757), for 15 compactions a week instead of 5. A native setting, so it works in the desktop app too. [The trade-off →](#3-compacting-earlier-automatic) - **Autopilot for terminal and IDE sessions and API apps:** a local proxy that clears stale tool output only when the prompt cache is cold, so it never costs more. **9.8% less input cost, no session made more expensive**, in the same replay. (The desktop app's Code tab sets its own API address, so autopilot cannot reach it; `doctor` tells you if that is your case.) - **Counts Claude correctly.** Current Claude models pack 2.75 characters per token, not the 4 most tools assume, so estimates built on 4 undercount Claude by about 40%. The ratios were measured from the API's own counts; `context-doctor accuracy` re-checks them on yours. - **Works where you work:** Claude Code (terminal, IDE, desktop app, plugin), Cursor, Codex, Claude Desktop chat, any Anthropic or OpenAI API app, VS Code, CI. macOS, Linux and Windows, Node 20+. Local, keyless, no telemetry, MIT. Built and maintained by [gAI Ventures](https://gai.ventures). > **Which context-doctor is this?** Several projects share the name. This one is [`context-doctor` on npm](https://www.npmjs.com/package/context-doctor) and `io.github.KushalP1/context-doctor` in the [official MCP Registry](https://registry.modelcontextprotocol.io): the one you run as `npx context-doctor`, and the one that prices what it saves on your own history. ## Quick start **See what it would save you first** (no install, reads your local Claude Code history): ```bash npx context-doctor savings ``` <img src="https://raw.githubusercontent.com/KushalP1/context-doctor/main/assets/savings.svg" alt="npx context-doctor savings: input billed, what /compact at cold resumes, autopilot and an earlier auto-compact window would have saved" width="640"> That is the author's machine: every session there runs in the desktop app, which autopilot cannot reach, so lines 1 and 3 are the ones that apply. Yours is computed the same way, from your own transcripts: every session replayed request by request through the shipped code, against what you were actually billed. `context-doctor savings --share` prints a few lines with totals only (no project names or paths) if you want to post your number. **Then install it**, whichever way suits you: ```bash # Everything, every app it finds (Claude Code, Cursor, Codex, Claude Desktop) npm install -g context-doctor context-doctor install context-doctor autopilot on # every new Claude Code session keeps its context lean ``` ```text # Or as a Claude Code plugin, from inside Claude Code /plugin marketplace add KushalP1/context-doctor /plugin install context-doctor@context-doctor ``` The plugin brings the every-prompt check, the MCP tools, and `/context-doctor:savings`, `/context-doctor:checkup`, `/context-doctor:autopilot` and `/context-doctor:compact-window`. It needs no npm step: the MCP server ships as one self-contained file, so it also works on Claude Code versions that do not install plugin dependencies. `context-doctor autopilot status` shows what autopilot did; `context-doctor doctor` checks the whole setup. Everything is reversible: `context-doctor autopilot off`, `context-doctor uninstall`, or `/plugin uninstall`. ``` Where the tokens go ──────────────────────────────────────────────────────── Tool results ████████████████░░░░░░░░░░░░ 57% ~41k System prompt ██████░░░░░░░░░░░░░░░░░░░░░░ 21% ~15k Assistant replies ████░░░░░░░░░░░░░░░░░░░░░░░░ 13% ~9.4k User messages ██░░░░░░░░░░░░░░░░░░░░░░░░░░ 9% ~6.5k Findings (4) ──────────────────────────────────────────────────────── ✖ Message #12 contains a base64/binary blob (~8.2k tokens). [save ~7.4k] → Never put base64 in text content — use the provider's file/image APIs. ▲ Tool result at message #7 (web_search) is ~6.1k tokens. [save ~4.9k] → Truncate or summarize large tool outputs before they enter history. ``` ## What it saves Measured, not modelled, on every Claude Code session on the author's machine (mostly Opus 5 and Fable 5 with the 1M window), priced the way the prompt cache bills it (cached reads 0.1x, writes 1.25x) at API list prices. `context-doctor savings` runs the same measurement on yours. **1. Compacting when you come back** (every Claude Code surface, desktop app included). 133 days, 401 returns to a session over 150k tokens after more than 65 idle minutes; median context at the return, 517k tokens. | | | |---|---| | Net saving had you run `/compact` after the first reply | **$4,053 (about $914 a month)** | | Returns where it paid off | 296 of 401 | | Worst single case | −$2.30 (a session left a few messages later) | Each return counts only the messages up to the next return, and the compaction request is charged as a cost. Not counted: files the model may re-read after compacting, and what the summary leaves out. That is why this is advice with the numbers attached, not something done for you. **2. Autopilot** (terminal and IDE sessions, API apps). 130 days, 43 sessions, replayed through the shipped autopilot code with real timestamps: | | Without autopilot | With autopilot | Saved | |---|---|---|---| | Input tokens sent | 41.4 billion | 37.6 billion | **3.8 billion (9.2%)** | | Input cost at API list price | $48,962 | $44,268 | **$4,694 (9.8%)** | | Sessions made more expensive | | | **0 of 43** | The median session saves 1.9%, the best 37.7%: long sessions are where the money is (94% of input cost on that machine came from requests above 200k tokens). These sessions ran in the desktop app, which autopilot cannot reach, so for the author this is what the same sessions would have saved in a terminal; `context-doctor savings` separates the two for you. **3. Compacting earlier** <a id="3-compacting-earlier-automatic"></a>(automatic, every Claude Code surface, desktop app included). The offer in 1 is advice, and on the author's machine it was followed 1 time in 33. Claude Code has a native setting that needs nobody to follow anything: `autoCompactWindow` in `~/.claude/settings.json` makes it compact as if the window were that size. `context-doctor compact-window` replays each session request by request at several sizes, priced as the cache bills (each simulated compaction pays its own request and a 20k-token summary at the output rate), and changes nothing until you pick one: | Window | Input cost, last 30 days | Saved | Compactions a week | |---|---|---|---| | as now (~970k) | $6,119 | | 5.1 | | 600k | $3,570 | $2,549 (42%) | 6.5 | | **400k** | **$2,757** | **$3,362 (55%)** | **14.7** | | 300k | $2,353 | $3,766 (62%) | 24.5 | | 200k | $1,963 | $4,155 (68%) | 46.9 | 29 sessions. The replay's baseline came within 9% of what the transcripts say was billed, on the low side. The cost is real: each compaction replaces the session's history with a summary, so a smaller window trades detail for money. That is why the command shows the table first and sets a window only when you name one (`context-doctor compact-window 400k`; `off` undoes it, and a backup of settings.json is kept). On a Claude subscription you do not pay list price; the same tokens come out of your usage limit instead. Anthropic does not publish how limits weight cached tokens, so read the dollars as the size of the effect, not as your bill. ## What happens on each platform | Where you work | Automatic, every request | What you get on top | |---|---|---| | **Claude Code** in the terminal, VS Code or JetBrains | **Autopilot** clears stale tool output (cold cache only, never more expensive). **Hook** on every prompt: real context size, largest waste, and a `/compact` offer when you return to a large session after the cache expired. **`compact-window`**, if you set one | | **Claude Code** in the desktop app's C
Lo que la gente pregunta sobre context-doctor
¿Qué es KushalP1/context-doctor?
+
KushalP1/context-doctor es mcp servers para el ecosistema de Claude AI. Profile and optimize LLM context windows — see what's eating your tokens and fix it. CLI + MCP server for Claude, GPT, and any AI app. Tiene 1 estrellas en GitHub y su última actualización registrada es del 2026-10-06.
¿Cómo se instala context-doctor?
+
Puedes instalar context-doctor clonando el repositorio (https://github.com/KushalP1/context-doctor) 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 KushalP1/context-doctor?
+
Nuestro agente de seguridad ha analizado KushalP1/context-doctor 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 KushalP1/context-doctor?
+
KushalP1/context-doctor es mantenido por KushalP1. La última actividad registrada en GitHub es del 2026-10-06, con 1 issues abiertos.
¿Hay alternativas a context-doctor?
+
Sí. En ClaudeWave puedes explorar mcp servers similares en /categories/mcp, ordenados por popularidad o actividad reciente.
Despliega context-doctor 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/kushalp1-context-doctor)<a href="https://claudewave.com/repo/kushalp1-context-doctor"><img src="https://claudewave.com/api/badge/kushalp1-context-doctor" alt="Featured on ClaudeWave: KushalP1/context-doctor" 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.
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! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
The fastest path to AI-powered full stack observability, even for lean teams.