claude-context-mode
Stop losing context to large outputs.
claude mcp add --transport stdio mksglu-claude-context-mode npx -y context-mode
How to use
Claude Context Mode is an MCP server that helps manage and optimize the context window by routing tool calls through sandboxed context-saving tools and indexing session events for continuity. When enabled, the server provides six sandbox tools that your model can invoke: ctx_batch_execute, ctx_execute, ctx_execute_file, ctx_index, ctx_search, and ctx_fetch_and_index. These tools are designed to offload raw data from your context and persist session state in SQLite, with an FTS5 index and BM25 search to retrieve only relevant information when you resume a conversation. The server also includes hooks and integration points (PreToolUse, PostToolUse, SessionStart, and similar workflows) to nudge the model to prefer sandboxed tools over raw commands, improving both efficiency and continuity across sessions.
How to install
Prerequisites:
- Node.js and npm installed on your machine
- Basic familiarity with MCP (Model Context Protocol) tooling
Installation steps:
- Ensure you have Node.js and npm installed. You can verify with:
node -v
npm -v
- Install the MCP server via npx (as recommended in the README):
npx -y context-mode
- If you prefer a direct MCP entry point, you can also install context-mode and run it as an MCP server:
npm install -g context-mode
Then register and run according to your MCP hosting environment (Claude’s MCP workflow can use the npx approach or an explicit server script).
- Verify the server is available in your MCP configuration as:
{
"mcpServers": {
"claude-context-mode": {
"command": "npx",
"args": ["-y", "context-mode"]
}
}
}
- Start or register the server in your Claude/MCP environment as needed and test with a simple tool invocation to confirm sandbox routing is active.
Additional notes
Tips and caveats:
- Context Mode relies on sandboxed tools to significantly reduce context pollution. If you don’t see improvements, ensure hooks are enabled and that the model is instructed to prefer sandboxed tools over raw commands.
- The MCP server tracks session data in SQLite and uses FTS5 indexing with BM25 search to retrieve relevant context on demand. If you experience performance issues, ensure the underlying storage is accessible and not blocked by permissions.
- The default tooling exposed by this server includes six sandbox tools: ctx_batch_execute, ctx_execute, ctx_execute_file, ctx_index, ctx_search, ctx_fetch_and_index. Use ctx_index and ctx_fetch_and_index to build and query the context index as sessions progress.
- For Claude users, there are built-in commands (ctx-stats, ctx-doctor, ctx-upgrade) to inspect and manage the MCP server. On other platforms, use equivalent tool commands if available.
- If you need to run without the optional hooks, you can use the MCP-only install path: claude mcp add context-mode -- npx -y context-mode. This provides the sandbox tools without automatic routing enhancements.
Related MCP Servers
everything-claude-code
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Cowork, and beyond.
claude-code
MCP Server connects with claude code local command.
claude-vigil
🏺 An MCP server for checkpointing and file recovery in Claude Code
create -kit
Scaffold a production-ready Model Context Protocol (MCP) server in seconds.
mcp -mysql
这是一款增强型MySQL MCP服务,专为 MySQL 数据库提供完善的只读访问能力。高性能的MCP服务能让大语言模型全面查看数据库结构,高效执行查询、分析,还具备更多高级特性。
mcp-tidy
CLI tool to visualize and manage MCP server configurations in Claude Code. List servers, analyze usage statistics, and clean up unused servers