context-mode

Introduction

context-mode is an MCP plugin that keeps raw data out of the LLM context window — run code in a sandbox, search a knowledge base, and only the answer enters the conversation.

Large language models reason inside a fixed context window. Every log line, API response, and file you read into that window is reasoning capacity you can't get back. A single unrouted command can drop tens of kilobytes of raw text into the conversation — and once it's there, it costs you for the rest of the session.

context-mode is an open-source MCP plugin that solves the other half of the context problem: instead of pulling raw data in, it runs the work out — in a sandbox — and returns only the derived answer.

The model writes a small program that processes the data and prints a summary. The raw bytes stay in the sandbox; only what you console.log() enters context. This is the Think in Code principle, and it routinely saves 95–99.9% of a payload's footprint.

How it works

context-mode wraps four mechanisms behind a handful of ctx_* tools:

  • Sandboxed execution — run code in 12 languages; only stdout returns.
  • An FTS5 knowledge base — index large outputs and recall them on demand with BM25 search, so nothing is read twice.
  • Web without the flood — fetch and index pages; raw HTML never enters context.
  • Session continuity — decisions, errors, and plans survive compaction, so a resumed session already knows what you were doing.

Start here

Why it matters

A session that would fill its window in ~30 minutes can stay productive for hours. You keep the same answers and the same work — at a fraction of the token cost — and your agent never loses the plot to a wall of raw output.

On this page