Context Mode logo

Context Mode

Reduces coding-agent context usage by sandboxing tool output, indexing session events, and routing work through executable code.

Install Context Mode

Pick your client, then add it in one click or paste the config.

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "context-mode": {
      "command": "npx",
      "args": [
        "-y",
        "context-mode"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

We couldn’t confirm it starts correctly

The install command didn't complete successfully in our automated test.

npx -y context-mode

g: https://github.com/nodejs/node/issues/62515 npm ERR! https://github.com/mksglu/context-mode/issues/564 npm ERR! npm ERR! Fix: upgrade Node (recommended) npm ERR! nvm install 22.5 && nvm use 22.5 npm ERR! npm install -g context-mode npm ERR! npm ERR! Or: run under Bun npm ERR! curl -fsSL https://bun.sh/install | bash npm ERR! bun add -g context-mode npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2026-10-23T11_33_07_972Z-debug-0.log

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked 16d ago.

Overview

The context-mode MCP server reduces context usage for AI coding agents by keeping large tool results outside the conversation and returning concise outputs. It provides sandbox execution, indexing, search, session statistics, diagnostics, and related maintenance tools through MCP. Session events are stored in SQLite and searched with FTS5 and BM25 so relevant state can be recovered after compaction. Reach for it when large codebase reads, logs, snapshots, or repeated tool calls are consuming the agent's context window.

Use cases

  • Process large codebases without loading every file into context
  • Recover relevant session state after conversation compaction
  • Index local files for later full-text search
  • Inspect context savings and diagnose installation issues

Key features

  • Sandboxed JavaScript and file execution
  • Batch processing for tool-driven tasks
  • SQLite session persistence with FTS5 and BM25 search
  • Local content indexing and retrieval
  • Context savings statistics and diagnostics
  • Hook-based routing for supported clients

Tools9

What Context Mode lets your agent do. Expand a tool for its parameters.

Self-reported~157 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked Today

Recent health check succeeded.

28/28 checks healthy over the last 18d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 2d ago via OSV.dev · context-mode (npm)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars33kStargazers on the source repository.
npm downloads142kPackage downloads in the last 30 days.
Last commitTodayMost recent push to the default branch.
Install checkInconclusiveInstall command did not finish in our automated test.
Tools exposed9Callable tools this server registers over MCP.
Directory activity16 viewsConfig copies, upvotes, and views on AllMCPs.

How Context Mode works

What the context-mode MCP server does

The context-mode MCP server is designed for coding sessions where tool output consumes too much of the model's context. Rather than placing every raw result in the conversation, it provides tools that execute code, process data, index content, and return selected results.

It also preserves session state. File edits, Git operations, tasks, errors, and user decisions are recorded in a SQLite database. When a conversation is compacted, the stored events are not all reinserted into the prompt. Relevant information can instead be located through full-text search.

The system does not enforce a particular style for the model's final response. Its routing guidance concerns where data should be processed, not whether the agent should be brief, verbose, or formatted in a specific way.

How it works

The context-mode MCP server exposes sandbox tools for running JavaScript, running a script file, processing batches, indexing local content, searching indexed material, and fetching and indexing content. A coding agent can use these operations to calculate results close to the data instead of reading many files into the conversation. For example, a script can count lines across a directory and print only the totals.

Indexed session information uses SQLite with FTS5. Search uses BM25 ranking to retrieve relevant events rather than restoring the entire prior session. A continued session can therefore recover selected context after compaction.

Routing is enforced through hooks on supported hook-capable platforms. The project describes this routing and code-oriented workflow as applying across its supported clients, as well as through an OpenClaw gateway integration.

Setup and configuration

Claude Code can install the project through its plugin marketplace. The documented flow is to add the mksglu/context-mode marketplace, install the context-mode@context-mode plugin, and restart Claude Code or reload plugins. Claude Code version 1.0.33 or newer is required.

The Claude Code plugin registers hooks for session start, tool use, prompts, compaction, and stopping. Its session-start hook supplies routing instructions at runtime rather than writing a routing file into the project. The plugin also registers the MCP tools and provides a diagnostic command that checks runtimes, hooks, FTS5, and plugin registration.

Tools and capabilities

The documented Claude Code installation includes 11 MCP tools:

  • ctx_batch_execute, ctx_execute, and ctx_execute_file for sandboxed computation.
  • ctx_index, ctx_search, and ctx_fetch_and_index for building and querying the local knowledge base.
  • ctx_stats for context-use and savings information.
  • ctx_doctor for diagnostics.
  • ctx_upgrade for updating and repairing the installation.
  • ctx_purge for permanently removing indexed content.
  • ctx_insight for opening the hosted Insight dashboard in a browser.

The same functions can be reached through Claude Code slash commands.

Limitations and notes

This tool changes how data is routed and processed; it does not guarantee a fixed reduction for every workload. Agents still need to use the sandbox and indexing tools appropriately. The project also does not replace a model's response-style instructions. Indexed content can be permanently removed with ctx_purge, and sessions that are not continued lose their previous stored data according to the documented behavior.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Context Mode

context-mode is an MCP server that connects AI coding agents to sandboxed execution, local content indexing, and persistent session search. Its main tools include ctx_execute, ctx_batch_execute, ctx_execute_file, ctx_index, ctx_search, and ctx_fetch_and_index, which keep large results out of the conversation and retrieve relevant stored information when needed.

Install it in Claude Code through the plugin marketplace by adding `mksglu/context-mode`, installing `context-mode@context-mode`, and restarting or reloading plugins. Claude Code 1.0.33 or newer is required.

Yes, Cursor is named as a supported platform.

It stores file edits, Git operations, tasks, errors, and user decisions in SQLite, then indexes them with FTS5 and retrieves relevant entries using BM25 search. Continued sessions can recover selected information after compaction instead of restoring the entire history.

Use `ctx_stats` to inspect context usage, per-tool details, and savings, and use `ctx_doctor` to check runtimes, hooks, FTS5, versions, and plugin registration. Claude Code also exposes these functions as `/context-mode:ctx-stats` and `/context-mode:ctx-doctor`.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewContext Mode AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/context-mode?style=directory)](https://allmcps.com/mcp/context-mode)
HTML Embed
<a href="https://allmcps.com/mcp/context-mode"><img src="https://allmcps.com/api/badge/context-mode?style=directory" alt="Context Mode on AllMCPs" /></a>