LeanCTX
Local context layer for coding agents: cached, compressed file reads, shell output and session memory
Keeps large tool output out of a coding agent's context by running it in a sandbox and indexing it locally.
By Mert Köseoğlu (individual) JavaScript Local · stdio Developer toolsKnowledge and memory
103 popularity score ★ 34k ↓ 67k/wk
Opens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.
npm i -g context-modeclaude mcp add context-mode -- context-mode server --agent '<AGENT_ID>'{
"mcpServers": {
"context-mode": {
"command": "context-mode",
"args": [
"server",
"--agent",
"<AGENT_ID>"
]
}
}
}{
"mcpServers": {
"context-mode": {
"command": "context-mode",
"args": [
"server",
"--agent",
"<AGENT_ID>"
]
}
}
}{
"servers": {
"context-mode": {
"type": "stdio",
"command": "context-mode",
"args": [
"server",
"--agent",
"<AGENT_ID>"
]
}
}
}[mcp_servers.context-mode]
command = "context-mode"
args = ["server", "--agent", "<AGENT_ID>"]gemini mcp add --scope user context-mode context-mode -- server --agent '<AGENT_ID>'Context Mode sits between a coding agent and the big outputs it would otherwise read whole: files, logs, command output and web pages. The agent sends a short script to ctx_execute, the script reads the data in a subprocess, and only what it prints comes back into the conversation. Larger results go into a per-project SQLite database (context.db under ~/.context-mode), split into chunks and searchable with FTS5, so the agent can pull back just the parts it asks for with ctx_search.
On agents with hooks, the plugin also steers the agent toward these tools. A PreToolUse hook stops a full-file Read over 16,384 bytes, WebFetch and curl calls and similar dumps, and names the ctx_* call to use instead. The hooks keep a journal of prompts, edits, commands and errors, and after compaction ctx_resume hands back a state block of at most 2,048 bytes.
The README covers 10 agents: Claude Code, Codex, Gemini CLI, Qwen Code, Pi, OpenCode, Copilot CLI, Kiro, VS Code and ZCode. Each has its own install command, and `context-mode setup` after a global npm install configures any of them. The code at this release names five languages for ctx_execute (shell, powershell, javascript, typescript and python) and also accepts any other runtime on PATH. The MCP server needs an --agent argument to find the project, except under Claude Code, where it reads CLAUDE_PROJECT_DIR.
The README also advertises Context Mode Gateway, a separate hosted service with its own account and subscription that proxies requests to Anthropic and OpenAI. That is not part of this package. The license is Elastic License 2.0, which is source-available and bars offering it to others as a hosted service.
| Runtime | Node.js 24.15.0+ |
|---|---|
| Runs on | macOS, Windows, Linux |
| Also |
|
Suits developers on one of the 10 supported agents who keep hitting context limits from long logs, big files or fetched docs, and who want everything stored on their own machine. It needs Node 24.15 or later, which is newer than many machines carry. Since ctx_execute runs any code as your user, it fits setups where the agent's own permission prompts stay on. Teams that want memory shared across machines and agents are pointed by the makers to their hosted Gateway, which is a paid service that sees your requests.
3 only read, 5 change things, 1 can delete or overwrite.
ctx_execute changesctx_batch changesctx_index changesctx_searchctx_resumectx_statsctx_doctor changesctx_upgrade changesctx_purge deletes