An MCP server that stops AI agents from hoarding junk in their context window
Context Mode sandboxes tool output, indexes session state in SQLite, and nudges agents to think in code instead of prose.

What it does Context Mode is an MCP server that intercepts the flood of raw data from tool calls — Playwright snapshots, GitHub issues, log files — and keeps it out of the LLM’s context window. It replaces verbose output with sandboxed execution results, tracks session state in a local SQLite database with FTS5 search, and enforces a “think in code” pattern where the agent writes scripts instead of reading files into context. It supports 15+ platforms including Claude Code, Gemini CLI, Cursor, and Zed.
The interesting bit
The project treats context compression as a data-routing problem, not a prompting problem. When the conversation compacts, Context Mode doesn’t dump history back into the window — it retrieves only relevant events via BM25 search. The “think in code” mandate is unusually strict: the LLM must generate scripts that console.log() results, turning 47 file reads into one 3.6 KB execution. The README explicitly rejects prose-style enforcement, citing evidence that aggressive brevity prompts degrade reasoning benchmarks.
Key highlights
- Claims 98% context reduction (315 KB → 5.4 KB) via sandboxed tool output
- Session continuity through SQLite + FTS5 indexing with BM25 retrieval
- 11 MCP tools: six sandbox executors (
ctx_execute,ctx_batch_execute, etc.) plus five meta-tools (ctx_stats,ctx_doctor,ctx_insight) - Hook-based automatic routing on Claude Code and Gemini CLI; manual config file for other platforms
- Optional status line showing real-time savings per session
ctx_insightopens a local analytics dashboard with 90 metrics across 23 event categories
Caveats
- License is ELv2 (Elastic License v2), not open source
- Platform coverage varies: Claude Code gets full plugin marketplace install, others require manual config file edits or hook setup
- The 98% reduction figure is self-reported from the README without independent verification
- Session data is deleted on fresh starts unless
--continueis used, which could surprise users expecting persistent history
Verdict Worth trying if you hit context limits daily with agentic coding tools — especially Claude Code users who can install via marketplace. Skip if you need true open source or if your workflow doesn’t involve heavy tool-call churn.