Context Mode
An MCP server that preserves LLM context by intercepting large data outputs and returning only concise summaries or relevant sections. It enables efficient sandboxed code execution, file processing, and documentation indexing across multiple programming languages and authenticated CLIs.
README
Context Mode
Stop losing context to large outputs.
Run tests without burning 5K tokens. Query docs without loading raw HTML. Debug logs without reading 45KB of noise. Only summaries reach Claude — everything else stays in the sandbox.
Without Context Mode With Context Mode
───────────────────── ────────────────────
Playwright snapshot → 56 KB into context → 299 B summary
GitHub issues (20) → 59 KB into context → 1.1 KB summary
Access log (500) → 45 KB into context → 155 B summary
Context7 docs → 6 KB into context → 261 B summary
Total: 166 KB = 42K tokens gone Total: 1.8 KB = ~450 tokens
Install
claude mcp add context-mode -- npx -y context-mode
Restart Claude Code. Done. You now have 5 tools that intercept large outputs and return only what matters.
<details> <summary><strong>Plugin install</strong> (includes auto-routing skill)</summary>
/plugin marketplace add mksglu/claude-context-mode
/plugin install context-mode@claude-context-mode
Installs the MCP server + a skill that automatically guides Claude to route large outputs through Context Mode. No prompting needed.
</details>
<details> <summary><strong>Local development</strong></summary>
claude --plugin-dir ./path/to/context-mode
</details>
What It Does
Every MCP tool call dumps raw data into your 200K context window. With 81+ tools active, 143K tokens (72%) get consumed before your first message. Context Mode intercepts these operations, processes data in isolated subprocesses, and returns only what you need.
Result: 315 KB raw data becomes 5.4 KB of context across 14 real scenarios — 98% savings.
| Metric | Without | With |
|---|---|---|
| Context consumed per session | 315 KB | 5.4 KB |
| Time before slowdown | ~30 min | ~3 hours |
| Context remaining after 45 min | 60% | 99% |
Tools
execute — Run code in sandbox
Execute code in 10 languages (JS, TS, Python, Shell, Ruby, Go, Rust, PHP, Perl, R). Only stdout enters context.
execute({ language: "shell", code: "gh pr list --json title,state | jq length" })
→ "3" ← 2 bytes instead of 8KB
Add intent for large outputs — Context Mode filters to relevant sections automatically:
execute({ language: "shell", code: "cat app.log", intent: "database connection error" })
→ matching sections + searchable terms ← 500B instead of 100KB
Authenticated CLIs work out of the box — gh, aws, gcloud, kubectl, docker credentials pass through. Bun auto-detected for 3-5x faster JS/TS.
execute_file — Process files without loading
File contents stay in the sandbox as FILE_CONTENT. Your code summarizes. Only the summary enters context.
execute_file({ path: "access.log", language: "python", code: "..." })
→ "200: 312 | 404: 89 | 500: 14" ← 30 bytes instead of 45KB
index + search — Searchable knowledge base
Index documentation into FTS5 with BM25 ranking. Search returns exact code blocks — not summaries.
index({ content: <60KB React docs>, source: "React useEffect" })
→ "Indexed 33 sections (15 with code)" ← 40 bytes
search({ query: "useEffect cleanup function" })
→ exact code example with heading context ← 500 bytes instead of 60KB
fetch_and_index — Fetch URLs into knowledge base
Fetches, converts HTML to markdown, indexes. Raw content never enters context. Use instead of WebFetch or Context7 when you need to reference docs multiple times.
fetch_and_index({ url: "https://react.dev/reference/react/useEffect" })
→ "Indexed 33 sections (15 with code)" ← 40 bytes instead of 60KB
Example Prompts
Just ask naturally — Claude routes through Context Mode automatically when it saves tokens.
"Analyze the last 50 commits and find the most frequently changed files"
"Read the access log and break down requests by HTTP status code"
"Run the test suite and give me a pass/fail summary"
"Fetch the React useEffect docs and find the cleanup pattern"
"List all Docker containers with their memory usage"
"Find all TODO comments across the codebase"
"Analyze package-lock.json and find the 10 largest dependencies"
"Show running Kubernetes pods and their restart counts"
Real-World Benchmarks
| Operation | Raw | Context | Savings |
|---|---|---|---|
Playwright browser_snapshot |
56.2 KB | 299 B | 99% |
| GitHub Issues (20) | 58.9 KB | 1.1 KB | 98% |
| Access log (500 requests) | 45.1 KB | 155 B | 100% |
| Context7 React docs | 5.9 KB | 261 B | 96% |
| Analytics CSV (500 rows) | 85.5 KB | 222 B | 100% |
| Git log (153 commits) | 11.6 KB | 107 B | 99% |
| Test output (30 suites) | 6.0 KB | 337 B | 95% |
Full benchmark data with 21 scenarios →
How It Works
┌─────────────┐ stdio / JSON-RPC ┌─────────────────────────────────┐
│ Claude Code │ ◄─────────────────────► │ Context Mode MCP Server │
│ │ tool calls/results │ │
└─────────────┘ │ Sandboxed subprocesses │
│ • 10 language runtimes │
│ • Auth passthrough (gh, aws…) │
│ • Intent-driven search │
│ │
│ SQLite FTS5 knowledge base │
│ • BM25 ranking │
│ • Porter stemming │
│ • Heading-aware chunking │
└─────────────────────────────────┘
Each execute call spawns an isolated subprocess — scripts can't access each other, but authenticated CLIs (gh, aws, gcloud) find their configs through secure credential passthrough.
Requirements
- Node.js 18+
- Claude Code with MCP support
- Optional: Bun (auto-detected, 3-5x faster JS/TS)
Development
git clone https://github.com/mksglu/claude-context-mode.git
cd claude-context-mode && npm install
npm test # 100+ tests across 4 suites
npm run test:all # full suite
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。