Context Mode
An MCP server that preserves LLM context by intercepting large data outputs and returning only concise summaries or relevant sections. It enables efficient sandboxed code execution, file processing, and documentation indexing across multiple programm
What is Context Mode?
Context Mode is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp server that preserves llm context by intercepting large data outputs and returning only concise summaries or relevant sections. it enables efficient sandboxed code execution, file processing, and ...
An MCP server that preserves LLM context by intercepting large data outputs and returning only concise summaries or relevant sections. It enables efficient sandboxed code execution, file processing, and documentation indexing across multiple programm
This server falls under the Knowledge & Memory category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- An MCP server that preserves LLM context by intercepting lar
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx context-modeConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Context Mode
Context Mode is an MCP server designed to prevent AI assistants from exhausting their context window when working with large outputs. It intercepts code execution results, file content, and fetched web pages and returns only concise summaries or relevant sections rather than dumping thousands of tokens into the conversation. The server provides sandboxed code execution in 12 programming languages, full-text indexed document search with BM25 ranking, and URL fetching with HTML-to-markdown conversion — all with measured context reduction that typically achieves 90–99% token savings compared to raw output.
Prerequisites
- Node.js 18 or higher (for npx-based install) or npm for global installation
- An MCP-compatible client such as Claude Desktop, Claude Code, Gemini, or Codex CLI
- At least one runtime installed for code execution (e.g., Python 3, Go, Node.js) if you want sandboxed code running
- Internet access for the URL fetch and index capabilities
Install Context Mode globally
Install the context-mode package globally via npm so it is available as a CLI tool that your MCP client can spawn.
npm install -g context-modeConfigure environment variables (optional)
Set optional environment variables to customize storage paths, platform detection, and security. CONTEXT_MODE_DIR sets the absolute storage path; CTX_FETCH_STRICT blocks loopback/private-network fetches.
export CONTEXT_MODE_DIR="/path/to/storage"
export CONTEXT_MODE_EXTERNAL_MCP_NUDGE_EVERY=10Add Context Mode to your MCP client configuration
Register context-mode as an MCP server in your client's configuration file. The server auto-detects your platform (Claude, Gemini, Codex) and adjusts its behavior.
For Claude Code, install via plugin marketplace
If using Claude Code, you can install Context Mode directly through the plugin marketplace for automatic integration with hooks and settings.
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-modeRun a health check
After connecting, ask your AI assistant to run ctx_doctor to verify that runtimes, FTS5 search, hooks, and the storage directory are all configured correctly.
Execute code and check context savings
Use the ctx_execute tool to run code in a sandbox and then call ctx_stats to see how much context was saved compared to raw output.
Context Mode Examples
Client configuration
Add this to your claude_desktop_config.json to register context-mode as an MCP server. The CONTEXT_MODE_DIR variable controls where sessions and indexes are stored.
{
"mcpServers": {
"context-mode": {
"command": "npx",
"args": ["context-mode"],
"env": {
"CONTEXT_MODE_DIR": "/Users/yourname/.context-mode",
"CONTEXT_MODE_EXTERNAL_MCP_NUDGE_EVERY": "10"
}
}
}
}Prompts to try
Use these prompts with Claude after enabling Context Mode to take advantage of context-saving execution and search.
- "Use ctx_execute to run this Python script and summarize the output: [paste script]"
- "Fetch and index https://docs.example.com/api then search it for 'authentication'"
- "Run ctx_stats to show how much context has been saved in this session"
- "Index this large JSON file and find records where status is 'failed'"
- "Run ctx_doctor to check that all runtimes are available"Troubleshooting Context Mode
ctx_execute fails with 'runtime not found' for a language
Ensure the required runtime is installed and on your PATH (e.g., `python3 --version`, `go version`). Run ctx_doctor to see which runtimes context-mode can detect. Install the missing runtime and restart your MCP client.
ctx_index or ctx_search returns no results after indexing
FTS5 full-text search requires SQLite with FTS5 compiled in. Run ctx_doctor to check FTS5 availability. If missing, rebuild SQLite with FTS5 or use a Node.js distribution that bundles it.
CTX_FETCH_STRICT blocks URLs you expect to work
CTX_FETCH_STRICT blocks loopback (127.x) and RFC1918 private addresses for security. Do not set this variable if you need to fetch from localhost or internal network URLs during local development.
Frequently Asked Questions about Context Mode
What is Context Mode?
Context Mode is a Model Context Protocol (MCP) server that mcp server that preserves llm context by intercepting large data outputs and returning only concise summaries or relevant sections. it enables efficient sandboxed code execution, file processing, and documentation indexing across multiple programm It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Context Mode?
Follow the installation instructions on the Context Mode GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Context Mode?
Context Mode works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Context Mode free to use?
Yes, Context Mode is open source and available under the Elastic License 2.0 license. You can use it freely in both personal and commercial projects.
Context Mode Alternatives — Similar Knowledge & Memory Servers
Looking for alternatives to Context Mode? Here are other popular knowledge & memory servers you can use with Claude, Cursor, and VS Code.
MemPalace
★ 52.6kA local AI memory system that stores all conversations verbatim and organizes them into navigable structures. It provides 19 MCP tools for AI assistants to search and retrieve past decisions, debugging sessions, and architecture debates automatically
Kratos
★ 25.7k🏛️ Memory System for AI Coding Tools - Never explain your codebase again. MCP server with perfect project isolation, 95.8% context accuracy, and the Four Pillars Framework.
Memu
★ 13.7kMemory for 24/7 proactive agents like OpenClaw.
MemOS
★ 9.3kMemOS (Memory Operating System) is a memory management operating system designed for AI applications. Its goal is: to enable your AI system to have long-term memory like a human, not only remembering what users have said but also actively invoking, u
Everos
★ 5.4kBuild, evaluate, and integrate long-term memory for self-evolving agents.
Cipher
★ 4.8kCipher is an opensource memory layer specifically designed for coding agents. Compatible with Cursor, Windsurf, Claude Desktop, Claude Code, Gemini CLI, AWS's Kiro, VS Code, and Roo Code through MCP, and coding agents, such as Kimi K2.
Browse More Knowledge & Memory MCP Servers
Explore all knowledge & memory servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Context Mode in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Context Mode?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.