Context Mode Solves Claude Code Context Window Exhaustion — 98% MCP Output Reduction
Context Mode, a new MCP server that reduces MCP tool output by up to 98%,来解决MCP tool outputs consuming context windows and causing sessions to slow down after 30 minutes.
Context Mode Solves Claude Code Context Window Exhaustion — 98% MCP Output Reduction
A growing challenge among developers using AI coding agents has been MCP (Model Context Protocol) tool outputs consuming context windows, causing sessions to slow down after about 30 minutes. Context Mode, developed by Mert Köseoğlu, solves this problem by compressing MCP tool outputs by up to 98%.
The Problem: Context Window Exhaustion from MCP Outputs
MCP has become the standard tool protocol for AI coding agents, but each tool call consumes context window tokens. The problem is particularly severe on the output side, where the following data is added to context for every tool call:
| Data Type | Context Consumption |
|---|---|
| Playwright snapshots | 56 KB |
| GitHub Issues (20 items) | 59 KB |
| Access logs (1 item) | 45 KB |
| CSV analysis (500 rows) | 85 KB |
After 30 minutes of a session, 40% of the context is lost, degrading session longevity and response quality.
Context Mode’s Solution
Context Mode acts as an MCP server that receives raw data from MCP tools and returns only the minimum information AI needs to context. Compression results:
| Data Type | Before | After | Reduction |
|---|---|---|---|
| Playwright snapshots | 56 KB | 299 B | 99.5% |
| GitHub Issues (20 items) | 59 KB | 1.1 KB | 98% |
| Access logs (500 items) | 45 KB | 155 B | 99.7% |
| CSV analysis (500 rows) | 85 KB | 222 B | 99.7% |
For entire sessions, 315 KB compresses to 5.4 KB, extending session runtime from approximately 30 minutes to about 3 hours before context degradation.
Technical Approach
Context Mode consists of two main components:
1. Sandbox
Each execute call runs in an isolated subprocess. Raw data (logs, API responses, snapshots) never enters context—only stdout is returned, preventing unnecessary data from bloating the context.
2. Knowledge Base
Chunks markdown by headings and provides BM25 ranking search via SQLite FTS5. Returns code blocks precisely, keeping context information minimal yet sufficient.
Installation
# MCP only
claude mcp add context-mode -- npx -y context-mode
Or install via Claude Code’s Plugin Marketplace. Supports 10 language runtimes (JS/TS/Python/Shell/Ruby/Go/Rust/PHP/Perl/R), with 3-5x speedup when using Bun.
Why It Was Needed
The idea came from Köseoğlu, who operates the MCP Directory & Hub. “Everyone builds tools, but nobody addresses the output side. We process 100,000 requests daily at MCP Hub. When Cloudflare announced Tool Mode for compressing tool definitions, we tackled the reverse—compressing tool outputs.”
Conclusion
Context Mode addresses the often-overlooked “output side efficiency” in an era where MCP standardization is advancing. Efficient context window utilization will become increasingly important for future AI coding agent development.
Repository: github.com/mksglu/claude-context-mode (MIT License)
Related Articles
Claude Code v2.1.64 Released — New Remote Control Feature and Performance Improvements
Claude Code v2.1.64 brings new Remote Control subcommand, BashTool performance improvements, enhanced auto-save, and various fixes.
Claude Code v2.1.66 Released — New Slash Commands and HTTP Hooks Support
Claude Code v2.1.66 introduces bundled /simplify and /batch slash commands, HTTP Hooks support, performance improvements, and numerous memory leak fixes.
Claude Code v2.1.68 Released — Opus 4.6 Default, ultrathink Keyword Returns
Claude Code v2.1.68 released. Opus 4.6 now defaults to medium effort for Max/Team subscribers, ultrathink keyword reintroduced, Opus 4 and 4.1 removed.
Popular Articles
Claude Code v2.1.93 Released - Deferred Permission Decisions, Flicker-Free Rendering, and More
Anthropic releases Claude Code v2.1.93 with deferred permission decisions for PreToolUse hooks, flicker-free rendering option, PermissionDenied hook, and named subagent typeahead support.
Claude Code v2.1.92 Released - forceRemoteSettingsRefresh, Bedrock Setup Wizard, and More
Anthropic releases Claude Code v2.1.92 with forceRemoteSettingsRefresh policy setting, AWS Bedrock setup wizard, /cost command improvements, and numerous bug fixes.
Claude Code v2.1.84 Release - PowerShell Tool Preview and Environment Configuration Enhancements
Claude Code v2.1.84 introduces PowerShell tool for Windows, new environment variable overrides for model selection, idle session handling improvements, and various stability fixes.
Latest Articles
Claude Code v2.1.93 Released - Deferred Permission Decisions, Flicker-Free Rendering, and More
Anthropic releases Claude Code v2.1.93 with deferred permission decisions for PreToolUse hooks, flicker-free rendering option, PermissionDenied hook, and named subagent typeahead support.
Claude Code v2.1.92 Released - forceRemoteSettingsRefresh, Bedrock Setup Wizard, and More
Anthropic releases Claude Code v2.1.92 with forceRemoteSettingsRefresh policy setting, AWS Bedrock setup wizard, /cost command improvements, and numerous bug fixes.
Claude Code v2.1.91 Released - MCP Tool Result Persistence and Improved Edit Tool
Claude Code v2.1.91 introduces MCP tool result persistence override, improved shell execution controls, and enhanced Edit tool efficiency.