Loading theme preference
Ilia Bukin
← Back to blog

context-mode: the MCP server that keeps raw tool output out of your agent's context window

Sep 11, 2026

context-mode: the MCP server that keeps raw tool output out of your agent's context window

Every coding agent hits the same wall sooner or later: reach for an MCP tool, get a dump of raw text back, and watch a slice of the context window disappear. context-mode is a newer open-source project aimed squarely at that annoyance. It has had a good week. This week it was the top trending TypeScript repo on GitHub, adding about 1,600 stars in a few days on top of a 22k-star base.1

The problem is tool output, not tool definitions

Even before you run into a hard context limit, it is easy to feel. A single Playwright snapshot of a page is around 56 KB. Twenty GitHub issues come in at about 59 KB. One access log is roughly 45 KB. Count those up and the project's README notes that after 30 minutes of that kind of work, about 40% of a session's context is already gone.2

The detail that tends to get lost is which half of "context" is the problem. Tool definitions are small, and some projects already squeeze them hard. The real consumers are tool outputs, the verbatim results pasted back on every call. That is the half context-mode targets.

What it does

The project is an MCP server that sits between the agent and its tools, and it attacks the problem from four sides:2

  • Context saving. Large tool output runs in a sandboxed subprocess and never gets dumped raw into the conversation. Raw data goes into a local SQLite FTS5 store, and the model sees a compact summary or a pointer instead. In one benchmark scenario that takes 315 KB of raw output down to 5.4 KB of context, a 98% reduction.2
  • Session continuity. File edits, git operations, tasks, errors, and user decisions are tracked in SQLite. When a conversation compacts, its events are indexed into FTS5 and retrieved with BM25 search, so the model picks up where it left off without reloading everything. Skip --continue and the previous session's data is deleted outright; a fresh session is a clean slate.2
  • Think in code. Rather than have the model read fifty files just to summarize them, the sandbox lets it write a short script that does the work and logs only the result. The README's example turns 47 sequential reads, about 700 KB, into a single ctx_execute call that lands in context at roughly 3.6 KB.2

That last one is the mindset shift the project is pushing: treat the model as a code generator, not a data processor. Writing a script that counts functions beats loading fifty files into context to count them.

The numbers, as the project reports them

The repo's BENCHMARK.md documents the savings against outputs captured from real tool invocations, not synthetic fixtures: Context7 docs, Playwright snapshots, GitHub PR and issue listings, vitest output, nginx access logs.3

Across 21 scenarios it reports 376 KB of raw input compressed into 16.5 KB of context, about a 96% reduction, with every code example coming back exact rather than summarized.3 The compression splits neatly by tool:

  • ctx_execute_file, meant for logs, test output, and other data where an aggregate beats the raw lines, hits 98% on its subtotal (315 KB to 5.5 KB).3
  • ctx_index plus ctx_search, used for documentation and code where you want the exact text back, saves less, around 82% on its subtotal, because it deliberately returns whole chunks instead of summaries.3

Outputs over 100 KB are auto-indexed into FTS5 and replaced in context with a pointer message, so nothing is lost, just parked out of the way until the model calls ctx_search.3

None of this is independent validation. These are self-reported figures from the repo and a benchmark by the same authors, so read them accordingly.

Where it runs

There are 17 integrations, from a Claude Code plugin with routing enforced automatically through hooks, to Gemini CLI, VS Code Copilot, JetBrains, GitHub Copilot CLI, Cursor, OpenCode, KiloCode, the OpenClaw/Pi gateway, and Codex CLI.2 Hook-capable platforms get automatic routing; the rest get a routing-rules file. The npm package is context-mode, currently at version 1.0.169, and it needs Node 22.5 or newer.4

A couple of caveats

The license is Elastic License 2.0, source-available rather than an OSI-approved open-source license, which matters if you plan to build a business on it. And headline figures like 98% or the marketing site's "30× fewer tokens" come from the project itself, so treat them as pointers, not independent proof.5

Still, it is a sound idea at a moment when context is the scarce resource in agentic coding. If raw tool output is what keeps killing your long sessions, it is worth a weekend try.


  1. https://github.com/trending/typescript?since=weekly
  2. https://github.com/mksglu/context-mode
  3. https://github.com/mksglu/context-mode/blob/main/BENCHMARK.md
  4. https://raw.githubusercontent.com/mksglu/context-mode/main/package.json
  5. https://context-mode.com/context-saving