Context Mode MCP Server

mksglu · MCP
8.5
★ 3.8k

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.

stable context optimization updated 2026-03
install
/plugin marketplace add mksglu/context-mode
↗ GitHub
capabilities
Virtualizes tool outputs in local SQLite database Indexes data with FTS5 full-text search and BM25 ranking Reduces token usage 25-99% on large files Creates session checkpoints for recovery after compaction Extends sessions from 30 minutes to 3+ hours Supports 11 programming language runtimes Enforces security rules in sandbox environment
compatible with
Claude Code

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:

  1. Indexes outputs in a local SQLite database using FTS5
  2. Keeps raw data in a sandbox (away from context)
  3. Lets the AI query indexed data intelligently instead of parsing raw text
  4. 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:

  1. Tool output (Playwright snapshot, API response, file) goes to sandbox
  2. Sandbox indexes the data in SQLite using FTS5
  3. AI receives confirmation: “315 KB file indexed”
  4. AI queries database instead of parsing raw text
  5. 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:

  1. Builds a snapshot of critical info (~2 KB)
  2. Injects it back when context resets
  3. 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

/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

  1. Install via Claude Code marketplace
  2. Run a normal session with tool calls
  3. Check savings: context-mode stats
  4. Watch your session extend past 30 minutes

See the full Context Mode setup guide for step-by-step installation and cost calculations.