MCP server that reduces Claude Code context consumption by 98%
TL;DR Highlight
Running tool output in a sandbox cut Claude Code context use from 315KB to 5.4KB.
Who Should Read
A developer running long Claude Code sessions whose context fills up fast from MCP tool output.
Core Mechanics
- Tool output eats your context
- One Playwright snapshot costs 56 KB, 20 GitHub issues cost 59 KB, and one access log costs 45 KB.
- After 30 minutes, 40% of the 200K context is gone, per the post.
- Tool definitions are already a heavy cost
- With 81+ tools active, 143K tokens (72%) are used before the first message.
- Cloudflare's Code Mode compressed tool definitions by 99.9%, and this post compresses the output side.
- Run code in a sandbox, keep only stdout
- Each execute call spawns an isolated subprocess, and only its stdout enters the conversation.
- Raw logs, API responses, and snapshots never leave the sandbox.
- Raw data goes into a SQLite search index
- The index tool chunks markdown by heading, keeps code blocks intact, and stores them in an SQLite FTS5 (full-text search) table.
- Search uses BM25 ranking (term-frequency-based scoring) with Porter stemming, so running, runs, and ran match.
- There are no LLM calls, and search returns the indexed original code blocks, not summaries.
- All 11 scenarios came in under 1 KB
- Playwright snapshot 56 KB to 299 B, 20 GitHub issues 59 KB to 1.1 KB, 500-request access log 45 KB to 155 B.
- Over a full session, remaining context after 45 minutes rose from 60% to 99%.
- Sessions last about 3 hours instead of 30 minutes
- The author says he worked 6x longer before context degradation in his own sessions.
- A PreToolUse hook routes tool output through the sandbox, and Bash subagents are upgraded to general-purpose so they use batch_execute.
Community Reactions
- Community: BM25 alone may not be enough
- Commenters said tool output mixes structured data (JSON, tables) and natural language, so keyword matching is weak on the structured half.
- One commenter built a hybrid of Model2Vec, sqlite-vec, and FTS5 merged with RRF over a 15,800-file vault, with incremental indexing under 10 seconds.
- Community: concerns about information loss and aggressive hooks
- Several commenters said that if the model writes a bad extraction script, the needed information is gone, and the benchmarks assume it always writes the right one.
- Others said routing even a 200-byte health check through the sandbox is overkill, and that cross-session context may suffer.
- Community: alternatives and real-world experience
- Some said using CLIs such as the GitHub CLI instead of MCP costs far fewer tokens.
- One user ran rtk for a week and found it a good balance, and another recommended Context Mode to their team for a sizable token reduction.
- Community: caching and accuracy remain open questions
- A commenter warned that breaking the prompt cache would be penny wise and pound foolish, and the post does not mention caching.
- Others asked whether benchmarks show that less context makes the model perform better.
How to Apply
- Measure token burn with claude-trace first
- Today, run the CLI from the comments (vexorkai/claude-trace), which parses ~/.claude/projects/*/*.jsonl, to see usage by session and tool.
- Find which MCP tool uses the most before deciding whether to install.
- Install Context Mode MCP-only and compare
- Run claude mcp add context-mode -- npx -y context-mode in your terminal and restart Claude Code.
- Run the same task for 30 to 45 minutes and compare remaining context to before.
- Route only big-output tools to the sandbox
- Tell the agent in your prompt to use execute or batch_execute for Playwright snapshots, issue lists, and logs that return tens of KB.
- Let it read small responses directly to avoid over-aggressive hooks and information loss.
- Spot-check extraction against raw data
- For important work, review the extraction script the model wrote and its output.
- If something is missing, index the raw data with index and have the model find it with search.
Try It
# Prompt to paste into a Claude Code session (after installing Context Mode, a simplified use of the post's approach)
For tasks with large expected output, don't put the raw data in the conversation. Follow these rules.
1. Run {{task: e.g. gh issue list for 20 issues}} in the sandbox with execute and print only the information I need to stdout.
2. Before printing, tell me in one line what criteria you used to extract.
3. If output may exceed 1 KB, index it with index and fetch only the needed parts with search.
4. Small responses of around 200 bytes can be read directly without the sandbox.
5. I am looking for {{information to find}}. Check that your extraction logic doesn't miss it.
# Install (shell): claude mcp add context-mode -- npx -y context-modeTerminology
Related Papers
A Beginner's Guide to Local AI with Inkling, Qwen, and Unsloth
Install Unsloth Desktop, load a quantized Qwen model, and share a private ChatGPT-like AI on your home LAN.
Muru – AI-assisted Rust server for Python apps by mod_WSGI's creator
mod_wsgi's creator is building Muru, an AI-assisted Rust ASGI/WSGI server, documenting it in public
87% of the Anthropic power will come from gas and 11% from coal in 2028
Analysis of Anthropic's contracted data centers: 87% gas, 11% coal power in 2028
Anthropic’s Nasdaq debut
Anthropic listed on Nasdaq and closed its first day below its opening price.
OpenAI still has a WebRTC Problem
WebRTC drops late audio, hurting voice AI; MoQ retransmits and buffers instead
Gemini 4 Neon
Gemini 4 Neon cuts cost per task 32% versus Carbon, at $3 input and $15 output per million tokens
AI is killing All About Berlin
After Google AI Overviews, a Berlin guide site lost 70-75% of its traffic.
Not Everything Needs an LLM
PostHog used small decision models to skip 98.7% of expensive LLM calls