/ Каталог / Песочница / Context Mode
● Сообщество mksglu ⚡ Сразу

Context Mode

автор mksglu · mksglu/context-mode

Sandbox tool output and persist session state in SQLite — 98% less token waste, no more compaction amnesia.

Context Mode solves the "LLM forgot what it was doing" problem two ways. First, sandbox tools capture raw data out of the context window (playwright snapshot: 56KB → indexed, agent searches what it needs). Second, a per-session SQLite event log survives context compaction — the model picks up exactly where it was. Ships as plugin + MCP for 12 platforms.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

context-mode-mcp.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "context-mode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "context-mode"
      ]
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "context-mode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "context-mode"
      ]
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "context-mode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "context-mode"
      ]
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "context-mode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "context-mode"
      ]
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "context-mode-mcp",
      "command": "npx",
      "args": [
        "-y",
        "context-mode"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "context-mode-mcp": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "context-mode"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add context-mode-mcp -- npx -y context-mode

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: Context Mode

Stop wasting context on raw tool output

👤 Heavy Claude Code users who hit compaction mid-session ⏱ ~15 min intermediate

Когда использовать: You feel your agent "forget" after 30 minutes and burn $$ on re-reads.

Предварительные требования
  • Claude Code v1.0.33+brew upgrade claude-code or npm update -g @anthropic-ai/claude-code
Поток
  1. Install
    /plugin marketplace add mksglu/context-mode
    /plugin install context-mode@context-mode✓ Скопировано
    → Plugin registers hooks + 6 sandbox tools
  2. Verify
    /context-mode:ctx-doctor✓ Скопировано
    → All checks [x]
  3. Use normally
    Now do a big task that would normally blow context — e.g. analyze all .log files under /var/log✓ Скопировано
    → ctx_execute used instead of raw Read; output indexed not dumped
  4. Check savings
    /context-mode:ctx-stats✓ Скопировано
    → Per-tool reduction ratio reported

Итог: Same task, 10x longer before compaction, and the agent remembers.

Подводные камни
  • Other MCPs bypass the routing — Pass their tool calls through ctx_batch_execute for consistent accounting
Сочетать с: serena

Resume a long task seamlessly after the model compacts

👤 Devs on multi-hour agent sessions ⏱ ~5 min beginner

Когда использовать: Your task is too big to fit in one context window.

Поток
  1. Start with --continue
    [CLI flag] claude --continue✓ Скопировано
    → Prior session's SQLite loaded
  2. Observe
    What did I last ask you about? What tasks are in progress?✓ Скопировано
    → Accurate recap from FTS5 index, not hallucinated

Итог: A genuinely resumable workflow.

Подводные камни
  • Forgetting --continue starts fresh — Persistence requires --continue; absence means deliberate fresh start

Комбинации

Сочетайте с другими MCP — эффект x10

context-mode-mcp + serena

Serena for semantic code nav, context-mode for keeping its output out of context

Use serena for the lookup, ctx_execute to post-process the results.✓ Скопировано
context-mode-mcp + playwright

Page snapshot output stays sandboxed

Snapshot the page via playwright, let context-mode hold it — search it instead of dumping.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
ctx_execute code: str (js/python) Run a script to process data; output only what's needed free
ctx_batch_execute ops: [{tool, args}] Wrap multiple tool calls through the sandbox free
ctx_index content: str, tags?: [] Stash data for later retrieval free
ctx_search query: str Retrieve from session index free
ctx_fetch_and_index url: str Pull a URL, keep it out of context but searchable free
ctx_stats none See how much context was saved free

Стоимость и лимиты

Во что обходится

Квота API
Local
Токенов на вызов
Dramatic reduction — quoted 98% on real sessions
Деньги
Free (ELv2 license)
Совет
The bigger the session, the bigger the win — use on long tasks

Безопасность

Права, секреты, радиус поражения

Хранение учётных данных: Session SQLite in ~/.context-mode/
Исходящий трафик: None

Устранение неполадок

Частые ошибки и исправления

ctx-doctor shows missing hooks

Restart Claude Code fully after install; hooks register at startup

Проверить: Re-run /context-mode:ctx-doctor
Sandbox won't execute code

Node/Python runtime missing. Doctor tells you which. Install with brew/asdf.

Search returns nothing

Verify FTS5 built: sqlite3 ~/.context-mode/session.db "SELECT name FROM sqlite_master". Reinstall if broken.

Альтернативы

Context Mode в сравнении

АльтернативаКогда использоватьКомпромисс
Raw Claude Code (no plugin)Short sessions that never hit compactionNo context saving
claude-memYou want the memory layer without the sandbox-tool paradigmDifferent tradeoff — memory only, no tool output sandbox

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills