yvgude/lean-ctx
Hybrid Context Optimizer — Shell Hook + MCP Server. Reduces LLM token consumption by 89-99%. Single Rust binary, zero dependencies.
Platform-specific configuration:
{
"mcpServers": {
"lean-ctx": {
"command": "npx",
"args": [
"-y",
"lean-ctx"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
Hybrid Context Optimizer — Shell Hook + MCP Server. Single Rust binary, zero dependencies.
[](https://crates.io/crates/lean-ctx) [](rust/LICENSE)
Website · Install · Quick Start · CLI Reference · MCP Tools · vs RTK
---
lean-ctx reduces LLM token consumption by 89-99% through two complementary strategies in a single binary:
| Operation | Frequency | Standard | lean-ctx | Savings | |---|---|---|---|---| | File reads (cached) | 15x | 30,000 | 195 | -99% | | File reads (map mode) | 10x | 20,000 | 2,000 | -90% | | ls / find | 8x | 6,400 | 1,280 | -80% | | git status/log/diff | 10x | 8,000 | 2,400 | -70% | | grep / rg | 5x | 8,000 | 2,400 | -70% | | cargo/npm build | 5x | 5,000 | 1,000 | -80% | | Test runners | 4x | 10,000 | 1,000 | -90% | | curl (JSON) | 3x | 1,500 | 165 | -89% | | docker ps/build | 3x | 900 | 180 | -80% | | Total | | ~89,800 | ~10,620 | -88% |
> Estimates based on medium-sized TypeScript/Rust projects. MCP cache hits reduce re-reads to ~13 tokens each.
cargo install lean-ctxgit clone https://github.com/yvgude/lean-ctx.git
cd lean-ctx/rust
cargo build --release
cp target/release/lean-ctx ~/.local/bin/> Add ~/.local/bin to your PATH if needed: > ```bash > echo 'export PATH="$HOME/.local/bin:$PA
Loading reviews...