Context Mode is an MCP (Model Context Protocol) server built for developers using AI coding agents like Claude Code, GitHub Copilot, Gemini CLI, Cursor, and similar tools. It targets a specific pain point: raw tool output (file dumps, API responses, browser snapshots) flooding the model's context window and eating the budget meant for actual reasoning. It's for anyone running long agent sessions who notices the model forgetting what it was doing after a context compaction, or burning through context on a single Playwright snapshot or GitHub issue dump.
The core idea is that agents shouldn't read raw data into context when they can write a script to process it and log only the result. Context Mode enforces this pattern through sandboxed execution tools, tracks session state in SQLite with FTS5 indexing for retrieval after compaction, and avoids dictating how the model phrases its final answers.
ctx_execute, ctx_batch_execute, ctx_execute_file) run code and return only console output, turning a 315 KB tool result into roughly 5.4 KB, a claimed 98% reduction.ctx_stats, ctx_doctor, ctx_upgrade, ctx_purge, ctx_insight) and slash commands expose per-tool token savings, run health checks, and manage the local knowledge base.Installation steps differ by platform since each agent has its own hook and MCP registration mechanism. Claude Code has the most automated path via its plugin marketplace:
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode
Restart Claude Code (or run /reload-plugins), then verify with:
/context-mode:ctx-doctor
For an MCP-only install without hooks or slash commands on Claude Code:
claude mcp add context-mode -- npx -y context-mode
For Gemini CLI (requires Node.js >= 22.5 or Bun):
npm install -g context-mode
Then add the MCP server and hook definitions to ~/.gemini/settings.json (see README for the full JSON block), restart Gemini CLI, and verify with /mcp list.
For VS Code Copilot and JetBrains Copilot, install globally with npm install -g context-mode, then create the platform-specific MCP config (.vscode/mcp.json or the JetBrains Settings UI) plus a .github/hooks/context-mode.json hook file, and restart the IDE.
For GitHub Copilot CLI, the recommended path is:
npm install -g context-mode
copilot plugin install mksglu/context-mode:configs/copilot-cli
After any install, run the platform's diagnostic command (ctx doctor or the equivalent slash command) to confirm hooks, FTS5, and MCP registration are working.