Context Mode MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add context-mode -- npx -y context-mode
README.md

The other half of the context problem.

Context Mode

The other half of the context problem.

Privacy & Architecture

Context Mode is not a CLI output filter or a cloud analytics dashboard. It operates at the MCP protocol layer — raw data stays in a sandboxed subprocess and never enters your context window. Web pages, API responses, file analysis, Playwright snapshots, log files — everything is processed in complete isolation.

Nothing leaves your machine. No telemetry, no cloud sync, no usage tracking, no account required. Your code, your prompts, your session data — all local. The SQLite databases live in your home directory and die when you're done.

This is a deliberate architectural choice, not a missing feature. Context optimization should happen at the source, not in a dashboard behind a per-seat subscription. Privacy-first is our philosophy — and every design decision follows from it. License →

The Problem

Every MCP tool call dumps raw data into your context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. One access log — 45 KB. After 30 minutes, 40% of your context is gone. And when the agent compacts the conversation to free space, it forgets which files it was editing, what tasks are in progress, and what you last asked for.

Context Mode is an MCP server that solves both halves of this problem:

  1. Context Saving — Sandbox tools keep raw data out of the context window. 315 KB becomes 5.4 KB. 98% reduction.
  2. Session Continuity — Every file edit, git operation, task, error, and user decision is tracked in SQLite. When the conversation compacts, context-mode doesn't dump this data back into context — it indexes events into FTS5 and retrieves only what's relevant via BM25 search. The model picks up exactly where you left off. If you don't --continue, previous session data is deleted immediately — a fresh session means a clean slate.

https://github.com/user-attachments/assets/07013dbf-07c0-4ef1-974a-33ea1207637b

Install

Platforms are grouped by install complexity. Hook-capable platforms get automatic routing enforcement. Non-hook platforms need a one-time routing file copy.

Claude Code — plugin marketplace, fully automatic

Prerequisites: Claude Code v1.0.33+ (claude --version). If /plugin is not recognized, update first: brew upgrade claude-code or npm update -g @anthropic-ai/claude-code.

Install:

/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode

Restart Claude Code (or run /reload-plugins).

Verify:

/context-mode:ctx-doctor

All checks should show [x]. The doctor validates runtimes, hooks, FTS5, and plugin registration.

Routing: Automatic. The SessionStart hook injects routing instructions at runtime — no file is written to your project. The plugin registers all hooks (PreToolUse, PostToolUse, PreCompact, SessionStart) and 6 sandbox tools (ctx_batch_execute, ctx_execute, ctx_execute_file, ctx_index, ctx_search, ctx_fetch_and_index).

Slash Command What it does
/context-mode:ctx-stats Context savings — per-tool breakdown, tokens consumed, savings ratio.
/context-mode:ctx-doctor Diagnostics — runtimes, hooks, FTS5, plugin registration, versions.
/context-mode:ctx-upgrade Pull latest, rebuild, migrate cache, fix hooks.

Note: Slash commands are a Claude Code plugin feature. On other platforms, type ctx stats, ctx doctor, or ctx upgrade in the chat — the model calls the MCP tool automatically. See Utility Commands.

Tools (6)

ctx_batch_executeExecutes multiple commands in a sandboxed environment while keeping output out of the context window.
ctx_executeExecutes a single command in a sandboxed environment.
ctx_execute_fileExecutes a file in a sandboxed environment.
ctx_indexIndexes data into the local SQLite database for future retrieval.
ctx_searchPerforms a BM25 search against indexed session data.
ctx_fetch_and_indexFetches external data and indexes it immediately.

Configuration

claude_desktop_config.json
{"mcpServers": {"context-mode": {"command": "npx", "args": ["-y", "context-mode"]}}}

Try it

Use ctx_execute to run my test suite and summarize only the failures.
Search my previous session logs using ctx_search to find where I last edited the authentication module.
Fetch the documentation from this URL and index it for my current project using ctx_fetch_and_index.
Run the build script and use ctx_index to store the output for later reference without cluttering the chat.
Show me my current context savings statistics using ctx_stats.

Frequently Asked Questions

What are the key features of Context Mode?

Reduces context window usage by intercepting and summarizing raw tool output.. Maintains session continuity by indexing events in a local SQLite database.. Operates in a sandboxed subprocess to ensure data privacy.. Provides BM25 search to retrieve only relevant historical session data.. Supports automatic routing enforcement for Claude Code..

What can I use Context Mode for?

Managing large log files or API responses without exhausting the LLM context window.. Maintaining long-term project state across multiple chat sessions.. Executing sandboxed code and scripts while keeping the chat interface clean.. Indexing documentation or external data sources for efficient retrieval during coding tasks..

How do I install Context Mode?

Install Context Mode by running: /plugin marketplace add mksglu/context-mode

What MCP clients work with Context Mode?

Context Mode works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Context Mode docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare