Context Mode: An MCP Server That Compresses Tool Outputs for Claude Code

✍️ OpenClawRadar📅 Published: February 25, 2026🔗 Source
Context Mode: An MCP Server That Compresses Tool Outputs for Claude Code
Ad

What Context Mode Does

Context Mode addresses the problem where every MCP tool call in Claude Code dumps raw data into the 200K context window. Examples from the source show a Playwright snapshot costs 56 KB, twenty GitHub issues cost 59 KB, and one access log costs 45 KB. After 30 minutes, 40% of your context can be gone.

The MCP server sits between Claude Code and these outputs, processing them in sandboxes so only summaries reach the model. It achieves a 98% reduction in context usage (315 KB becomes 5.4 KB).

Installation and Setup

Single command install:

/plugin marketplace add mksglu/claude-context-mode
/plugin install context-mode@claude-context-mode

Or via CLI:

claude mcp add context-mode -- npx -y context-mode

The installation includes an auto-routing skill that automatically routes large outputs through Context Mode, plus a PreToolUse hook that injects context-mode routing into subagent prompts. No prompting is needed.

Available Tools

  • batch_execute: Run multiple commands + search multiple queries in ONE call (986 KB → 62 KB)
  • execute: Run code in 10 languages. Only stdout enters context (56 KB → 299 B)
  • execute_file: Process files in sandbox. Raw content never leaves (45 KB → 155 B)
  • index: Chunk markdown into FTS5 with BM25 ranking (60 KB → 40 B)
  • search: Query indexed content with multiple queries in one call (on-demand retrieval)
  • fetch_and_index: Fetch URL, convert to markdown, index (60 KB → 40 B)
  • stats: Session token tracking with per-tool breakdown
Ad

Technical Implementation

Each execute call spawns an isolated subprocess with its own process boundary. Scripts can't access each other's memory or state. The subprocess runs your code, captures stdout, and only that stdout enters the conversation context. The raw data — log files, API responses, snapshots — never leaves the sandbox.

Ten language runtimes are available: JavaScript, TypeScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R. Bun is auto-detected for 3-5x faster JS/TS execution.

Authenticated CLIs work through credential passthrough — gh, aws, gcloud, kubectl, docker inherit environment variables and config paths without exposing them to the conversation.

When output exceeds 5 KB and an intent is provided, Context Mode switches to intent-driven filtering: it indexes the full output into the knowledge base, searches for sections matching your intent, and returns only the relevant matches with a vocabulary of searchable terms for follow-up queries.

The knowledge base uses SQLite FTS5 (Full-Text Search 5) virtual tables. The index tool chunks markdown content by headings while keeping code blocks intact, then stores them. Search uses BM25 ranking — a probabilistic relevance algorithm that scores documents based on term frequency, inverse document frequency, and document length.

📖 Read the full source: HN AI Agents

Ad

👀 See Also

Handoffs Pattern in Claude Workflows: Two-File Split vs One-Doc Summary
Tools

Handoffs Pattern in Claude Workflows: Two-File Split vs One-Doc Summary

Long Claude sessions break on context decay. Handoffs compress what matters and start fresh. Two approaches: Matt Pocock's single-doc handoff skill vs a two-file split with persistent narrative and ephemeral prompt.

OpenClawRadar
Phaselock: An AI Agent Control System Inspired by Parenting Techniques
Tools

Phaselock: An AI Agent Control System Inspired by Parenting Techniques

Phaselock is an open-source Agent Skill that implements four control mechanisms for AI agents: explicit gates before action, immediate feedback on mistakes, constrained choices, and mechanical rule enforcement. It works with Claude Code, Cursor, Windsurf, and tools supporting hooks.

OpenClawRadar
Gemma4 26B-A4B Delivers Fast Local Performance with Web Search and Image Support
Tools

Gemma4 26B-A4B Delivers Fast Local Performance with Web Search and Image Support

The gemma-4-26B-A4B model achieves approximately 145 tokens per second on an RTX 4090 and includes web search MCP and image support for chat applications. A blog post details setup and cross-platform usage on Mac and iPhone.

OpenClawRadar
Three Repositories for RAG and AI Agent Development
Tools

Three Repositories for RAG and AI Agent Development

A Reddit post highlights three repositories for developers building with RAG and AI agents: memvid for agent memory, llama_index for RAG pipelines, and Continue for coding assistants. The author notes that pure RAG works best for knowledge retrieval, while memory systems are better for agents, with hybrid approaches being common in real tools.

OpenClawRadar