Skip to content

Summary

Local context gateway for coding agents: an MCP server with compressed file reads, shell-output compression, session memory and a code graph, so agents spend less context on noise.

Features

  • 16 file-read modes (map, signatures, diff, line ranges, budget compression) with cached re-reads
  • Shell hooks compress git, npm, cargo, docker, kubectl and terraform output
  • Tree-sitter structure for 27 languages and a property graph for impact analysis
  • Session memory and a project knowledge graph that persist across chats
  • Path jails, content filters and context budgets on supported calls
  • Local cockpit dashboard for token use, estimated cost and recorded calls
  • One-command setup for Cursor, Claude Code, Codex and 30+ other agents

Installation

Set up this MCP server in your favorite AI agent — copy a ready-made configuration below.

Any MCP-compatible agent

Most agents (Claude, Cursor, Windsurf, VS Code, and more) read a standard mcpServers configuration.

  1. Open your agent's MCP configuration file.
  2. Merge the snippet below into it.
  3. Restart the agent — the "LeanCTX" tools will be available.
{
  "mcpServers": {
    "lean-ctx": {
      "command": "lean-ctx",
      "args": [
        "mcp"
      ]
    }
  }
}

Description

LeanCTX sits between an AI coding tool and the files, repositories and command output it reads, and hands the agent only what the task needs. The open-source core is a single Rust binary that runs locally as an MCP server, a set of shell hooks and an optional request proxy; it leaves your agent loop and model choice alone.

The MCP side exposes a family of ctx_* tools. File reads come in 16 modes — a structural map, function signatures with line spans, diff, lines:N-M, entropy-based and budget-targeted compression among them — and a cached re-read returns a compact reference instead of the whole file again. Tree-sitter parsing covers 27 languages, and ctx_expand recovers the full source behind a compressed view. Shell hooks compress the output of git, npm, cargo, docker, kubectl, terraform and other common commands through 85+ patterns. Beyond reading, LeanCTX keeps session memory and a project knowledge graph across chats, builds a property graph of imports and calls for impact analysis and ranked search, offers LSP-backed symbol edits and call graphs, and can pull a web page, PDF or YouTube transcript into context as compressed text.

Controls and evidence are a large part of the pitch: path jails limit filesystem access, content filters can warn, redact or block, context budgets cap what goes through, and lean-ctx cockpit opens a local dashboard of token use, estimated cost and recorded calls. The README is careful to call its savings figures estimates rather than measured quality gains.

Install with the shell script, Homebrew, npm install -g lean-ctx-bin or cargo install lean-ctx, then run lean-ctx wrap cursor (or claude, codex) or lean-ctx onboard to register the MCP server with the agents it detects — more than 30 are supported. The open-source host is Apache-2.0; enterprise controls and an SDK are sold separately.

Related MCP Servers

See all LeanCTX alternatives
Featured

Builds a searchable markdown graph of your repo so coding agents stop re-exploring it on every task — reported 42% fewer tokens and 46% fewer tool calls.

MCP: Headroom

by Headroom Labs

Featured

Context-compression MCP server that shrinks tool outputs, logs, files and RAG chunks before they reach the model, cutting 60-95% of tokens on JSON payloads.

MCP: ripwire

by Red Hat

Featured

Red Hat's zero-dependency C++23 code-context engine — ranked call graphs and blast-radius analysis, indexing a repo in under half a second with no server and no database.

MCP: Concord

by Concord AI

New

Local-first MCP server that lets Claude Code, Codex, Cursor, Gemini CLI and other coding agents message each other, claim files and hand off tasks in one repo.

Browse all MCP servers →