Home / Blog / Context Mode – An Open-Source MCP Server That Reduces AI…
Tech News

Context Mode – An Open-Source MCP Server That Reduces AI Coding Context

Context Mode launched an open-source MCP server that slashes AI coding context usage by 98 percent by running sandboxed code and storing history in SQLite.

By Dillip Chowdary • Nov 01, 2026 • Source: github.com

Context Mode – An Open-Source MCP Server That Reduces AI Coding Context

Developer mksglu released Context Mode, an open-source Model Context Protocol server engineered to slash token usage during AI-assisted programming sessions, as detailed in github.com's report. The project directly tackles context window bloat caused by conventional agent tool calls, which routinely dump entire raw outputs into the model prompt. Across standard development tasks, tools such as Playwright browser snapshots take 56 KB, batches of 20 GitHub issues consume 59 KB, and a single server access log burns 45 KB. Under ordinary workflows, roughly 40 percent of an agent's available context window disappears within 30 minutes, leading to rapid compaction where models frequently lose active task states, user directions, and file modification records.

This report examines how Context Mode intercepts tool traffic, how its execution architecture functions across developer tools, and what software engineers need to configure to deploy it. Context Mode targets developers using coding assistants such as Anthropic Claude Code, Gemini CLI, GitHub Copilot in Visual Studio Code, and JetBrains IDEs. By handling execution in dedicated sandbox tools and indexing session state locally rather than passing raw text blobs into the conversation history, the system aims to keep agent operations lightweight, prevent token exhaustion, and preserve accurate memory over extended coding sessions without dictating model prose styling.

Context Mode – An Open-Source MCP Server That: what actually changed

Context Mode alters how AI coding tools process external data by shifting from raw text ingestion to sandboxed programmatic analysis and local search indexing. In typical workflows, an agent running 47 individual file reads dumps approximately 700 KB of text into the active prompt. Using Context Mode's ctx_execute tool, an agent instead executes a single JavaScript script that parses the directory, calculates metrics such as line counts internally, and logs only the finalized answer, collapsing that interaction down to 3.6 KB. Across standard sandbox operations, raw outputs of 315 KB shrink to 5.4 KB, delivering an aggregate 98 percent reduction in context consumption.

In addition to filtering tool returns, Context Mode restructures session tracking through a local SQLite database using full-text search extensions. File updates, git interactions, error messages, and active goals are continuously recorded in SQLite. When context compaction occurs, the server avoids dumping historical logs back into the conversation window; instead, it indexes events into FTS5 and queries past context on demand using BM25 relevance scoring. If a user starts a session without passing the continue flag, previous records are immediately purged, ensuring clean execution boundaries without leftover prompt artifacts.

Context Mode – An Open-Source MCP Server That: how it works

Context Mode – An Open-Source MCP Server That Reduces AI Coding Context
Illustration · Pexels

The system operates via an MCP architecture spanning 17 supported client platforms alongside an OpenClaw gateway integration. The server registers 11 core tools divided into two operational tiers: six sandbox execution tools and five administrative meta-tools. The sandbox tier includes ctx_batch_execute, ctx_execute, ctx_execute_file, ctx_index, ctx_search, and ctx_fetch_and_index. The administrative suite includes ctx_stats, ctx_doctor, ctx_upgrade, ctx_purge, and ctx_insight. For Claude Code, these tools expose slash commands such as /context-mode:ctx-stats for viewing token consumption and /context-mode:ctx-doctor for validating runtimes, FTS5 components, hooks, and active registrations.

Platform integration relies on lifecycle hooks to route commands automatically without cluttering source projects. In environments like Gemini CLI, a single configuration file registers the server alongside BeforeTool, AfterTool, PreCompress, and SessionStart hooks. The BeforeTool hook uses a targeted regular expression matcher to intercept heavy output commands like run_shell_command, read_file, read_many_files, grep_search, and web_fetch while letting lightweight tools bypass proxy layers. Crucially, Context Mode avoids imposing prose-style instructions on the model's final response, deliberately steering clear of aggressive brevity prompts that research by Moonshot AI on kimi-k2.5 found detrimental to coding benchmarks.

Advertisement

Tech Pulse Daily

Get tomorrow's pulse first

Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.

Context Mode – An Open-Source MCP Server That: why it matters now

Modern agentic programming workflows routinely suffer from dual-sided context waste: input bloat from raw tool payloads and output bloat from verbose agent explanations. When models ingest entire database logs, API JSON payloads, or multi-file repositories, context limits are quickly reached, forcing context compaction algorithms to wipe active task memory. By treating the underlying large language model as a code generator that writes scripts to parse data rather than a data processor that reads raw strings, Context Mode forces operations into sandboxes, ensuring that only condensed, final programmatic outputs enter the active token stream.

