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](https://context-mode.com/benchmarks/data/reach-2026-09-30.json)

18 AI coding tools

[Install the plugin →](#install) [View on GitHub](https://github.com/mksglu/context-mode)

## 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.

The problem

### Every turn sends it all again

The model has no memory between turns. The client sends the whole conversation each time.

## 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.

playwright 56.2 KB for one snapshot 20 gh issues 58.9 KB of JSON access log 45.1 KB for 500 requests 14 scenarios 315 KB of raw tool output

How it works

### Sandbox, index, search

An MCP server plus hooks in your coding tool.

## 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:

| Hook | What it does |
| --- | --- |
| PreToolUse | Routes tool calls to the sandbox and blocks raw curl and wget |
| PostToolUse | Records file edits, git operations, errors and decisions |
| UserPromptSubmit | Records your corrections and the mode of the session |
| PreCompact | Builds a snapshot just before the window is compacted |
| SessionStart | Restores that snapshot after a compaction or a resume |
| Stop | Records 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 snapshot 99% 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 scenarios 98% 315 KB became 5.5 KB

Measured by the plugin's own benchmark suite. [All 21 scenarios on GitHub →](https://github.com/mksglu/context-mode/blob/main/BENCHMARK.md)

Think in Code

### Write the script, not the reading

12 languages, from JavaScript and Python to Go and Rust.

## 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 →](https://context-mode.com/thinking-in-code)

Session continuity

### Compaction keeps your place

Stored per project, in SQLite on your disk.

## 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.

work tasks, plans, files modified, git operations decisions your corrections, rejected approaches, constraints, blockers errors open errors, and each error with the fix that closed it setup project 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](https://github.com/mksglu/context-mode#install).

| Tool | How context-mode plugs in |
| --- | --- |
| **Claude Code** | Plugin marketplace, hooks and slash commands |
| **Codex CLI** | MCP and hooks |
| **Cursor** | Hooks, with stop support |
| **VS Code Copilot** | Hooks, with SessionStart |
| **JetBrains Copilot** | Hooks, with SessionStart |
| **GitHub Copilot CLI** | MCP and hooks |
| **Gemini CLI** | One config file, hooks included |
| **Qwen Code** | MCP and hooks |
| **Kimi Code** | MCP and hooks |
| **Kiro** | Hooks, with a steering file |
| **OpenCode** | TypeScript plugin with hooks |
| **KiloCode** | TypeScript plugin with hooks |
| **OpenClaw** | Native plugin for Pi Agent sessions |
| **Pi Coding Agent** | Extension with full hook support |
| **OMP (Oh My Pi)** | Plugin with full hook support |
| **Antigravity CLI (agy)** | Plugin: MCP, skill and hooks |
| **Antigravity IDE** | MCP only, with a routing file |
| **Zed** | MCP only, with a routing file |

Privacy

### Nothing leaves your machine unless you connect Insight

No account and no cloud sync by default.

## Your code, prompts and sessions *stay on your disk.*

local by default the databases live in your home directory. Nothing is sent anywhere unless you connect [Insight](https://context-mode.com/insight).

with Insight only 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](https://github.com/mksglu/context-mode/blob/main/hooks/platform-bridge.mjs)). Delete the file to stop.

your rules deny rules you set for Bash and Read also apply inside the sandbox

credentials gh, aws, gcloud, kubectl and docker work without their secrets entering the conversation

license Elastic 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](https://github.com/mksglu/context-mode#install). Needs Node.js 22.5 or later, or Bun.

Community

### Built in the open

[Join the Discord →](https://discord.gg/DCN9jUgN5v)

## 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](https://context-mode.com/docs), 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](https://context-mode.com/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](https://context-mode.com/docs) 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](https://context-mode.com/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.

[Install from GitHub →](https://github.com/mksglu/context-mode#install) [Try the gateway →](https://context-mode.com/docs/quick-start)
