TokenDiet MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@TokenDiet MCPrun 'npm test' and compress output"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TokenDiet MCP
TokenDiet is a local MCP server that compresses file reads, command output, search hits, and fetched web pages before they enter the agent context. It uses deterministic transforms (outline+, log dedup, snippet caps) and a safety verifier that rolls back when compression would drop protected content or fail to shrink the payload. Token counts use a real BPE encoder (o200k_base by default), not character guesses.
This only helps when the agent gets data through TokenDiet tools. If built-in Read or Bash already loaded the full text into context, calling compress afterward cannot undo that cost.
Two value propositions (honest)
Billed cost — savings on profile workloads (logs, web pages, large files, batch reads) when the agent uses TokenDiet tools without extra MCP turns. On small files or drill-down ladders, billed cost can be higher than baseline; the server-side economic guard and batch API exist to prevent that. See
benchmarks/2026-07-25-e2e-turn-neutral.md.Context window budget — fewer fresh tokens per turn delays context summarization in long sessions. This benefit is independent of cache pricing and applies even when billed cost is neutral.
Turn-neutral rule (v0.7.0): compression must not multiply agent turns. Implemented via economic guard (T_full ≈ 3K BPE), read(targets[]) batching, outline+ (not outline→expand ladders), and optional shrink proxy for upstream MCP servers.
verified: true means structure verified — check warnings, omitted.bodies, and compression.net_estimate before editing code.
Related MCP server: winnow
Install (from source)
Requires Node.js 20+ and build tools for better-sqlite3 (native addon).
git clone https://github.com/DukeDeSouth/tokendiet-mcp.git
cd tokendiet-mcp
npm install
npm run buildWire Cursor (example — adjust paths after clone):
node dist/index.js setup --client cursor --project /path/to/your/projectReload MCP servers in Cursor. Point agents at read, run, search, fetch, expand, and stats instead of raw Read/Grep/Bash for large payloads.
Shrink proxy (wrap upstream MCP servers)
TokenDiet can sit between Cursor and another MCP server and compress results inside the same tool round-trip (no extra agent turns). This does not intercept built-in Cursor/Codex tools — only MCP servers you wrap.
# Example: wrap Playwright MCP
tokendiet-mcp shrink -- npx @playwright/mcp@latestCursor mcp.json (stdio) — replace the upstream command with the shrink wrapper:
{
"mcpServers": {
"playwright": {
"command": "node",
"args": ["/absolute/path/to/tokendiet-mcp/dist/index.js", "shrink", "--", "npx", "@playwright/mcp@latest"]
}
}
}Optional: TOKENDIET_SHRINK_SERVER=playwright selects a profile from shrink.config.json (allowlist/denylist, min_text_tokens, content hints).
What gets compressed:
tools/list— long tooldescriptionstrings (schema overhead)tools/call— large text content blocks; images/resources pass through byte-safe
Compressed blocks append [compressed by tokendiet — expand(<ref>) for full]. Retrieve the original via the TokenDiet expand tool when the main TokenDiet MCP server is also configured.
See shrink.config.json for per-upstream tuning.
Tools
Tool | Role |
| Batch file read ( |
| Shell command with compressed stdout/stderr |
| Ripgrep with JS fallback; compressed snippets |
| HTTP fetch with HTML/JSON/text compression |
| Full content from a prior |
| Session and all-time token accounting |
What to expect (honest ranges)
Measured on our dogfood corpus and E2E harness (benchmarks/), not a universal promise:
Turn-neutral N-corpus (offline sim): v2 policy turns_ratio 0.38, cost_ratio 0.36 vs baseline
User A/B v1 (documented failure): turns_ratio 4.42, cost_ratio 2.36 — why v0.7.0 exists
Test and log output via
run: often 68–99% payload savedShrink proxy (Playwright snapshot sim): ≥50% saved, 0 extra turns
Small files (< ~3K BPE): server returns full content; use built-in Read or batch
targets[]stats.net_tokens_estimatesubtracts turn cost — negative means the call was economically unprofitable
See benchmarks/2026-07-11-dogfood-v3.md and benchmarks/2026-07-25-e2e-turn-neutral.md for methodology.
Limitations
AST outline modes: TypeScript, JavaScript, Python (via tree-sitter WASM bundled in
wasm/)searchwithoutrginstalled uses a slower JS walker (respects.gitignore)fetchdoes not execute JavaScript; private IPs are blocked (SSRF hygiene)BPE counts approximate Claude/Gemini tokenizers; relative savings are still meaningful because in/out use the same encoder (
docs/TOKENIZER.md)Ref cache under
~/.tokendiet/refs(TTL/size capped via env) — local only, no cloud
Privacy
Everything runs on your machine over stdio. No telemetry, no remote compression service.
Development
npm test
npm run e2e:gate
npm run check-disclosureLicense
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityBmaintenanceContextCrumb compresses long text, local files, and MCP catalog descriptions into denser context for LLM agents. It helps agents load more useful information into the context window and reduce token usage without turning the input into a summary.1MIT
- Alicense-qualityBmaintenanceEnables local-first context compression for AI agents, offering tools to compress text, retrieve original content, and get compression statistics.438MIT
- Alicense-qualityCmaintenanceToken compression for AI contexts, reducing token consumption by compressing conversation exchanges before they enter the LLM context window.MIT
- Alicense-qualityCmaintenanceCompresses, deduplicates, and filters tool outputs to optimize token usage and context window for AI agents.MIT
Related MCP Connectors
Deterministic AI agent microtools, no accounts/API keys. fetch_extract: 98% token cut. 38 tools.
A paid remote MCP for OpenAI Codex context compressor, built to return verdicts, receipts, usage log
Same functionality, consuming only 1/20 of the context window tokens.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DukeDeSouth/tokendiet-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server