Skip to content
Context Mode logo

Context Mode

Verified

Context window optimization for AI coding agents with 98% reduction.

MCP ServerAI & KnowledgeLocal (stdio) 17.5k
View on GitHub
Updated 2026-06-15

What is the Context Mode MCP server?

Context Mode addresses context bloat from MCP tool calls by sandboxing outputs, reducing sizes like 315 KB to 5.4 KB. It tracks edits, tasks, and decisions in SQLite with FTS5/BM25 search for continuity across conversation compactions.

The server enforces a code-generation paradigm where agents write scripts for analysis rather than ingesting files. This applies across supported platforms and deletes prior session data unless --continue is used.

Install & connect

Add this to your MCP client config. Pick your client below and copy.

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

Package: context-mode (npm)

Other ways to install

npx

npx
npx -y context-mode

Tools it exposes

1 tool your AI client can call once connected.

ctx_executeExecutes code in a sandboxed environment and returns only the result to minimize context usage.
languagecode

Example prompts

Once connected, try asking your AI client:

Run ctx_execute to count functions across the current project without loading files into context
Optimize my next Playwright tool call to avoid dumping 50 KB snapshots
Retrieve relevant past edits from the session index after the conversation was compacted
Switch to code-generation mode so the agent writes analysis scripts instead of reading data

Security & permissions

Runs locally via stdio transport with no remote API keys required; stores session data in a local SQLite database.

What you can do with Context Mode

Reduce tool output size

Sandbox large Playwright snapshots or GitHub issue lists so only compact results reach the model.

Maintain session state

Index file edits and task progress for retrieval after context compaction without losing history.

Analyze code via scripts

Replace dozens of Read calls with a single ctx_execute that counts functions or searches files.

How to use Context Mode

  1. 1Install the context-mode package from npm.
  2. 2Configure the MCP server in your AI client using stdio transport.
  3. 3Start a new session; previous data is deleted unless --continue is passed.
  4. 4Use ctx_execute for data analysis tasks instead of direct tool output.
  5. 5Review indexed events via BM25 search when context is compacted.

Context Mode: pros & cons

Pros

  • +Dramatic context reduction (98%) keeps more room for actual work.
  • +Session continuity survives compaction without manual re-entry.
  • +Enforces efficient code-generation patterns across many platforms.
  • +Automatic cleanup of old sessions prevents data accumulation.

Cons

  • Requires changing agent behavior to write scripts rather than read data.
  • SQLite index adds local storage overhead.
  • Limited to platforms where the sandboxed execution is supported.
Did you find this helpful?

Frequently asked questions

Typical tool outputs drop from hundreds of KB to a few KB, achieving up to 98% reduction.

User reviews

Verified reviews from the community shape this listing's rating.

Loading reviews…

Sign in to review

Promote Context Mode

Add this badge to your website, or share the tool.

DFeatured on DhanasviContext Mode 2