← Back to directory
C

Context Mode

Community
Optimize context windows for AI coding agents.
GitHub source repository ↗
★ 19.2k Stars Category · Dev Tools Very popular
54FMRS · D
Reliability
10/20
Security and permissions
8/20
Maintenance
10/20
Documentation
14/20
Setup experience
12/20

Context Mode is designed for context governance in AI coding agents. Isolation, output filtering, indexed retrieval, caching, and session tracking can reduce context consumption. It supports many clients, but installation complexity, automatic routing, and hook coverage vary; users should evaluate local code execution, credential inheritance, and persistent indexing before deployment.

Read the FMRS scoring method →

Context Mode is an MCP server for optimizing AI coding-agent context usage through MCP and hooks. It runs tool work in isolated subprocesses and returns only stdout to the context, while providing session memory, SQLite FTS5/BM25 indexing, targeted retrieval, batch execution, and routing support across many coding clients. The README claims roughly 98% reduction for typical tool output.

Tools

ctx_batch_execute
Runs multiple commands and multiple searches in one call, with optional concurrency.
ctx_execute
Runs code in 12 languages in an isolated subprocess and returns only stdout to context.
ctx_execute_file
Processes files in a sandbox without exposing raw file contents.
ctx_index
Chunks Markdown by headings and indexes it in SQLite FTS5.
ctx_search
Searches indexed content and returns relevant snippets.
ctx_fetch_and_index
Fetches URLs, converts them to Markdown, and indexes them with TTL caching and batch-request support.
ctx_stats
Shows context savings, call counts, and session statistics.
ctx_doctor
Diagnoses runtimes, hooks, FTS5, versions, and registration state.
ctx_upgrade
Upgrades from GitHub, rebuilds, and reconfigures hooks.
ctx_purge
Permanently deletes all indexed content from the knowledge base.
ctx_insight
Opens the hosted Insight dashboard in a browser.

Setup

Choose the configuration for the target client. The general MCP-only approach is to run npm install -g context-mode and configure the server command as context-mode; the README also provides the Claude Code command claude mcp add context-mode -- npx -y context-mode. For automatic routing and session tracking, configure the target client's hooks, plugin, or rules file as documented in the README.

claude_desktop_config.json
{"mcpServers":{"context-mode":{"command":"npx","args":["-y","context-mode"]}}}

Fit and risk

Best for

  • Developers using one of the supported AI coding CLIs, IDEs, or agents
  • Teams working with large codebases, logs, web pages, or batch queries
  • Users who need work-state recovery after context compaction

Not for

  • Users requiring a dedicated GUI MCP integration not listed as supported
  • Users who only need a simple MCP tool and do not want hooks, plugins, or local indexing
  • Environments that prohibit local script execution or access to local files, credentials, and network resources

Required permissions

  • Requires Node.js, Bun, or another listed runtime to execute locally.
  • Sandboxed scripts can read and process local files and can use authenticated CLIs such as gh, aws, gcloud, kubectl, and docker through inherited environment variables and configuration paths.
  • ctx_fetch_and_index requires URL fetching; indexed content is stored in SQLite databases under the user's local data directory.
  • With hooks or plugins enabled, the server can intercept selected tool calls, record session events, and apply routing rules.

Risks and side effects

  • Tools such as ctx_execute run code supplied by the user or agent; that code may read local files, invoke commands, or use inherited credentials.
  • Session and indexed content persist in local SQLite databases; ctx_purge permanently deletes all indexed content.
  • Hooks may block or redirect selected tool calls, and routing capabilities vary by client.
  • The README's savings percentages are project-reported metrics; actual results depend on tool output and usage.

Troubleshooting

  1. Confirm that the Node.js version meets the target client's requirements; many configurations require Node.js >= 22.5.
  2. Run context-mode doctor or the client's ctx doctor command to inspect runtimes, hooks, FTS5, versions, and MCP registration.
  3. Use ctx stats to verify that MCP tools are reachable and inspect savings statistics.
  4. Check configuration paths, command PATH, plugin trust state, and duplicate registration of MCP and plugin integrations.
  5. For Linux, older glibc, Windows, or native SQLite binding problems, follow the README's build prerequisites and self-healing guidance.

Use cases

Reduce context usage from large command, log, web, and code-analysis outputs
Build persistent searchable indexes of local files or web pages
Preserve edits, git operations, tasks, errors, and user decisions across sessions
Use scripts for batch file analysis instead of loading large raw datasets into context

Supported clients

Claude CodeFull support
Gemini CLIFull support
VS Code CopilotFull support
JetBrains CopilotFull support
GitHub Copilot CLIFull support
CursorFull support
OpenCodeFull support
KiloCodeFull support
OpenClaw / Pi AgentFull support
Codex CLIFull support
Kimi CodeFull support
Qwen CodeFull support
Antigravity IDEPartial support
Antigravity CLIFull support
KiroFull support
ZedPartial support
Pi Coding AgentFull support
OMP (Oh My Pi)Full support