# Context Mode

> An MCP server that optimizes AI coding agent context windows by sandboxing tool output, achieving up to 98% context reduction across 14 platforms.

Context Mode is an MCP server that solves the context window problem for AI coding agents by sandboxing raw tool output, maintaining session continuity across compactions, and compressing LLM output tokens. It supports 14 platforms including Claude Code, Cursor, VS Code Copilot, Gemini CLI, and more, delivering up to 98% context savings on tool outputs like Playwright snapshots, GitHub issues, and log files. The tool operates entirely locally with no telemetry, no cloud sync, and no account required.

- **Context Saving via Sandbox Tools** — *Install globally with `npm install -g context-mode`, then add the MCP server to your platform config. Raw tool output (e.g., 56 KB Playwright snapshots) is processed in an isolated subprocess; only stdout enters the context window, achieving up to 99% reduction.*
- **Session Continuity** — *Hooks (PreToolUse, PostToolUse, PreCompact, SessionStart) capture every file edit, git operation, task, error, and user decision into a local SQLite database. After context compaction, the model resumes from your last prompt with full working state restored.*
- **Think in Code Paradigm** — *Instead of reading 50 files into context, the agent writes a script that processes them and logs only the result. One `ctx_execute` call replaces dozens of Read/Bash calls, saving 100x context.*
- **Output Compression** — *Enforces terse, caveman-style responses from the LLM — dropping filler, pleasantries, and hedging — achieving 65–75% output token reduction while preserving full technical accuracy.*
- **11 Sandbox Runtimes** — *`ctx_execute` supports JavaScript, TypeScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, and Elixir. Bun is auto-detected for 3–5x faster JS/TS execution.*
- **FTS5 Knowledge Base** — *`ctx_index` and `ctx_fetch_and_index` chunk and store content in SQLite FTS5 with BM25 ranking, Porter stemming, trigram search, Reciprocal Rank Fusion, and a 24-hour TTL cache for fetched URLs.*
- **Personal Analytics Dashboard** — *`ctx_insight` opens a local web UI with 90 metrics, 37 insight patterns, and 4 composite scores (productivity, quality, delegation, context health) across 23 event categories.*
- **Security & Permission Enforcement** — *Inherits Claude Code's `permissions.deny/allow` rules and extends them into the MCP sandbox. Network fetch hardening blocks cloud metadata endpoints, dangerous URL schemes, and optionally RFC1918 ranges via `CTX_FETCH_STRICT=1`.*
- **14-Platform Support** — *Works with Claude Code (plugin marketplace), Cursor, VS Code Copilot, JetBrains Copilot, Gemini CLI, OpenCode, KiloCode, OpenClaw, Codex CLI, Qwen Code, Antigravity, Kiro, Zed, and Pi Coding Agent.*

## Features
- Context window sandboxing with up to 99% output reduction
- Session continuity across context compactions via SQLite event tracking
- Think in Code paradigm — agent writes scripts instead of reading files
- 65–75% output token compression via terse response enforcement
- 11 sandbox language runtimes (JS, TS, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir)
- FTS5 knowledge base with BM25 ranking, Porter stemming, and trigram search
- Reciprocal Rank Fusion for multi-strategy search merging
- 24-hour TTL cache for fetched and indexed URLs
- Personal analytics dashboard with 90 metrics and 4 composite scores
- Security permission enforcement inherited from Claude Code settings
- Network fetch hardening blocking cloud metadata and dangerous URL schemes
- 14-platform support including Claude Code, Cursor, VS Code Copilot, Gemini CLI, and more
- Automatic Bun detection for 3–5x faster JS/TS sandbox execution
- No telemetry, no cloud sync, fully local SQLite storage

## Integrations
Claude Code, Cursor, VS Code Copilot, JetBrains Copilot, Gemini CLI, OpenCode, KiloCode, OpenClaw, Codex CLI, Qwen Code, Antigravity, Kiro, Zed, Pi Coding Agent, npm, Bun, SQLite, GitHub

## Platforms
WINDOWS, MACOS, LINUX, WEB, API, VSC_EXTENSION, JETBRAINS_PLUGIN, CLI

## Pricing
Open Source

## Version
v1.0.106

## Links
- Website: https://context-mode.com
- Documentation: https://github.com/mksglu/context-mode
- Repository: https://github.com/mksglu/context-mode
- EveryDev.ai: https://www.everydev.ai/tools/context-mode
