Context Mode
BLOCKgrade F · trust 37/100Context window optimization for AI coding agents. Sandboxes tool output (98% reduction), persists session memory, and enforces routing across 17 platforms via MCP + hooks.
antigravityclaudeclaude codeclaude code hooksclaude code pluginsclaude code skillcodexcodex cliOverview
From the repository's own README, as read at the audited commit.
# context-mode> Save 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and native Cursor v1.7+ hook routing for context protection.## What it doescontext-mode is an MCP server + hook bundle that keeps long-running Cursor agent sessions from blowing through their context window. Three pillars:- **Sandboxed execution** — `ctx_execute`, `ctx_execute_file`, `ctx_batch_execute` run code in 11 languages (Node, Python, Bun, Deno, Ruby, Go, Rust, Java, C, C++, Shell). Only `stdout` enters the agent's context, so analysing huge files no longer floods the window.- **FTS5 knowledge base** — `ctx_index`, `ctx_search`, `ctx_fetch_and_index` store research, command output, and web content in SQLite FTS5 with BM25 ranking. The agent searches its own memory instead of re-reading files.- **Native Cursor hooks** — registers `preToolUse`, `postToolUse`, `sessionStart`, `afterAgentResponse`, and `stop` so context-mode can intercept Shell / Read / Grep / WebFetch and redirect them to the sandbox before they pollute context.## InstallAfter clicking **Install** in the Cursor Plugins panel, the plugin registers an MCP server that runs `npx -y context-mode`. The first invocation downloads the package from npm; subsequent invocations are cached.If you prefer pinning a global install (faster cold start):```bashnpm i -g context-mode```The plugin manifest will pick up the global binary automatically.## Try it locally before Marketplace acceptanceWhile the plugin is awaiting Marketplace review, you can install itdirectly from the repo. Cursor does **not** follow Windowssymlinks/junctions for plugin folders, so use a mirror copy on Windowsand a symlink elsewhere.**Windows (PowerShell):**```powershellgit clone https://github.com/mksglu/context-mode.gitcd context-moderobocopy . "$env:USERPROFILE\.cursor\plugins\local\context-mode" /MIR ` /XD node_modules .git build insight web tests scripts .vscode ` /XF *.log .gitignore *.bundle.mjs.map`
Connect
Built from this server's own package name, version and transport as found in its source — not copied from anyone's documentation, so it cannot drift against a page we do not control. Replace the environment placeholders with a token scoped to the least it needs.
claude mcp add og --env CLAUDE_CODE_MAX_OUTPUT_TOKENS=${CLAUDE_CODE_MAX_OUTPUT_TOKENS} --env JWT_SECRET=${JWT_SECRET} --env MY_CUSTOM_API_KEY=${MY_CUSTOM_API_KEY} --env PI_CONTEXT_MODE_PRICE_OUTPUT_PER_TOKEN=${PI_CONTEXT_MODE_PRICE_OUTPUT_PER_TOKEN} -- npx -y [email protected]{
"mcpServers": {
"og": {
"command": "npx",
"args": [
"-y",
"[email protected]"
],
"env": {
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "${CLAUDE_CODE_MAX_OUTPUT_TOKENS}",
"JWT_SECRET": "${JWT_SECRET}",
"MY_CUSTOM_API_KEY": "${MY_CUSTOM_API_KEY}",
"PI_CONTEXT_MODE_PRICE_OUTPUT_PER_TOKEN": "${PI_CONTEXT_MODE_PRICE_OUTPUT_PER_TOKEN}"
}
}
}
}Exposed tools (18) 10 read · 6 write · 2 destructive
Blast radius: 2 tools can delete or overwrite. An agent that can be talked into calling a tool can be talked into calling this one.
| Tool | Risk | Description |
|---|---|---|
context-mode.session-new | read | Session initialization — cleans up old sessions on /new command |
context-mode.session-reset | destructive | Session cleanup on /reset command |
context-mode.session-stop | write | Session cleanup on /stop command |
ctx-doctor | write | Run context-mode diagnostics |
ctx-stats | read | Show context-mode session statistics |
ctx-upgrade | read | Upgrade context-mode to the latest version |
ctx_batch_execute | write | Run multiple commands and search queries in ONE call. Primary research tool — replaces 30+ individual calls. |
ctx_doctor | write | Run context-mode diagnostics — runtimes, hooks, FTS5, plugin registration. |
ctx_execute | write | Execute code in a sandboxed subprocess. Only stdout enters context. Prefer over Bash for any command producing >20 lines. |
ctx_execute_file | write | Execute code with a file path. Only printed summary enters context — raw file stays in sandbox. |
ctx_fetch_and_index | read | Fetch a URL, chunk it, and index — raw HTML never enters context. |
ctx_index | read | Store content in the FTS5 knowledge base for later search. |
ctx_insight | read | Open the hosted context-mode Insight dashboard (context-mode.com/insight) in the browser. |
ctx_purge | destructive | DESTRUCTIVE — permanently delete indexed content. CANNOT be undone.\n\n |
ctx_search | read | Query indexed content via FTS5. Pass all questions as an array in ONE call. |
ctx_stats | read | Show context-mode session statistics — token consumption and per-tool breakdown. |
ctx_upgrade | read | Upgrade context-mode to the latest version. |
ping | read | p |
Details
- Source
- mksglu/context-mode
- npm
og@1.0.0- Transports
- stdio
- Credentials it reads
CLAUDE_CODE_MAX_OUTPUT_TOKENSJWT_SECRETMY_CUSTOM_API_KEYPI_CONTEXT_MODE_PRICE_OUTPUT_PER_TOKENSLACK_BOT_TOKENSSH_AUTH_SOCK- License
- NOASSERTION
- Stars
- 23,423 · pushed 0d ago
Trust audit
Do not install this without reading the findings. The audit found something that could harm you or your machine.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | FAIL |
| L1 | Static analysis of the code | FAIL |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | WARN |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- declared (11 observation(s))
- Network
- declared (6 observation(s))
- Shell
- declared (10 observation(s))
- Dependencies
- not all pinned
- Secrets in source
- none-found
Findings (25)
atob( ... /exec(
payload.mjs
const displayName = exec(
exec(sql: string): any {exec(sql: string): any {/exec(?:Sync|File|FileSync)?\(\s*(['"`])(.*?)\1/g,
/exec(?:Sync|File|FileSync)?\(\s*(['"`])(.*?)\1/g,
if (a === 169 && b === 254) return "block"; // link-local incl. 169.254.169.254 (IMDS)
context-mode.session-reset, ctx_purge
.mcp.json.codex.example
.mcp.json.example
.ignore
console.log(` 1 token (post-dedup) : ${dedup.deduped.toFixed(1)} μs/query`);"../../.ssh/id_rsa",
"../../.ssh/id_rsa",
export { default } from "../../../build/adapters/pi/extension.js";import { parseJsonc } from "../../util/jsonc.js";import { resolveClaudeConfigDir } from "../../util/claude-config.js";import { checkPluginCacheIntegritySync } from "../../util/plugin-cache-integrity.js";import { hashProjectDirCanonical } from "../../session/db.js";- **Cloud metadata + link-local**: `169.254.0.0/16` (incl. AWS/GCP/Azure IMDS endpoint `169.254.169.254`) hard-blocked even if a hostname resolves to it (DNS-rebinding defense).
expect(classifyIp("169.254.169.254")).toBe("block");expect(classifyIp("::ffff:169.254.169.254")).toBe("block"); // IMDS via IPv4-mappedimds: classifyIp("169.254.169.254"),baseUrl = `http://127.0.0.1:${addr.port}`;Gates applied: critical_finding, no_behavioural_pass.
Audited 2026-09-18 · audit v0.4.0 · source sha 4031d1c9f64f · full audit: observations/trust-audit/mcp-server/mksglu__context-mode.json · Report an issue or request a re-scan
Audit history
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-09-18 | 4031d1c9f64f | BLOCK | F | 37 | first audit |
Alternatives
Other servers in the same categories, safer ones first.
Questions
What is the Context Mode MCP server?
Context window optimization for AI coding agents. Sandboxes tool output (98% reduction), persists session memory, and enforces routing across 17 platforms via MCP + hooks.
What tools does Context Mode expose?
18 in total: 10 read-only, 6 that write, and 2 that can delete or overwrite (context-mode.session-reset, ctx_purge). Every one is listed on this page with its risk.
Is Context Mode safe to connect to an agent?
No — not without reading the findings first. The audit graded it F (37/100) and found 8 critical or high issues in the source. Each one is listed on this page with the file and line it is on. Separately from the audit: 2 of its tools can destroy data, so scope the token you give it to what you actually need.
What credentials does Context Mode need?
It reads CLAUDE_CODE_MAX_OUTPUT_TOKENS, JWT_SECRET, MY_CUSTOM_API_KEY, PI_CONTEXT_MODE_PRICE_OUTPUT_PER_TOKEN, SLACK_BOT_TOKEN and SSH_AUTH_SOCK from the environment. Give it a token scoped to the least it needs — an agent that can be talked into calling a tool can be talked into calling it with your credentials.
How does Context Mode run?
It speaks stdio, so it runs as a local process your client starts. It is published on npm as og at 1.0.0.
How current is this page?
The grade is for one exact copy of the source (4031d1c9f64f), read on 2026-09-18. The repository is watched and re-audited when it changes.
Provenance: OBSERVED · read 2026-09-18 · job trust-audit-2026-09-18