Free · Elastic License 2.0 · runs on your machine

Context Mode Engine: keep raw tool output out of your agent's context window.

Context Mode Engine is the free context-mode plugin, under the Elastic License 2.0. It runs on your machine, in 18 AI coding tools, with no account, and keeps raw tool output in a local sandbox and index so only the answer enters the context.

98%
less tool output across 14 benchmark scenarios
24,230
GitHub stars, read 2026-09-30
580,024
npm downloads since 2026-02-23, read 2026-09-30
18
AI coding tools

Key facts

What it is
The free context-mode MCP plugin: a sandbox and a local FTS5 index that keep raw tool output out of the context window.
Who it is for
Developers who want a free tool that runs on their own machine, with no account.
Clients
18 AI coding tools.
Measured result
Cost is not measured. Across 14 data-processing scenarios in the plugin's own benchmark suite, 315 KB of raw output became 5.5 KB.
Limits
It works on one machine, inside the agent it runs in. Checking tool calls, one memory for two clients and per-request cost are Context Mode Gateway features.

One command's output, paid for on every turn.

Claude Code, Cursor, Copilot, Codex and Gemini CLI all work the same way. Every file read, command output and search result stays in the conversation, and the whole conversation goes back to the model on each turn. Run gh issue list once and 59 KB of JSON comes back. Fifty turns later you have paid for it fifty times.

When the window fills, the agent compacts: it summarises the conversation and drops the originals. The files it was editing and the errors it fixed go with them.

playwright56.2 KB for one snapshot
20 gh issues58.9 KB of JSON
access log45.1 KB for 500 requests
14 scenarios315 KB of raw tool output

Raw data stays in a sandbox. The agent gets the answer.

context-mode is an MCP server that sits between your agent and its tools. When a call would dump large output into the conversation, it runs in a sandboxed subprocess instead, and only what the script prints comes back. The full output goes into a local SQLite FTS5 database with BM25 ranking, and the agent searches it with ctx_search when it needs a detail.

In tools with hook support, the plugin hooks into the session lifecycle:

HookWhat it does
PreToolUseRoutes tool calls to the sandbox and blocks raw curl and wget
PostToolUseRecords file edits, git operations, errors and decisions
UserPromptSubmitRecords your corrections and the mode of the session
PreCompactBuilds a snapshot just before the window is compacted
SessionStartRestores that snapshot after a compaction or a resume
StopRecords where each turn ended

Tools without hooks use a routing file (AGENTS.md or GEMINI.md) instead.


Measured

What the model read, with and without the plugin.

The same calls, measured on raw output and on what entered the context. Across 14 data-processing scenarios, 315 KB of raw output became 5.5 KB.

Playwright snapshot99%56.2 KB became 299 B
GitHub issues (20)98%58.9 KB became 1.1 KB
Access log (500 requests)100%45.1 KB became 155 B
14 scenarios98%315 KB became 5.5 KB

Measured by the plugin's own benchmark suite. All 21 scenarios on GitHub →


The agent writes a script. Only its output enters the context.

To count lines in 47 files, an agent would call Read 47 times and keep every file in the conversation. With Think in Code it writes one short script, the sandbox runs it, and only the answer comes back.

// Before: 47 Read() calls, and every file stays in context
// After:  one ctx_execute() call, and only the line counts enter context
ctx_execute("javascript", `
  const files = fs.readdirSync('src').filter(f => f.endsWith('.ts'));
  files.forEach(f => console.log(f + ': ' +
    fs.readFileSync('src/' + f, 'utf8').split('\n').length + ' lines'));
`);

The same idea runs on the gateway too: Thinking in Code →


Your agent does not start from scratch.

The plugin writes each meaningful event to a local database. When the conversation compacts, or you resume with --continue or /resume, it rebuilds your working state and the model continues from your last prompt.

worktasks, plans, files modified, git operations
decisionsyour corrections, rejected approaches, constraints, blockers
errorsopen errors, and each error with the fix that closed it
setupproject rules, working directory, worktrees, tools and skills used

Adapters

18 AI coding tools, one plugin.

Tools with hooks get automatic routing. The rest get a routing file that tells the model to use the sandbox. Each tool's steps are in the README.

ToolHow context-mode plugs in
Claude CodePlugin marketplace, hooks and slash commands
Codex CLIMCP and hooks
CursorHooks, with stop support
VS Code CopilotHooks, with SessionStart
JetBrains CopilotHooks, with SessionStart
GitHub Copilot CLIMCP and hooks
Gemini CLIOne config file, hooks included
Qwen CodeMCP and hooks
Kimi CodeMCP and hooks
KiroHooks, with a steering file
OpenCodeTypeScript plugin with hooks
KiloCodeTypeScript plugin with hooks
OpenClawNative plugin for Pi Agent sessions
Pi Coding AgentExtension with full hook support
OMP (Oh My Pi)Plugin with full hook support
Antigravity CLI (agy)Plugin: MCP, skill and hooks
Antigravity IDEMCP only, with a routing file
ZedMCP only, with a routing file

Your code, prompts and sessions stay on your disk.

local by defaultthe databases live in your home directory. Nothing is sent anywhere unless you connect Insight.
with Insightonly when ~/.context-mode/platform.json holds an Insight key. Then the plugin sends each session event: tool name, file path, command type, exit code, and the first 200 characters of the event's text, which includes the start of each prompt. Secrets, e-mail addresses and your home folder name are masked first (platform-bridge.mjs). Delete the file to stop.
your rulesdeny rules you set for Bash and Read also apply inside the sandbox
credentialsgh, aws, gcloud, kubectl and docker work without their secrets entering the conversation
licenseElastic License 2.0, source on GitHub: use, fork, modify and share it; do not resell it as a hosted service

Install

Two commands in Claude Code.

No account and no token. Install the plugin, restart your tool, and routing starts on the next tool call.

Claude Code

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

Restart Claude Code or run /reload-plugins, then check the install with /context-mode:ctx-doctor.

Claude Code, MCP tools only

claude mcp add context-mode -- npx -y context-mode

Codex CLI

codex plugin marketplace add mksglu/context-mode

Then install it from Codex's plugin screen and turn on plugin_hooks, as the README shows.

Every other tool

npm install -g context-mode

Then add the config for your tool from the install guide. Needs Node.js 22.5 or later, or Bun.


Thank you for building it with us.

context-mode reached #1 on Hacker News and has 24,230 stars on GitHub (read 2026-09-30). 111 people have contributed code, and many more have filed issues, tested adapters and shared fixes. Every adapter on this page exists because someone asked for it or wrote it.

Context Mode Engine stays free and runs on your machine. It keeps tool output out of one agent's context window, on one machine, in 18 tools. Context Mode Gateway, our main product, is a different layer: it sits on the request path for Claude Code and Codex, lowers the cost of each request, and adds Cage, Memory, Skills, Search and session resume across machines and both clients. For teams, Context Mode Insight reads the plugin's events and shows how the team works with coding agents.


FAQ

Is Context Mode Engine free?

Yes, under the Elastic License 2.0, with no account.

How is it different from Context Mode Gateway?

The Engine runs on your machine and keeps tool output out of one agent's context window. The Gateway sits on the request path of Claude Code and Codex, lowers the cost of each request and enforces your rules.

Does my code leave my machine?

No. Your code, prompts and sessions stay on your disk, unless you connect Insight, which receives masked events.

Keep raw data out of context.

/plugin marketplace add mksglu/context-mode in Claude Code, or npm install -g context-mode for every other tool.