Back to feed

Context Mode: A Virtualization Layer for AI Agent Context Windows

mksglu/context-mode
8.4k
+1.6k/day
586
TypeScriptAI/ML📈 Breakout

Context window optimization for AI coding agents. Sandboxes tool output, 98% reduction. 12 platforms

AI Analysis

MCP server that compresses tool output by 98% and maintains session continuity for AI agents.

Built for Developers building AI agents and Claude integrations who struggle with context window bloat from tool calls.

From the README

Context Mode

The other half of the context problem.

Privacy & Architecture

Context Mode is not a CLI output filter or a cloud analytics dashboard. It operates at the MCP protocol layer — raw data stays in a sandboxed subprocess and never enters your context window. Web pages, API responses, file analysis, Playwright snapshots, log files — everything is processed in complete isolation.

Nothing leaves your machine. No telemetry, no cloud sync, no usage tracking, no account required. Your code, your prompts, your session data — all local. The SQLite databases live in your home directory and die when you're done.

This is a deliberate architectural choice, not a missing feature. Context optimization should happen at the source, not in a dashboard behind a per-seat subscription. Privacy-first is our philosophy — and every design decision follows from it. License →

The Problem

Every MCP tool call dumps raw data into your context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. One access log — 45 KB. After 30 minutes, 40% of your context is gone. And when the agent compacts the conversation to free space, it forgets which files it was editing, what tasks are in progress, and what you last asked for.

Context Mode is an MCP server that solves both halves of this problem:

  1. Context Saving — Sandbox tools keep raw data out of the context window. 315 KB becomes 5.4 KB. 98% reduction.
  2. Session Continuity — Every file edit, git operation, task, error, and user decision is tracked in SQLite. When the conversation compacts, context-mode doesn't dump this data back into context — it indexes events into FTS5 and retrieves only what's relevant via BM25 search. The model picks up exactly where you left off. If you don't --continue, previous session data is deleted immediately — a fresh session means a clean slate.

Install

Claude Code

Step 1 — Install the plugin:

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

Step 2 — Restart Claude Code.

That's it. The plugin installs everything automatically:

  • MCP server with 6 sandbox tools (ctx_batch_execute, ctx_execute, ctx_execute_file, ctx_index, ctx_search, ctx_fetch_and_index)
  • PreToolUse hooks that intercept Bash, Read, WebFetch, Grep, and Task calls — nudging them toward sandbox execution
  • PostToolUse, PreCompact, and SessionStart hooks for session tracking and context injection
  • A CLAUDE.md routing