← MCP servers · mksglu

Context Mode

BLOCKgrade F · trust 37/100

Context 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 cli

Overview

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-code
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]
claude-desktop
{
  "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.

ToolRiskDescription
context-mode.session-newreadSession initialization — cleans up old sessions on /new command
context-mode.session-resetdestructiveSession cleanup on /reset command
context-mode.session-stopwriteSession cleanup on /stop command
ctx-doctorwriteRun context-mode diagnostics
ctx-statsreadShow context-mode session statistics
ctx-upgradereadUpgrade context-mode to the latest version
ctx_batch_executewriteRun multiple commands and search queries in ONE call. Primary research tool — replaces 30+ individual calls.
ctx_doctorwriteRun context-mode diagnostics — runtimes, hooks, FTS5, plugin registration.
ctx_executewriteExecute code in a sandboxed subprocess. Only stdout enters context. Prefer over Bash for any command producing >20 lines.
ctx_execute_filewriteExecute code with a file path. Only printed summary enters context — raw file stays in sandbox.
ctx_fetch_and_indexreadFetch a URL, chunk it, and index — raw HTML never enters context.
ctx_indexreadStore content in the FTS5 knowledge base for later search.
ctx_insightreadOpen the hosted context-mode Insight dashboard (context-mode.com/insight) in the browser.
ctx_purgedestructiveDESTRUCTIVE — permanently delete indexed content. CANNOT be undone.\n\n
ctx_searchreadQuery indexed content via FTS5. Pass all questions as an array in ONE call.
ctx_statsreadShow context-mode session statistics — token consumption and per-tool breakdown.
ctx_upgradereadUpgrade context-mode to the latest version.
pingreadp

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.

LayerWhat it checksResult
L0Provenance & inventoryFAIL
L1Static analysis of the codeFAIL
L2Instruction surface (what it tells the agent)PASS
L3Class-specific surfaceWARN
L4Behavioural (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)

CRITICALObfuscation / stealth · obf.decode_then_exec · CWE-506, CWE-94
cli.bundle.mjs:459
atob( ... /exec(
Why it matters. decodes a payload and executes it
HIGHInventory / provenance · inv.suspicious_name · CWE-1104
hooks/antigravity-cli/payload.mjs
payload.mjs
Why it matters. member named after an attack tool
Fix. remove or justify
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
scripts/heal-better-sqlite3.mjs:197
const displayName = exec(
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
src/db-base.ts:64
exec(sql: string): any {
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
src/db-base.ts:140
exec(sql: string): any {
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
src/security.ts:801
/exec(?:Sync|File|FileSync)?\(\s*(['"`])(.*?)\1/g,
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
src/security.ts:805
/exec(?:Sync|File|FileSync)?\(\s*(['"`])(.*?)\1/g,
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHNetwork egress · net.metadata_ip · CWE-200, CWE-319
src/server.ts:3277
if (a === 169 && b === 254) return "block"; // link-local incl. 169.254.169.254 (IMDS)
Why it matters. cloud metadata endpoint: the classic SSRF credential grab
MEDIUMFilesystem / path · mcp.destructive_tools · CWE-22, CWE-59
context-mode.session-reset, ctx_purge
Why it matters. 2 tool(s) can delete or overwrite
Fix. prefer a read-only mode or scoped tokens; the page states the blast radius
LOWInventory / provenance · inv.hidden_file · CWE-1104
.mcp.json.codex.example
.mcp.json.codex.example
Why it matters. hidden member outside the usual dotfiles
Fix. review its purpose
LOWInventory / provenance · inv.hidden_file · CWE-1104
.mcp.json.example
.mcp.json.example
Why it matters. hidden member outside the usual dotfiles
Fix. review its purpose
LOWInventory / provenance · inv.hidden_file · CWE-1104
skills/.ignore
.ignore
Why it matters. hidden member outside the usual dotfiles
Fix. review its purpose
LOWInformation disclosure · disclose.log_secret · CWE-209, CWE-532
tests/benchmark.ts:415
console.log(`  1 token (post-dedup)            : ${dedup.deduped.toFixed(1)} μs/query`);
LOWFilesystem / path · fs.credential_store · CWE-22, CWE-59
tests/security.test.ts:600
"../../.ssh/id_rsa",
Why it matters. touches a credential store
LOWFilesystem / path · fs.credential_store · CWE-22, CWE-59
tests/security.test.ts:615
"../../.ssh/id_rsa",
Why it matters. touches a credential store
LOWFilesystem / path · fs.traversal · CWE-22, CWE-59
.pi/extensions/context-mode/index.ts:1
export { default } from "../../../build/adapters/pi/extension.js";
LOWFilesystem / path · fs.traversal · CWE-22, CWE-59
src/adapters/antigravity-cli/index.ts:25
import { parseJsonc } from "../../util/jsonc.js";
LOWFilesystem / path · fs.traversal · CWE-22, CWE-59
src/adapters/claude-code/index.ts:30
import { resolveClaudeConfigDir } from "../../util/claude-config.js";
LOWFilesystem / path · fs.traversal · CWE-22, CWE-59
src/adapters/claude-code/index.ts:31
import { checkPluginCacheIntegritySync } from "../../util/plugin-cache-integrity.js";
LOWFilesystem / path · fs.traversal · CWE-22, CWE-59
src/adapters/codex/index.ts:31
import { hashProjectDirCanonical } from "../../session/db.js";
LOWNetwork egress · net.metadata_ip · CWE-200, CWE-319
README.md:1582
- **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).
Why it matters. cloud metadata endpoint: the classic SSRF credential grab
LOWNetwork egress · net.metadata_ip · CWE-200, CWE-319
tests/core/server.test.ts:3728
expect(classifyIp("169.254.169.254")).toBe("block");
Why it matters. cloud metadata endpoint: the classic SSRF credential grab
LOWNetwork egress · net.metadata_ip · CWE-200, CWE-319
tests/core/server.test.ts:3783
expect(classifyIp("::ffff:169.254.169.254")).toBe("block"); // IMDS via IPv4-mapped
Why it matters. cloud metadata endpoint: the classic SSRF credential grab
LOWNetwork egress · net.metadata_ip · CWE-200, CWE-319
tests/core/server.test.ts:3879
imds: classifyIp("169.254.169.254"),
Why it matters. cloud metadata endpoint: the classic SSRF credential grab
LOWNetwork egress · net.raw_ip · CWE-200, CWE-319
tests/core/fetch-cleanup.test.ts:113
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

DateSourceVerdictGradeScoreChange
2026-09-184031d1c9f64fBLOCKF37first 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