Context Mode MCP Server
MCP server that virtualizes Claude Code tool outputs via SQLite indexing, reducing token usage 25-99% and extending sessions from 30 minutes to 3+ hours.
Context Mode solves the #1 problem in Claude Code: context bloat. Every MCP tool call dumps raw output (Playwright snapshots, GitHub issues, log files) directly into your 200K context window. Within 30 minutes, you’ve consumed 70% of your window and hit compaction. Context Mode virtualizes those outputs, reducing token usage by 25-99% and extending sessions to 3+ hours.
What is Context Mode?
Context Mode is an MCP server that virtualizes Claude Code tool outputs. Instead of dumping raw data into your context window, it:
- Indexes outputs in a local SQLite database using FTS5
- Keeps raw data in a sandbox (away from context)
- Lets the AI query indexed data intelligently instead of parsing raw text
- Creates session checkpoints that restore state after context compaction
Result: A 315 KB analytics file becomes 5.4 KB in context (98% reduction). Sessions extend from 30 minutes to 3+ hours.
The Problem It Solves
Context Depletion is Fast
In Claude Code, every tool call adds to context bloat:
- Playwright snapshot: 56 KB
- 20 GitHub issues: 59 KB
- Production logs: 315 KB
- Analytics CSV: 75+ KB
Run these a few times and your 200K window is 70% full. The AI starts forgetting files you opened 10 minutes ago, decisions you made, failed approaches it shouldn’t repeat.
Sessions Hit Compaction Every 30 Minutes
When context fills up, Claude Code compacts the conversation. The problem: The AI loses track of previous context. You’re left with forgotten decisions, lost session state, and wasted tokens (that data gets re-sent with every message anyway).
How It Works
Virtualization Layer
Instead of tools dumping outputs directly to context, Context Mode intercepts them:
- Tool output (Playwright snapshot, API response, file) goes to sandbox
- Sandbox indexes the data in SQLite using FTS5
- AI receives confirmation: “315 KB file indexed”
- AI queries database instead of parsing raw text
- Result: Intelligent search without token cost
Token Reduction (Real Numbers)
Access Log Analysis:
- Raw file: 5,000 lines (20 KB)
- Without Context Mode: ~625 tokens to context
- With Context Mode: ~0 tokens to context
- Savings: ~625 tokens
Large Analytics Export:
- Raw file: 315 KB
- Without Context Mode: ~12,500 tokens to context
- With Context Mode: ~650 tokens to context
- Savings: ~11,850 tokens (98% reduction)
Repository Research:
- 100+ GitHub issues + source files
- Without Context Mode: 50,000–100,000 tokens
- With Context Mode: 5,000–10,000 tokens
- Savings: 40,000–90,000 tokens per session
Session Continuity (The Real Magic)
Token savings are one thing. Session continuity is another.
Context Mode monitors:
- File edits
- Git operations
- Sub-agent tasks
- Decisions made
When context compacts, Context Mode:
- Builds a snapshot of critical info (~2 KB)
- Injects it back when context resets
- AI remembers: Previous code, failed approaches, decisions
Result: Sessions extend from 30 minutes to 2–3 hours without losing continuity.
Features
6 Sandbox Tools
- Code execution
- File processing
- Content indexing
- Intelligent search
- State management
- Decision tracking
11 Language Runtimes
JavaScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir
FTS5 Knowledge Base
- Full-text search with BM25 ranking
- Fuzzy matching for typos/variations
- Three-layer fallback search
- Session recovery with priority-tiered snapshots
Security
- Enforces existing permission rules
- No privilege escalation
- Sandboxed execution
Installation
For Claude Code (Recommended)
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode
Claude Code handles everything automatically.
When to Use It
Best For:
- Long research sessions (multi-hour coding + investigation)
- Large file analysis (logs, analytics, CSVs > 50 KB)
- Multi-tool workflows (Playwright + GitHub + filesystem combined)
- Complex projects (extended reasoning without compaction)
- Cost-conscious teams (every 50K tokens saved matters)
Skip It For:
- Quick edits (single files, <10 min sessions)
- Minimal tool usage (few API calls per session)
- Small contexts (where overhead outweighs savings)
Performance & Cost Impact
Typical Session (Research + Coding):
- GitHub issues: 59 KB
- Log analysis: 100 KB
- File reads: 50 KB
- Web snapshots: 56 KB
- Total: ~265 KB
Without Context Mode:
- Context impact: ~33 KB → ~4,125 tokens
- Compaction at 30 min
With Context Mode:
- Context impact: ~2 KB → ~200 tokens
- Session extension: 2–3 hours
Pros & Cons
Pros ✅
- Massive token reduction: 25-99%
- Session extension: 3+ hours continuous work
- Automatic: No configuration needed
- Cross-platform: Works on 6+ IDEs
- Security: Sandboxed, permission-aware
- Open source: 3.8K+ GitHub stars, active development
Cons ⚠️
- SQLite overhead on tiny operations
- Learning curve for Claude Code newcomers
- Not a complete context solution
- Platform compatibility check needed
Verdict
Context Mode is essential for serious Claude Code users. If you’re running long research sessions, analyzing large files, or managing complex projects, this MCP server pays for itself in time saved and context preserved. The 98% token reduction on large exports, automatic checkpoints that extend sessions to 3+ hours, and transparent integration make it a must-have.
It becomes invisible after setup—you don’t think about it, it just works, and suddenly you’re running 2-hour sessions without hitting compaction.
Score: 8.5/10
Getting Started
- Install via Claude Code marketplace
- Run a normal session with tool calls
- Check savings:
context-mode stats - Watch your session extend past 30 minutes
See the full Context Mode setup guide for step-by-step installation and cost calculations.
Links
- GitHub: mksglu/context-mode
- Setup Guide: Save Money in Claude Code with Context Mode
- Related: