What Is Context Mode? Freeing Up a Coding Agent's Context Window: Setup, Tools, License
When your coding agent (such as Claude Code, Cursor or Codex) has to work with a large log, API response or page snapshot, Context Mode keeps the data in a subprocess and only the result enters the context window (the text the model can see at once); the raw data is stored in a local search index. It also records edited files, tasks and decisions, and brings back the relevant part when the conversation is compacted. By the maker's own measurement, savings reach 98%. The local version is free; its license is Elastic License 2.0: the source code is open but it isn't fully open source, and it can't be offered as a hosted service. The same company also runs a separate paid cloud service.
- What it does
- Keeps large tool output out of the agent's context
- Free
- Local version is free, no account
- License
- Elastic License 2.0: not fully open source
- Where
- Claude Code, Gemini CLI, VS Code Copilot, Cursor, Codex and others
- Requirements
- Node.js 22.5+ or Bun
- Data
- Stays local; leaves only if Insight is connected
- Version
- 1.0.169 (June 29, 2026)
What Is Context Mode For? What Problem Does It Solve?
When a coding agent calls a tool (a browser snapshot, a GitHub issue list, a log file), the entire output enters the context window. In the README's examples, a Playwright page snapshot takes 56 KB and 20 GitHub issues take 59 KB; after half an hour, 40% of the context is gone. When the context fills up, the agent compacts the conversation and forgets which file it was editing and which task was left half done. Context Mode targets both sides: keeping raw data out of the context and bringing back where it left off after compaction.
MCP is a common connection format that lets an assistant connect to a service outside itself or to a program on your computer. This server sits in the middle of that bridge: the assistant passes the request to it, it queries the target and brings the answer back.
Data stays local; it leaves only if Insight is connected.
The "think in code" principle: instead of the agent reading 50 files one by one to count them, the README recommends it write a small script that does the counting and prints only the result; Context Mode runs that script in a subprocess, and only what the script prints enters the context. It doesn't interfere with the style of the reply: writing short or long is up to the model and your instructions.
Who it helps: developers who work in long sessions with Claude Code, Codex or Cursor, deal with large logs and API output, and see the context fill up and get compacted often. In short conversations the difference is small.
The README's figures are the maker's own measurements: it states that in a full session 315 KB of raw output dropped to 5.4 KB and session length went from about 30 minutes to 3 hours; ~98% savings on platforms with hook support, ~60% on those without. No independent measurement is given in the official sources.
How Does Context Mode Work? Sandbox, Index and Session Log
Each ctx_execute call opens a separate subprocess with its own process boundary; 12 languages run (JavaScript, TypeScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir, C#). If the output exceeds 5 KB and an intent was given, the full output is indexed and only the matching sections return to the context.
Markdown content is split by headings and written to an SQLite FTS5 table; search uses BM25 ranking, stemming and partial matching, and typos are corrected. Web pages are cached for 24 hours; content older than 14 days is deleted at startup.
File edits, git operations, tasks, errors and decisions are kept in a per-project SQLite database. When the conversation is compacted, or when you return with --continue, --resume or /resume, the relevant part is restored by search. If you don't use --continue, the previous session's data is deleted right away.
What Tools Does Context Mode Add?
| MCP tool | What it does (README) |
|---|---|
ctx_execute | Runs code in 12 languages; only standard output (stdout) enters the context |
ctx_execute_file | Processes a file in the sandbox; the raw content doesn't enter the context. It can't go outside the project folder |
ctx_batch_execute | Runs several commands and searches in a single call |
ctx_index | Splits Markdown content into chunks and writes it to the local search index |
ctx_search | Searches the index with several queries and returns the matching chunk |
ctx_fetch_and_index | Fetches a web address, converts it to Markdown and indexes it (24-hour cache) |
ctx_stats, ctx_doctor, ctx_upgrade, ctx_purge, ctx_insight | Report, diagnostics, update, deleting the index, opening the Insight dashboard |
Search limit: within the same session, search calls 4–8 return fewer results and a warning, and after the 9th call you're redirected to ctx_batch_execute (README "Progressive Throttling").
How Do You Install Context Mode? Claude Code and Other Agents
› /plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-modeThen restart Claude Code or type /reload-plugins.
› /context-mode:ctx-doctorThe plugin registers all the hooks (PreToolUse, PostToolUse, UserPromptSubmit, PreCompact, SessionStart, Stop) and 11 MCP tools; the routing instructions are added at session start and no file is written to your project. Requires Claude Code v1.0.33+.
› claude mcp add context-mode -- npx -y context-mode@1.0.169This route gives you the 11 tools but no automatic routing: the model can use the tools, but it isn't pushed to prefer them over Bash/Read/WebFetch with large output. The README recommends it "for trying out".
The README writes the command without a version (npx -y context-mode); @1.0.169 is npm's version-pinning syntax. 2.0 pre-releases are also published on npm under the "next" tag; the stable version is 1.0.169.
› npm install -g context-mode@1.0.169Then you add the MCP server and (if supported) the hooks to the agent's settings file. For Gemini CLI it's a single ~/.gemini/settings.json; for VS Code Copilot and JetBrains Copilot, hooks.json + .github/copilot-instructions.md; for GitHub Copilot CLI, copilot plugin install mksglu/context-mode:configs/copilot-cli; the README has separate steps for Cursor, Codex CLI, OpenCode, Kiro, Zed and others. On a platform without hooks, you need to copy the instructions file (e.g. AGENTS.md, GEMINI.md) to the project root.
- Node.js 22.5 or later, or Bun. On Linux, if Node is older than 22.5 and Bun isn't present, the installation deliberately stops (because of a crash issue with the SQLite extension on older Node).
- What runs during installation: the npm package downloads its dependencies (including better-sqlite3) and runs an install script (postinstall); this script repairs the context-mode entries in Claude Code's
~/.claude/plugins/installed_plugins.jsonand~/.claude/settings.jsonfiles, and fixes paths on Windows. - Data folder: sessions and statistics are in the platform's default folder (e.g.
~/.claude/context-mode), the index under~/.context-mode/content/; change it withCONTEXT_MODE_DIR.
How Do You Use Context Mode? What You Type, What You Get
After installing, you work with your agent as usual; on a platform with hooks, calls with large output go to the sandbox automatically. The requests below come from the README's "Try It" section; the figures in parentheses are the maker's measurements, and the outputs are described as far as the README describes them.
What you get: instead of reading commits into the context one by one, the agent writes a script that counts them and runs it in the sandbox; only the summary table enters the context (README: one call, 5.6 KB of context). ctx stats shows, per tool, how many KB stayed out of the context.
What you get: the page is fetched with ctx_fetch_and_index, converted to Markdown and written to the local index; the raw page doesn't enter the context, and ctx_search returns only the matching chunks (README: 2 calls, 1.8 KB of context). If the same address is requested again within 24 hours, it isn't downloaded again.
What you get: according to the README, after more than 20 tool calls ctx stats shows the session's event count; when the context is compacted, the model restores tasks, files and decisions and continues from your last request, so you don't have to rewrite it.
| Type in the chat (any platform) | Claude Code command | What it does |
|---|---|---|
ctx stats | /context-mode:ctx-stats | Context savings, call counts, session report |
ctx doctor | /context-mode:ctx-doctor | Checks the runtime, hooks, FTS5 and version |
ctx index | /context-mode:ctx-index | Indexes a local file or folder |
ctx search | /context-mode:ctx-search | Searches the index |
ctx upgrade | /context-mode:ctx-upgrade | Updates to the latest version from GitHub and repairs the hooks |
ctx purge | /context-mode:ctx-purge | Permanently deletes all content in the index |
ctx insight | /context-mode:ctx-insight | Opens the hosted Insight dashboard in the browser (separate service) |
The same commands also have terminal equivalents: context-mode doctor, context-mode index . --source project:my-app, context-mode search "…". In Claude Code, an optional status line shows the savings in the session ("statusLine": {"type": "command", "command": "context-mode statusline"} in ~/.claude/settings.json).
Which Agents Does Context Mode Work With?
| Claude CodeYes | Plugin marketplace, all hooks and slash commands; the most complete support according to the README. |
|---|---|
| Gemini CLIYes | MCP and four hooks in a single settings file. |
| VS Code (Copilot)Yes | Hooks and SessionStart with VS Code Copilot Chat v0.32+. |
| CursorYes | Hooks (preToolUse, postToolUse, sessionStart, stop); the README says it will install in one click once it's listed on the Cursor Marketplace. |
| Codex CLIPartly | The MCP tools work; hooks require [features].hooks = true, and modifying tool input isn't supported yet. |
| Antigravity, ZedPartly | No hooks; routing only through an instructions file (README: ~60% savings, the maker's measurement). |
The README's table lists 17 clients and the OpenClaw gateway: Claude Code, Qwen Code, Gemini CLI, VS Code Copilot, JetBrains Copilot, GitHub Copilot CLI, Cursor, OpenCode, KiloCode, OpenClaw, Codex CLI, Kimi Code, Antigravity, Antigravity CLI, Kiro, Zed, Pi and OMP. The site's Engine page says "18 AI coding tools".
What Does Context Mode Do With My Data? Is It Safe?
README: no telemetry, cloud sync, usage tracking or account; code, prompts and session data stay in SQLite files in your home folder. Before being stored, fields such as tokens, passwords, API keys and cookies in MCP tool inputs are masked with [REDACTED].
ctx_fetch_and_index fetches web addresses (cloud metadata addresses are always blocked; local network addresses are allowed by default, CTX_FETCH_STRICT=1 turns them off). According to the site's privacy page, if you connect Insight, Engine events go to the company's Insight service; if you don't, they stay local.
ctx_execute and ctx_batch_execute run any code the agent writes and inherit the process's file access; credentials for tools such as gh, aws and gcloud carry over. README: approving an execution tool means approving arbitrary code execution.
!Context Mode is not an operating-system sandbox: approving the execution tool means approving that the code the agent writes runs with your file access.
Context Mode also applies Claude Code's permission rules to its own tools (e.g. if Bash(sudo *) is denied, it's denied in the sandbox too).
Is Context Mode Open Source? What Does Elastic License 2.0 Mean?
Context Mode's license is Elastic License 2.0 (ELv2). The source code is public and readable, but this license isn't a full open source license: the README itself says "source-available". The main difference: you can't offer the software to others as a hosted or managed service, and you can't remove the license notices. Because GitHub doesn't show this license in its recognized list, the license appears as "Other" on the repository page.
- Use, copy, distribute and make available (free of charge, worldwide)
- Modify and prepare derivative works (adding a notice that you changed it)
- Use it in your own business, company and projects without paying
- Provide the software to third parties as a hosted or managed service that gives access to a substantial part of its features
- Move, change, disable or circumvent the license key functionality
- Remove or obscure license, copyright and other notices; anyone you give a copy to must also receive the license text
Summary based on the Elastic License 2.0 text in the LICENSE file; not legal advice. If you violate the license, your rights end automatically; they come back if you stop the violation within 30 days of receiving notice.
Is Context Mode Free? What Is the Paid Cloud Service?
The local version (the one this guide covers, called "Context Mode Engine" on the site) is free: it requires no account, card or sign-up. The same company (MKSF LTD, London) also sells a hosted Context Mode service: your agent's requests pass through the company's gateway, and your own Anthropic or OpenAI account pays the model costs.
- All the tools in this guide
- No account needed
- Data stays on your computer
- 1,000 requests per month
- No card required
- At the limit, features pause until the next month
- 10,000 requests per month ($200 per year)
- Extra 1,000 requests for $2, with a budget cap
- Refund of the unused portion within the first 14 days
- 50,000 requests per seat, shared pool
- Single invoice
- Minimum 2 seats
According to the pricing page, at the limit the agent keeps working and requests go directly to the model; only the features stop. Enterprise is by contract (100,000+ requests per month; the company's cloud, a dedicated server or your own Cloudflare account). There's no Turkish lira pricing; paying by card from Turkey is not clear in the official sources.
Official pricing page last checked on .
Common Problems and Fixes
| What's happening | What to do (README) |
|---|---|
/plugin isn't recognized | Claude Code is outdated: check with claude --version and update to 1.0.33+. |
| "context-mode: install aborted" on Linux | Install Node.js 22.5+ or Bun; the installation deliberately stops because the SQLite extension occasionally crashes on older Node. |
| Savings are lower than expected | The MCP-only install has no routing; use the plugin route in Claude Code, and on a platform without hooks copy the instructions file to the project root. |
| Problems with installation or hooks | /context-mode:ctx-doctor (or context-mode doctor); for an error log, the bash scripts/ctx-debug.sh report. |
| It can't process a file outside the project | ctx_execute_file is restricted to the project folder; to open it up deliberately, add a Read(...) rule for the same path under permissions.allow in the settings. |
How Do You Uninstall Context Mode and Delete Its Data?
- First delete the index (optional): Type
ctx purgein the chat or/context-mode:ctx-purge: all content in the index is permanently deleted. - Plugin: In Claude Code,
/plugin→ Installed → context-mode → Uninstall. - If you installed MCP only:
claude mcp remove context-mode(Claude Code's general command); for a global npm install,npm uninstall -g context-mode. - Leftover files: Remove the session and index folders (
CONTEXT_MODE_DIRor the default folder,~/.context-mode/) and, if you added it manually, the status line setting.
Frequently asked questions
What is Context Mode?
An MCP server that keeps the tool output that fills coding agents' context windows out of the context. Raw data stays in a subprocess and a local index, only the result enters the context, and when the conversation is compacted it also brings back where the agent left off.
How do I install Context Mode in Claude Code?
In a Claude Code session, type /plugin marketplace add mksglu/context-mode and /plugin install context-mode@context-mode, then /reload-plugins. You verify the installation with /context-mode:ctx-doctor. Node.js 22.5 or later is required.
Does Context Mode work with Codex and Cursor?
Yes. The README lists 17 clients; Cursor has hook support, and in Codex CLI the MCP tools work and hooks are turned on with a separate setting.
Is Context Mode free?
The local version is free and requires no account. The same company's hosted service is separate: its free plan includes 1,000 requests per month, and the Pro plan is $20 per month.
Is Context Mode open source?
The source code is open, but it isn't fully open source: its license is Elastic License 2.0. Using, modifying and distributing it are allowed; offering it as a hosted or managed service and removing the license notices are not.
Does my data go anywhere?
According to the README, the local version has no telemetry or cloud sync; data stays in SQLite files in your home folder. If you connect the Insight service, events go to the company's server.
Is the 98 percent savings real?
That figure is the maker's own measurement and is given for platforms with hook support; for platforms without hooks it states about 60 percent. No independent measurement is given in the official sources.
Related guides
Sources
- Context Mode GitHub repository (README)
- License (Elastic License 2.0)
- npm package
- Context Mode Engine page
- Context Mode pricing (hosted service)
- Context Mode privacy page
Not clear in the official sources: Independent measurement of the savings rates (only the maker's measurement exists) · what will change in version 2.0 ("next" pre-releases are being published on npm; the stable version is 1.0.169) · paying for the hosted service by card from Turkey · no Turkish interface (commands and documentation are in English). Each is covered in the relevant section.




