Lean Ctx logo

Lean Ctx

Local context gateway for MCP workflows that selects, controls, compresses, and records context from files, tools, and configured providers.

Install Lean Ctx

Pick your client, then add it in one click or paste the config.

No confirmed install command yet

We only publish a config when the install details come from the project itself — its README, its docs, or a verified owner. We haven’t found those for lean-ctx, and we’d rather show nothing than a guess you’d paste into your client.

Open setup steps on GitHub

Overview

lean-ctx MCP server places a local context gateway between AI tools and the information they read. It selects task-relevant file and command context, applies configured path permissions, filters, and budgets on supported paths, and records observable context operations and delivery evidence. Its CLI, MCP, hooks, and proxy paths suit developers improving existing coding workflows without handing model selection or agent-loop control to the gateway. Reach for it when repeated reads, noisy shell output, cross-session task records, or inspectable context decisions matter.

Use cases

  • Reduce repeated file reads in coding-agent workflows
  • Compress noisy Git, npm, Cargo, or infrastructure command output
  • Apply configured filesystem and content controls to supported context paths
  • Retain task findings and decisions across local sessions
  • Inspect context references, policy decisions, and usage evidence

Key features

  • Multi-mode file reads with maps, signatures, diffs, ranges, and density views
  • AST-aware processing for 27 languages
  • Recognized shell-output compression for common developer tools
  • Path permissions, content filters, and context budgets
  • Session records and source recovery references
  • CLI, MCP, hooks, and supported proxy paths

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked Today

Recent health check succeeded.

18/18 checks healthy over the last 11d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars3.9kStargazers on the source repository.
Last commitTodayMost recent push to the default branch.

How Lean Ctx works

What lean-ctx does

lean-ctx acts as a local context gateway for AI applications and coding tools. It sits between sources such as files, repositories, tool results, and configured providers and the host application or agent. The gateway selects material relevant to a task, applies supported controls, and delivers a prepared result while leaving the agent loop and model calls with the host.

Its selection layer supports focused file views, structural information, compression, reuse, and references for recovering source detail. It can also retain local task, finding, and decision records across sessions, connecting code with local knowledge according to configured access and retention rules. This continuity is context storage and retrieval, not model training.

How it works

File reads support multiple views, including complete content, maps, signatures, diffs, line ranges, and density-based reduction. Density mode deterministically keeps higher-entropy lines until an approximate target proportion of the original tokens remains. Signature views can identify line spans for later targeted expansion. Supported shell paths recognize many common outputs from tools such as Git, npm, Cargo, Docker, kubectl, and Terraform.

Tree-sitter-based handling provides structural processing for 27 languages. Compact results can retain source or archive references for later expansion through ctx_expand or the reference API. Recovery depends on permissions, retention settings, and continued availability of the source.

Setup and configuration

The open-source engine runs locally through its CLI, MCP interface, hooks, and supported proxy paths. Existing AI-tool integrations can be configured with lean-ctx setup. The project is distributed through Rust, npm, and Arch Linux package channels, including the lean-ctx-bin npm package and the lean-ctx AUR package.

Configuration controls the filesystem scope, roles, content-filter behavior, context budgets, and retention rules. The available controls and their enforcement vary by integration and supported path. Telemetry is configurable.

Tools and capabilities

  • Select focused file content through read modes, structural views, and density compression.
  • Compress recognized shell output while retaining references where supported.
  • Restrict filesystem access with configured PathJail scopes and roles.
  • Warn, redact, or block supported content through configured detectors.
  • Apply context budgets to selected input and supported tool output.
  • Preserve task records and inspect source references, policy decisions, and usage evidence.

Limitations and notes

Controls apply only to supported calls and integrations. A filesystem boundary is not an operating-system sandbox. Detection coverage and enforcement depend on configuration and integration support. Context-only operation records the prepared result; the host owns the subsequent model call, model choice, task orchestration, and agent loop. Source recovery also requires suitable permissions, retention, and source availability.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Lean Ctx

lean-ctx is an MCP server that connects AI tools to files, repositories, tool results, and configured providers through a local context gateway. Its main capabilities select relevant context, apply supported access and content controls, preserve local task records, and expose source references and usage evidence while the host retains model control.

Configure an existing supported AI-tool integration with `lean-ctx setup`. The open-source engine also runs locally through its CLI, MCP interface, hooks, and supported proxy paths, with distribution channels including Rust, npm, and Arch Linux packages.

Yes, Cursor is one of the coding workflows recommended as a starting point for lean-ctx. Its exact capabilities depend on the configured integration and which context paths that integration supports.

Yes, supported paths can use configured PathJail scopes and roles to constrain filesystem access. These controls apply to supported calls and are a configured filesystem boundary, not an operating-system sandbox.

No, the host application chooses the model and performs model calls outside the Engine's observed path. lean-ctx prepares and controls supported context, while the host retains the task, agent loop, and model workflow.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewLean Ctx AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/lean-ctx?style=directory)](https://allmcps.com/mcp/lean-ctx)
HTML Embed
<a href="https://allmcps.com/mcp/lean-ctx"><img src="https://allmcps.com/api/badge/lean-ctx?style=directory" alt="Lean Ctx on AllMCPs" /></a>