Long-running programming sessions also gain operational stability through deterministic state retrieval. Traditional context compression techniques often discard which specific functions an agent was refactoring or forget user-defined constraints set early in a session. Because Context Mode persists decisions and git actions into SQLite and applies BM25 search over FTS5 tables, the agent only re-ingests specific historical segments when an explicit query requires them. This architecture mitigates the performance degradation commonly observed during deep code refactoring tasks that span dozens of consecutive tool calls.

Context Mode – An Open-Source MCP Server That: who is affected

Software engineers using autonomous coding CLIs and IDE-integrated extensions are the primary audience impacted by Context Mode. Users working with Claude Code version 1.0.33 or later can install Context Mode directly through Anthropic's plugin marketplace using the plugin add command. The Claude Code setup automates hook injection at session start without writing permanent files to the local repository, and supports an optional statusLine configuration in settings.json to display real-time dollar amounts saved and percentage efficiency metrics throughout the active session.

Developers utilizing Google Gemini CLI, Visual Studio Code with Copilot Chat version 0.32 or higher, and JetBrains IDEs with Copilot plugin version 1.5.57 or higher also gain hook-level interception. These platforms require Node.js version 22.5 or higher, or the Bun runtime, with the package installed globally through npm. For developer setups that cannot use runtime hooks, Context Mode offers an MCP-only installation method, which registers all 11 tools directly without enforcing automated routing nudges.

Context Mode – An Open-Source MCP Server That: what to watch

Adoption across development teams will depend on operational metrics tracked inside the project's tooling ecosystem. Teams monitoring token budgets can use the ctx_insight utility, which links directly to the hosted dashboard at context-mode.com/insight to analyze organizational token savings and assistant efficiency. Users running local environments can track real-time efficiency metrics using ctx_stats to verify whether their active workflows achieve the 98 percent payload reduction target demonstrated in repository benchmarks.

Ongoing maintenance requires developers to verify local runtime components and configuration hooks using the ctx_doctor diagnostics command. When framework dependencies update, running ctx_upgrade handles pulling latest builds, migrating cache stores, and realigning hook registrations. As client platforms update their internal extension architectures, developers should observe whether manual routing file copies remain necessary for non-hook IDE environments or if additional editors adopt automatic session hook injection standards.

Developer Action Items

  • ☐ Diff the official changelog for Anthropic / Claude / Gemini 3.6 before you bump — APIs, defaults, and removed flags only.
  • ☐ Install through the vendor's documented channel in staging; keep a one-command rollback and time-box the canary.
  • ☐ Grep your repo for old flag names, lockfile pins, and plugin versions that the notes mark as breaking.
  • ☐ Prefer the first patch cut over the day-zero tag unless you have a reason to be on the leading edge.
  • ☐ If HN AI Agents did not name a region, plan, or SKU, screenshot the official availability line before you promise it to users.

Context Mode – An Open-Source MCP Server That FAQ

What runtime requirements are needed to run Context Mode?

Context Mode requires Node.js version 22.5 or higher, or the Bun runtime, installed globally via npm. Specific platform integrations require Claude Code v1.0.33+, VS Code Copilot Chat v0.32+, or JetBrains Copilot v1.5.57+.

How does Context Mode reduce token usage during tool calls?

Instead of dumping raw data like access logs or file trees into context, Context Mode executes scripts inside sandboxes to compute answers, reducing 315 KB data payloads down to 5.4 KB for a 98 percent reduction.

How does Context Mode maintain conversation history across compaction?

The system records file edits, git commands, errors, and task states in a local SQLite database, indexes them with FTS5, and retrieves relevant records using BM25 search rather than re-injecting full history logs.

Does Context Mode enforce brevity or short prose in AI answers?

No, Context Mode only routes and sandboxes raw data, deliberately avoiding brevity prompts because research by Moonshot AI on kimi-k2.5 showed that aggressive brevity prompts degrade coding and reasoning benchmarks.

Sources

Dillip Chowdary

Author

Dillip Chowdary

Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.

Related on Tech Bytes

Advertisement

5-min tech signal

Weekday briefing for engineers who skip the noise.

No spam · Unsubscribe anytime

Advertisement

✈️ CareerPilot

Your AI job-search copilot

Match your resume against live Ashby, Greenhouse & Lever openings — fit scores, job-specific resume optimization and email alerts.

Find matching jobs →

Free Tools

Browse all tools →