MCP Catalogs
Homecontext-mode screenshot

context-mode

by mksglu·14,865·Score 62

MCP server that optimizes context windows for AI agents by sandboxing tool output with 98% reduction.

ai-llmdeveloper-toolsproductivity
1,055
Forks
12
Open issues
this month
Last commit
2d ago
Indexed

Overview

Context Mode is an MCP server designed to solve the context window optimization problem for AI coding agents. It provides four key solutions: context saving by sandboxing tools to keep raw data out of the context window (98% reduction), session continuity through tracking all operations in SQLite and retrieving only relevant information when needed, 'think in code' approach that encourages LLMs to write scripts rather than processing large data directly, and flexible output style that doesn't enforce prose-style responses. The project supports 15 platforms and has been adopted by major tech companies like Microsoft, Google, Meta, and Amazon.

Try asking AI

After installing, here are 6 things you can ask your AI assistant:

you:Optimize context usage when working with large files or multiple documents
you:Maintain session continuity across AI coding sessions without losing track of edits
you:Reduce token consumption by executing code instead of reading file contents
you:Improve AI agent performance by minimizing context overflow
you:How does Context Mode reduce context usage?
you:Is Context Mode compatible with my favorite AI coding platform?

When to choose this

Choose Context Mode when working with large codebases or long coding sessions where context overflow is a bottleneck, and especially when using supported platforms like Claude Code or Gemini CLI.

When NOT to choose this

Avoid if you need full raw tool outputs in your context, or if you're using an unsupported platform that requires manual implementation of all routing logic.

Tools this server exposes

11 tools extracted from the README
  • ctx_batch_execute

    Executes multiple code snippets in a batch

  • ctx_execute

    Executes code in the specified language and returns results

  • ctx_execute_file

    Executes a code file and returns the results

  • ctx_index

    Indexes content for later retrieval

  • ctx_search

    Searches indexed content using BM25

  • ctx_fetch_and_index

    Fetches content from a source and indexes it

  • ctx_stats

    Shows context savings and usage statistics

  • ctx_doctor

    Runs diagnostic checks on the system

  • ctx_upgrade

    Upgrades context-mode to the latest version

  • ctx_purge

    Deletes all indexed content from the knowledge base

  • ctx_insight

    Opens personal analytics dashboard

Comparable tools

claude-desktopmcp-server-kitcontext-optimizer

Installation

Installation

Claude Code

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

Gemini CLI

npm install -g context-mode

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "context-mode": {
      "command": "context-mode"
    }
  },
  "hooks": {
    "BeforeTool": [{
      "matcher": "run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill",
      "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli beforetool" }]
    }],
    "AfterTool": [{
      "matcher": "",
      "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli aftertool" }]
    }],
    "PreCompress": [{
      "matcher": "",
      "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli precompress" }]
    }],
    "SessionStart": [{
      "matcher": "",
      "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli sessionstart" }]
    }]
  }
}

Manual MCP (for Claude Desktop)

{
  "mcpServers": {
    "context-mode": {
      "command": "npx",
      "args": ["-y", "context-mode"]
    }
  }
}

FAQ

How does Context Mode reduce context usage?
Context Mode reduces context usage by 98% through sandboxing tool outputs. Instead of putting raw data into the context window, it stores the data in SQLite and only indexes it, allowing the model to retrieve relevant information when needed.
Is Context Mode compatible with my favorite AI coding platform?
Yes, Context Mode supports 15 platforms including Claude Code, Gemini CLI, VS Code Copilot, Cursor, and others. It provides specific installation instructions for each platform.

Compare context-mode with

GitHub →

Last updated · Auto-generated from public README + GitHub signals.