
context-mode
by mksglu·★ 14,865·Score 62
MCP server that optimizes context windows for AI agents by sandboxing tool output with 98% reduction.
Overview
Context Mode is an MCP server designed to solve the context window optimization problem for AI coding agents. It provides four key solutions: context saving by sandboxing tools to keep raw data out of the context window (98% reduction), session continuity through tracking all operations in SQLite and retrieving only relevant information when needed, 'think in code' approach that encourages LLMs to write scripts rather than processing large data directly, and flexible output style that doesn't enforce prose-style responses. The project supports 15 platforms and has been adopted by major tech companies like Microsoft, Google, Meta, and Amazon.
Try asking AI
After installing, here are 6 things you can ask your AI assistant:
When to choose this
Choose Context Mode when working with large codebases or long coding sessions where context overflow is a bottleneck, and especially when using supported platforms like Claude Code or Gemini CLI.
When NOT to choose this
Avoid if you need full raw tool outputs in your context, or if you're using an unsupported platform that requires manual implementation of all routing logic.
Tools this server exposes
11 tools extracted from the READMEctx_batch_executeExecutes multiple code snippets in a batch
ctx_executeExecutes code in the specified language and returns results
ctx_execute_fileExecutes a code file and returns the results
ctx_indexIndexes content for later retrieval
ctx_searchSearches indexed content using BM25
ctx_fetch_and_indexFetches content from a source and indexes it
ctx_statsShows context savings and usage statistics
ctx_doctorRuns diagnostic checks on the system
ctx_upgradeUpgrades context-mode to the latest version
ctx_purgeDeletes all indexed content from the knowledge base
ctx_insightOpens personal analytics dashboard
Comparable tools
Installation
Installation
Claude Code
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-modeGemini CLI
npm install -g context-modeAdd to ~/.gemini/settings.json:
{
"mcpServers": {
"context-mode": {
"command": "context-mode"
}
},
"hooks": {
"BeforeTool": [{
"matcher": "run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli beforetool" }]
}],
"AfterTool": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli aftertool" }]
}],
"PreCompress": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli precompress" }]
}],
"SessionStart": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli sessionstart" }]
}]
}
}Manual MCP (for Claude Desktop)
{
"mcpServers": {
"context-mode": {
"command": "npx",
"args": ["-y", "context-mode"]
}
}
}FAQ
- How does Context Mode reduce context usage?
- Context Mode reduces context usage by 98% through sandboxing tool outputs. Instead of putting raw data into the context window, it stores the data in SQLite and only indexes it, allowing the model to retrieve relevant information when needed.
- Is Context Mode compatible with my favorite AI coding platform?
- Yes, Context Mode supports 15 platforms including Claude Code, Gemini CLI, VS Code Copilot, Cursor, and others. It provides specific installation instructions for each platform.
Compare context-mode with
Last updated · Auto-generated from public README + GitHub signals.