The knowledge graphto save tokens
Index your codebase once. LeanKG queries only what AI needs with targeted subgraph retrieval. Works with Claude, Cursor, OpenCode, Gemini, Codex, and more.
Index once.
Query smarter.
Fast Code Indexing
Parse and index your codebase with tree-sitter AST parsing. Extract functions, classes, imports, and call relationships automatically. Supports 158+ languages including Go, TypeScript, Python, Rust, Java, Kotlin, Bash, Ruby, PHP, Perl, R, and Elixir.
Semantic Search with Embeddings
Optional dense-vector retrieval with cross-encoder reranking for contextual code search. Build embedding indices with HNSW support. Query by intent rather than syntax patterns.
MCP Server Integration
Expose your knowledge graph via MCP protocol. Connect seamlessly with Claude, Cursor, OpenCode, Gemini, Kilo, Codex, and Google Antigravity. 40 MCP tools available.
Auto-Trigger Session Hooks
Full lifecycle hooks inject LeanKG context into every AI session. Setup, SessionStart, PreToolUse, PostToolUse, and Stop hooks. Route search intents automatically.
Impact Radius & Blast Analysis
Compute code change impact radius before making changes. Build call graphs with IMPORTS, CALLS, and TESTED_BY edges. Classify risk as critical/high/medium/low.
Obsidian Vault Sync
Push LeanKG data to Obsidian notes and pull annotations back. Watch vault for changes and auto-sync. Full bidirectional integration with your knowledge management system.
RTK Compression & REST API
Run shell commands with token-saving compression. Full REST API with auth and API key management. Docker support with RocksDB backend for teams.
The numbers speak
for themselves.
Unified A/B benchmark across 19 test cases spanning all LeanKG tools. 30% input token savings with 3x better token efficiency compared to grep-based code search.
| Metric | LeanKG | Without LeanKG | Winner |
|---|---|---|---|
| Input Token Savings | 30.0% | 0% | LeanKG |
| Token Efficiency (tokens/result) | 2.09 | 6.39 | 3x better |
| Latency (simple queries) | 20.4ms | 20.2ms | Equal |
| Latency (complex queries) | 8.9s | 34.9ms | ⚠️ Heavy |
| Throughput (Load test) | ~57.6K/sec | N/A | Insert |
Input Token Savings
30%
across all tools
Token Efficiency Gain
3x
better than grep
Load Throughput
57.6K/sec
element insertion
Find Code by Intent
Not by Syntax
Dense-vector embeddings with cross-encoder reranking help AI tools find exactly what they need. Query by intent, get results by semantic relevance.
Top Results for: Find authentication patterns
Dense Embeddings
384-dimensional vectors capture semantic meaning
HNSW Indexing
Hierarchical Navigable Small World for fast similarity search
Cross-Encoder Reranking
Fine-grained relevance ranking for precise results
Why LeanKG
Side-by-side positioning against other local knowledge graph tools. Every figure comes from reproducible A/B benchmarks, not marketing copy.
Stop Burning Tokens
TOON format trims payloads by ~40%. 30% fewer input tokens and 3x better token efficiency compared to raw search.
85 MCP Tools
The broadest atomic surface in the category. Competitors ship 1-17. Query with surgical precision instead of blunt grep.
Built for Scale
Android-aware (XML, Hilt, Room). Microservice topologies linked with postmortems. Procedural ontologies alongside code metadata.
When LeanKG Wins
- ✓You pay per token - let the graph optimize every retrieval
- ✓You ship Android - only LeanKG understands XML, Hilt, Room, Navigation
- ✓You run microservices - graph links services to postmortems
- ✓You need fine-grained tools - impact radius, call graphs, dead code detection
Competitive Strengths
- codebase-memory-mcp: C/C++ indexing speed (Linux kernel in 3 min)
- GitNexus: Zero-server browser (WebAssembly + LadybugDB)
- graphify: Multi-modal (video, PDF, images)
- codegraph: Swift/React Native bridges across 17 frameworks
Feature Comparison
| Tool | MCP Tools | Token Format | Android | Microservices | Procedural |
|---|---|---|---|---|---|
| LeanKG | 85 | TOON | ✓ | ✓ | ✓ |
| codebase-memory-mcp | 15 | Standard | — | — | — |
| GitNexus | 17 | Standard | — | — | — |
| graphify | Std | Budget | — | — | — |
| codegraph | 1 | Standard | — | — | — |
Built on proven tech
Rust + CozoDB + tree-sitter. Local-first. No SaaS lock-in. Runs as an MCP HTTP server on :9699 or over stdio.
Works with your
entire codebase.
Full semantic type resolution for Python, TypeScript, Go, Rust, Java, Kotlin, C#, PHP, and C/C++. Syntactic parsing for 158+ languages.
Python
FullImports, dataclasses, generics, @property, async/await, Pydantic
TypeScript/JavaScript
FullGenerics, JSX, JSDoc inference, .d.ts, re-exports, method chaining
Go
FullGenerics, embedded structs, interface satisfaction, package resolution
Rust
Fulluse declarations, impl blocks, generics, trait bounds, UFCS, std prelude
Java
FullImports, class hierarchies, generics, annotations, lambdas, JDK stdlib
Kotlin
FullClasses, objects, extensions, data classes, scope functions, stdlib
C#
FullGlobal usings, records, LINQ, async Task, generics, BCL stdlib
PHP
FullNamespaces, traits, late-static-binding, PHPDoc inference
C/C++
FullMacros, typedef chains, templates, namespaces, auto inference
+ 149 more
SyntaxTree-sitter parsing support for all major languages
Why multiple language levels?
Full support means semantic type resolution powered by Hybrid LSP — the graph understands imports, generics, inheritance, and stdlib types just like an IDE would. Syntax support means tree-sitter parsing captures structure and declarations. Both give you accurate call graphs and dependency tracking.
Three simple steps.
Targeted context. Not full scans.
1# Initialize LeanKG2leankg init34# Index your codebase5leankg index ./src67# Auto-index on changes8leankg watch ./src910# Status check11leankg status
85 MCP tools.
The broadest surface.
More atomic tools than any competitor (1-17). Query with surgical precision instead of blunt grep. Works with Claude, Cursor, OpenCode, Gemini, and more.
One-line install for any AI tool: