MCP Server Open Source ELv2 5 Platforms

Context Mode

v1.0.0

The other half of the context problem.

B. Mert Koseoglu
github.com/mksglu/context-mode

The Problem

Raw data floods the context window

Every MCP tool call returns its full output directly into the model's 200K context window. With 81+ tools active, 143K tokens (72%) are consumed before the first user message.

56 KB One Playwright snapshot
59 KB Twenty GitHub issues
45 KB One access log

After 30 minutes, 40% of available context is gone. When the agent compacts to free space, it forgets files, tasks, and decisions.

Benchmarks

Before vs After

Operation Raw Output Context Mode Saved
Playwright snapshot 56.2 KB 299 B 99%
GitHub Issues (20) 58.9 KB 1.1 KB 98%
Access log (500 req) 45.1 KB 155 B 100%
Analytics CSV (500 rows) 85.5 KB 222 B 100%
Repo research (subagent) 986 KB 62 KB 94%
Test output (30 suites) 6.0 KB 337 B 95%
315 KB Total raw output
5.4 KB With Context Mode
98% Context saved

How it works

Sandbox Architecture

AI Agent
200K context window
Context Mode
MCP Server · stdio
Subprocess
Isolated execution
Summary
Only stdout returns

Each call spawns an isolated subprocess. Scripts cannot access each other's memory or state.

Authenticated CLIs pass through—gh aws gcloud kubectl docker inherit credentials without exposing them to context.

11 runtimes: JavaScript, TypeScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir.

When output exceeds 5 KB with an intent, Context Mode auto-indexes into FTS5 and returns only matching sections.

Toolkit

Nine Tools

Sandbox Execution
ctx_batch_execute Run multiple commands + search in one call. Replaces 30+ individual calls.
ctx_execute Run code in 11 languages. Only stdout enters context.
ctx_execute_file Process files in sandbox. Raw content never leaves.
Knowledge Base
ctx_index Chunk markdown into FTS5 with BM25 ranking.
ctx_search BM25-ranked full-text search. Multiple queries per call.
ctx_fetch_and_index Fetch URL, detect content type, chunk and index automatically.
Utilities
ctx_stats Context savings report with per-tool breakdown.
ctx_doctor Diagnose runtimes, hooks, FTS5, and versions.
ctx_upgrade Upgrade from GitHub, rebuild, reconfigure hooks.

Search Engine

Knowledge Base

SQLite FTS5 with BM25 ranking. Three-layer fuzzy search for fault-tolerant queries.

01 Porter Stemming "caching" → "cached"
02 Trigram Substring "useEff" → "useEffect"
03 Levenshtein Fuzzy "kuberntes" → "kubernetes"

Smart Snippets — windows around query matches with heading context, not truncation. You get the exact code block you need.

Progressive Throttling — calls 1–3 normal, 4–8 reduced, 9+ blocked. Prevents the model from exhausting the knowledge base in a single turn.

Source Scoping — search can target a specific indexed source, so React docs don't interfere with API references.

New in v1.0.0

Session Continuity

When context compacts, the model forgets everything. Context Mode captures events across the session and restores state automatically.

PostToolUse
Captures events
after each tool call
SQLite
Persistent per-project
event store
PreCompact
Builds priority-tiered
snapshot ≤ 2 KB
SessionStart
Restores state
into FTS5
Files · edits, reads Tasks · create, complete Git · commit, push, diff Errors · failures, exits Decisions · corrections Environment · cwd, venv MCP Tools · call counts Subagents · delegated work
~3h Session duration (vs ~30 min)
99% Context remaining at 45 min
15 Event categories tracked

Compatibility

Five Platforms

Feature Claude Code Gemini CLI VS Code Copilot OpenCode Codex CLI
MCP Server
PreToolUse Hook Plugin
Session Continuity Full High High High
Can Block Tools Plugin
Plugin Marketplace

Hook enforcement matters — one unrouted Playwright snapshot can wipe an entire session's savings.

With hooks
~98% saved
Without hooks
~60% saved

Permissions

Security

Same permission rules you already use—extended to the MCP sandbox. Zero additional configuration.

{
  "permissions": {
    "deny": [
      "Bash(sudo *)",
      "Bash(rm -rf /*)",
      "Read(.env)"
    ],
    "allow": [
      "Bash(git:*)",
      "Bash(npm:*)"
    ]
  }
}
  • Deny always wins over allow rules
  • Chained commands with && ; | are split and checked separately
  • Works across all platforms—Gemini CLI and OpenCode read the same settings format
  • Project-level rules override global configuration

Installation

Get Started

Claude Code — Plugin Marketplace
/install context-mode
All Platforms — npm
npm install -g context-mode

Open Source  ·  Elastic License 2.0  ·  Node.js 18+

github.com/mksglu/context-mode

Stop feeding your context window raw bytes.
Feed it answers.