Context Mode

Manages AI agent context by sandboxing tool outputs and persistently tracking session state across multiple LLM development environments to prevent context window bloat.

A high-resolution social sharing image preview for Context Mode tool.

The gist

Context Mode is an MCP server that addresses the problem of context window bloat and loss of session continuity when using AI agents and LLM tools. Developed by mksglu, it prevents raw data from overwhelming the LLM's context by using a sandbox and persistent storage. It ensures agents can maintain awareness of ongoing tasks and files across sessions.

What it does

  • Save LLM context by sandboxing raw tool output and only returning relevant summaries.
  • Maintain session continuity by tracking all relevant agent events in a local SQLite database.
  • Enable LLMs to act as code generators by executing scripts in a sandbox, rather than processing large datasets directly.
  • Provide full-text search and BM25 ranking over indexed content for efficient retrieval.
  • Offer diagnostic, upgrade, and analytics utilities via slash commands or chat prompts.
  • Support multiple AI platforms and development environments through hooks and plugins.

How it works

Context Mode functions as an MCP server, intercepting LLM tool calls. It uses isolated subprocesses (sandboxes) to execute code in 11 languages, returning only concise stdout to the LLM's context. Session events and indexed content are stored in a local SQLite database, leveraging FTS5 and BM25 ranking for efficient retrieval. Functionality is delivered via platform-specific plugins and hooks for various AI development environments, and the tool is open-source.

Best for

Ideal for developers and AI engineers building or using agents on platforms like Claude Code, VS Code Copilot, or Gemini CLI who struggle with LLM context window limits and session state loss during complex, multi-step tasks.

Watch out for

Full session continuity and automatic routing enforcement rely heavily on platform-specific hook support; some platforms (e.g., Antigravity, Zed in current releases) offer only partial or no hook integration, requiring manual file copying for reduced effectiveness.