Home/AI Agents/lean-ctx
lean-ctx logo

lean-ctx

yvgude/lean-ctx

Control what your AI can see by serving context with a local Rust binary.

GraphCanon updated 2w · GitHub synced 2w

3.5k stars312 forksLast push 2w Rust Apache-2.0

Decision brief

LeanCTX serves as a context intelligence layer for AI agents, providing localized control over read access and memory management while optimizing token usage for numerous MCP tools, all powered by a local Rust binary.

Good fit when

  • When you require granular, localized oversight over what your AI can visualize, learn from, and store within its operations.
  • If your project involves more than 70 MCP tools or uses multiple programming languages and needs token optimization to keep costs down.

Avoid when

  • When there is a dependence on cloud-based solutions for context intelligence, since LeanCTX operates as a local binary.
  • If your setup does not need context layering or token optimization. In such cases, using LeanCTX would incur overhead without providing significant benefits.

Observed Jul 14, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Very active (0d since push)
As of 2w
Provenance
Not a fork · Personal account
As of 2w
Security (OSV)
No MCP manifest
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

cargo add lean-ctx
crates.io

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

LeanCTX acts as a context intelligence layer for AI agents, controlling read access and memory management locally. It supports token optimization for more than 70 MCP tools with support for multiple programming languages.

Capability facts

Languages
rust

Source: github.language · Aug 4, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

LangChain integrationLangChain

Source: README excerpt (regex_v1, Aug 4, 2026)

Framework adapters included (LiteLLM, LangChain, Vercel AI SDK). → **[compress() cookbook](docs/guides/compress-sdk.md)**
Source link
Node.js runtimeNode.js

Source: README excerpt (regex_v1, Aug 4, 2026)

npm install -g lean-ctx-bin # Node.js
Source link
Python runtimePython

Source: README excerpt (regex_v1, Aug 4, 2026)

pip install lean-ctx-client # Python (imports as `leanctx`)
Source link

Tags

README

1) Install (pick one)

curl -fsSL https://leanctx.com/install.sh | sh # universal (no Rust needed) brew tap yvgude/lean-ctx && brew install lean-ctx # macOS / Linux npm install -g lean-ctx-bin # Node.js cargo install lean-ctx # Rust pi install npm:pi-lean-ctx # Pi Coding Agent


pip install lean-ctx-sdk

from lean_ctx import compress messages = compress(messages, model="claude-sonnet-4")


```ts
// npm install lean-ctx-sdk
import { compress } from "lean-ctx-sdk";
messages = await compress(messages, { model: "gpt-4o" });

Framework adapters included (LiteLLM, LangChain, Vercel AI SDK). → compress() cookbook

Thin /v1 contract clients — lean-ctx-client (npm · crates.io). Wrap the full /v1 tool, event and session API over the process boundary — never links the engine, so it stays stable as lean-ctx evolves.

pip install lean-ctx-client     # Python (imports as `leanctx`)
npm install lean-ctx-client     # TypeScript / Node
cargo add lean-ctx-client       # Rust

Start the server with lean-ctx serve, then point a client at it. → API reference


License

Apache License 2.0 — see LICENSE.

--- lean-ctx: ctx_compose bundles search+read+symbols in one call ---

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.