Local Token-Saving MCP Server, Multi-Language AST & Markdown Indexer, Named Docs Search, and Output Digest Engine (h:ID) for AI Coding Agents.
lee is a single standalone Rust binary engineered to cut token consumption by 60%–85% across coding sessions in Antigravity CLI (agy), Claude Code, and other Model Context Protocol (MCP) clients—with 100% offline execution, zero ML models, and zero network calls.
-
Pillar 1 — Precision AST, Config & Markdown Index (
tree-sitter+ PageRank Graph +blake3Parallel Indexing): Extracts symbol signatures for Rust, TypeScript/JS, Svelte, Python, and Go; key ranges for.toml/.yml/.json; and#–####headings for.md/.mdx(fence- & YAML-frontmatter-aware).project_mapranks files via PageRank centrality oversymbol_refs,read_symbolsupports batch reading (symbols) and fuzzy subsequence/bigram matching,smart_grepsupportswhole_word(-w), andfind_referencestraces 2-hop caller impact. -
Pillar 2 — Column-Weighted Workspace & Global Docs Search (
SQLite FTS5 BM25): Stores per-project caches centrally in~/.config/lee/projects/<name>-<hash>/lee.db(zero.lee/files or.gitignoreedits in your repos!) and global docs once in~/.config/lee/global.db. Splits.md/.mdxinto fence-safe windows (never cutting code blocks) and indexes full multi-language code files inside registered docs. Column-weighted FTS5 BM25 (heading = 10x,file_path = 5x) withcamelCase/snake_casesubword decomposition and prefix matching ("token"*). Sync incrementally vialee docs update. -
Pillar 3 — Output Digest & Handle Store (
h:ID+ ANSI Strip & Never-Worse Guard): Executes noisy build/test/diff commands (cargo,nextest,vitest,jest,tsc,pytest,go test,kaye diff,git diff) throughrun_digest. Outputs$\le 35$ lines pass through cleanly without header wrappers (preserving JSON); outputs$> 35$ lines are saved to SQLite underh:<6-char-blake3>for targetedrecall(key="h:ID", item="NAME").
flowchart TD
Agent["AI Coding Agent (Antigravity CLI agy / Claude Code)"]
MCP["lee serve (JSON-RPC 2.0 over stdio — 8 Tools)"]
Sec["Security Guard\n(HOME/Root Guard + Canonical Confinement + Secret Deny-List + 2MB Cap)"]
subgraph Pillars["Three Deterministic Pillars"]
Indexer["Pillar 1: Parallel AST & Graph Indexer\n(tree-sitter + PageRank + Batch/Fuzzy read_symbol + 2-Hop Refs + smart_grep)"]
DocSearch["Pillar 2: Column-Weighted FTS5 Docs Search\n(Fence-Safe .md/.mdx & Full Multi-Language Code Docs)"]
Digest["Pillar 3: Command & Diff Digest Engine\n(Cargo / Vitest / Jest / TSC / Pytest / Go / Diff + h:ID Handles)"]
end
subgraph Storage["Centralized Offline SQLite WAL (~/.config/lee/)"]
LocalDB[("Per-Project ~/.config/lee/projects/<name>-<hash>/lee.db\nfile_hashes | symbols | symbol_refs | doc_sections_fts | handles")]
GlobalDB[("Shared ~/.config/lee/global.db\nGlobal Docs Indexed Once Across All Repos")]
end
Agent <-->|"8 MCP Tools"| MCP
MCP --> Sec
Sec --> Indexer
Sec --> DocSearch
Sec --> Digest
Indexer --> LocalDB
DocSearch --> LocalDB
DocSearch --> GlobalDB
Digest --> LocalDB
cargo install --path .Run once from anywhere — no per-repo lee init needed for new projects (any repo you open auto-indexes into ~/.config/lee/projects/<name>-<hash>/lee.db on first MCP call):
lee init # Installs global Antigravity PreToolUse plugin (~/.gemini/config/plugins/lee/) & ~/.config/lee/# Register a workspace doc (`--w`, default) or global doc (`--g`, stored once in global.db):
lee add-docs /home/user/docs/my-lib
lee add-docs --g /home/user/docs/my-lib --name "my lib"
# List registered docs or output JSON for agents/scripts:
lee docs
lee docs --json
# Incrementally sync modified/added/removed files across workspace & global docs (skips unchanged):
lee docs update
# Remove a doc (interactive menu, by name, number, path, or --all):
lee rm-docs
lee rm-docs "my lib" --gAdd to ~/.gemini/config/mcp_config.json (Antigravity CLI) or .mcp.json / ~/.claude.json (Claude Code):
{
"mcpServers": {
"lee": {
"command": "lee",
"args": ["serve"]
}
}
}| # | Tool Name | Key Parameters | Purpose |
|---|---|---|---|
| 1 | project_map |
subpath?, max_tokens? (def: 800) |
PageRank-prioritized directory tree, AST symbols, # headings, and [start..end] ranges. |
| 2 | outline |
file, max_tokens?, include_tests?
|
AST symbol table, # heading TOC (.md/.mdx), or config keys (.toml/.yml/.json). |
| 3 | read_symbol |
file?, symbol?, symbols?, start_line?, end_line?, context_lines?, strip_comments?, signatures_only?, max_lines?
|
Exact line-range reader supporting batch symbols, workspace-wide fuzzy lookup, comment stripping, & AST signatures_only. |
| 4 | find_references |
symbol |
Lists AST import/type_use/call references, enclosing caller functions, and 2-hop caller impact. |
| 5 | search_docs |
query, doc?, scope? ("workspace" / "global" / "all"), file_filter?, budget_tokens? (def: 800) |
Column-weighted SQLite FTS5 BM25 search across .md/.mdx sections and full multi-language code docs. |
| 6 | smart_grep |
pattern, path?, glob?, files_only?, case_insensitive?, whole_word?, max_per_file?, max_results?
|
File-grouped regex search (rg -l / rg -n / rg -w) annotated with enclosing AST symbols or headings. |
| 7 | run_digest |
command, cwd?
|
Runs noisy build/test/diff commands; outputs h:ID. |
| 8 | recall |
key, item?, failures_only?, filter?, start_line?, end_line?
|
Pulls a single test/symbol/diff block, failures, regex filter, or line range from handle h:ID. |
lee init # One-time global setup (~/.gemini/config/plugins/lee/ & ~/.config/lee/)
lee exec <COMMAND...> # Execute a shell command and compress its output via run_digest
lee docs [--json] # List registered workspace & global docs (`--json` for LLMs)
lee docs update # Incrementally update changed/new/deleted files in workspace & global docs
lee add-docs <PATH> [--w|--g] [--name <NAME>] # Register a named workspace (`--w`) or global (`--g`) docs dir
lee rm-docs [NAME|PATH|NUM|--all] [--w|--g] # Remove a registered doc (supports interactive numbered menu)
lee index # Scan & pre-index current project + global docs in parallel
lee status # Show workspace & global index counts and registered docs
lee undo [-y] # Remove centralized cache (and any legacy .lee/ files) for current project
lee hook <antigravity|claude> # PreToolUse command-rewriting hook
lee serve # Run the JSON-RPC 2.0 MCP server over stdin/stdout- 100% Offline, Zero Network Calls: No ML models or network dependencies.
-
Workspace Safety Guards: Refuses to scan
$HOME,$HOME/.config, or/(specific subdirs like~/.config/omarchywork safely in isolated caches), skips heavy cache/browser/toolchain dirs (.cargo,.rustup,.local,.venv,node_modules,target,Cache,chromium, etc.), caps at 15,000 files & 2 MB per file, and bounds SQLite WAL viajournal_size_limit = 64 MB. -
Canonical Path Confinement & Secret Deny-List: Rejects paths escaping the project root / registered docs and blocks
.env*,*.pem,*.key,*.p12,*.pfx,id_rsa*,id_ed25519*,*secret*,*credentials*.