/ Annuaire / Playground / Context Mode
● Communauté mksglu ⚡ Instantané

Context Mode

par 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.

Pourquoi l'utiliser

Fonctionnalités clés

Démo en direct

Aperçu en pratique

context-mode-mcp.replay ▶ prêt
0/0

Installer

Choisissez votre client

~/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"
      ]
    }
  }
}

Ouvrez Claude Desktop → Settings → Developer → Edit Config. Redémarrez après avoir enregistré.

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

Cursor utilise le même schéma mcpServers que Claude Desktop. La config projet l'emporte sur la globale.

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

Cliquez sur l'icône MCP Servers dans la barre latérale Cline, puis "Edit Configuration".

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

Même format que Claude Desktop. Redémarrez Windsurf pour appliquer.

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

Continue utilise un tableau d'objets serveur plutôt qu'une map.

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

Ajoutez dans context_servers. Zed recharge à chaud à la sauvegarde.

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

Une seule ligne. Vérifiez avec claude mcp list. Supprimez avec claude mcp remove.

Cas d'usage

Usages concrets : Context Mode

Stop wasting context on raw tool output

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

Quand l'utiliser : You feel your agent "forget" after 30 minutes and burn $$ on re-reads.

Prérequis
  • Claude Code v1.0.33+brew upgrade claude-code or npm update -g @anthropic-ai/claude-code
Déroulement
  1. Install
    /plugin marketplace add mksglu/context-mode
    /plugin install context-mode@context-mode✓ Copié
    → Plugin registers hooks + 6 sandbox tools
  2. Verify
    /context-mode:ctx-doctor✓ Copié
    → 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✓ Copié
    → ctx_execute used instead of raw Read; output indexed not dumped
  4. Check savings
    /context-mode:ctx-stats✓ Copié
    → Per-tool reduction ratio reported

Résultat : Same task, 10x longer before compaction, and the agent remembers.

Pièges
  • Other MCPs bypass the routing — Pass their tool calls through ctx_batch_execute for consistent accounting
Combiner avec : serena

Resume a long task seamlessly after the model compacts

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

Quand l'utiliser : Your task is too big to fit in one context window.

Déroulement
  1. Start with --continue
    [CLI flag] claude --continue✓ Copié
    → Prior session's SQLite loaded
  2. Observe
    What did I last ask you about? What tasks are in progress?✓ Copié
    → Accurate recap from FTS5 index, not hallucinated

Résultat : A genuinely resumable workflow.

Pièges
  • Forgetting --continue starts fresh — Persistence requires --continue; absence means deliberate fresh start

Combinaisons

Associez-le à d'autres MCPs pour un effet 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.✓ Copié
context-mode-mcp + playwright

Page snapshot output stays sandboxed

Snapshot the page via playwright, let context-mode hold it — search it instead of dumping.✓ Copié

Outils

Ce que ce MCP expose

OutilEntréesQuand appelerCoût
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

Coût et limites

Coût d'exécution

Quota d'API
Local
Tokens par appel
Dramatic reduction — quoted 98% on real sessions
Monétaire
Free (ELv2 license)
Astuce
The bigger the session, the bigger the win — use on long tasks

Sécurité

Permissions, secrets, portée

Stockage des identifiants : Session SQLite in ~/.context-mode/
Sortie de données : None

Dépannage

Erreurs courantes et correctifs

ctx-doctor shows missing hooks

Restart Claude Code fully after install; hooks register at startup

Vérifier : 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.

Alternatives

Context Mode vs autres

AlternativeQuand l'utiliserCompromis
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

Plus

Ressources

📖 Lire le README officiel sur GitHub

🐙 Voir les issues ouvertes

🔍 Parcourir les 400+ serveurs MCP et Skills