← all repositories
mksglu/context-mode

Saving your context window from death by a thousand tool calls

Context Mode is an MCP server that sandboxes bloated tool output and persists session memory in SQLite so AI agents don't lose their place when the context window compacts.

19.2k stars TypeScript Coding AssistantsLLMOps · Eval
context-mode
Velocity · 7d
+31
★ / day
Trend
cooling
star history

What it does

Context Mode sits between your AI coding agent and its MCP tools, catching raw data before it floods the context window. It replaces direct tool output with sandboxed summaries—turning a 315 KB dump into roughly 5.4 KB—and stores session events in a local SQLite database. When the LLM eventually compacts the conversation to save space, the agent retrieves only relevant prior context via BM25 search instead of re-injecting everything.

The interesting bit

The project enforces a “think in code” paradigm: rather than reading dozens of files into the prompt just to count functions, the agent writes a short script, executes it inside the sandbox, and logs only the result. That shifts computation from the LLM to an actual runtime, which is where the 100× savings come from.

Key highlights

  • Claims a 98% reduction in context bloat by intercepting tool output before it reaches the model.
  • Session continuity survives conversation compaction via an FTS5 index and BM25 retrieval; previous sessions are wiped immediately if you don’t --continue.
  • Ships with 11 MCP tools, including sandbox executors and a meta-tool that opens a local analytics dashboard tracking 90 metrics.
  • Enforces routing automatically on hook-capable platforms; others need a one-time routing file copy.

Caveats

  • Licensed under ELv2, which carries restrictions on commercial use and redistribution that go beyond typical open-source terms.
  • Auto-routing requires platform hooks; agents without hook support need a manual routing file copy to get full enforcement.
  • It keeps raw data out of context but explicitly refuses to police the model’s output style, so token waste from verbose agent responses is still your problem.

Verdict

Worth a look if you run long agent sessions and watch your context window evaporate after thirty minutes. If you prefer lightweight, fully open-source tooling or only dabble with AI agents occasionally, the license overhead and platform-specific setup may not pay off.

Frequently asked

What is mksglu/context-mode?
Context Mode is an MCP server that sandboxes bloated tool output and persists session memory in SQLite so AI agents don't lose their place when the context window compacts.
Is context-mode open source?
Yes — mksglu/context-mode is an open-source project tracked on heatdrop.
What language is context-mode written in?
mksglu/context-mode is primarily written in TypeScript.
How popular is context-mode?
mksglu/context-mode has 19.2k stars on GitHub and is currently cooling off.
Where can I find context-mode?
mksglu/context-mode is on GitHub at https://github.com/mksglu/context-mode.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.