Context Mode
VerifiedContext window optimization for AI coding agents with 98% reduction.
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 -y context-modeTools it exposes
1 tool your AI client can call once connected.
ctx_execute— Executes code in a sandboxed environment and returns only the result to minimize context usage.Example prompts
Once connected, try asking your AI client:
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
- 1Install the context-mode package from npm.
- 2Configure the MCP server in your AI client using stdio transport.
- 3Start a new session; previous data is deleted unless --continue is passed.
- 4Use ctx_execute for data analysis tasks instead of direct tool output.
- 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.
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…