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 entire codebase with tree-sitter and AST parsing. Extract functions, classes, imports, and call relationships automatically. Supports 12 languages: Go, TypeScript, Python, Rust, Java, Kotlin, Bash, Ruby, PHP, Perl, R, and Elixir.
MCP Server Integration
Expose your knowledge graph via MCP (Model Context Protocol). Connect seamlessly with Claude, Cursor, OpenCode, Gemini, Kilo, Codex, and Google Antigravity. AI tools query your graph instead of scanning the whole codebase.
Auto-Trigger Sessions
Session hooks inject LeanKG context into every AI tool session automatically. PreToolUse hooks route search intents to LeanKG tools. Token-optimized context without manual prompting.
Impact Radius Analysis
Compute blast radius before making changes. Build call graphs with IMPORTS, CALLS, and TESTED_BY edges. Understand exactly what your changes will affect.
WebGL Graph Visualization
Visualize your codebase's dependency graph with force-directed layout, WebGL rendering, and community clustering. Filter by element type, zoom, pan, and click nodes for details.
Obsidian Sync
Push LeanKG data to Obsidian notes and pull annotation edits back. Watch vault for changes and auto-sync. Keep your knowledge graph and notes in sync.
Local-First Architecture
Everything runs on your machine. Privacy-first, no cloud required. SQLite storage keeps your code private and secure. Zero external database connections.
The numbers speak
for themselves.
Across five structural questions about a real codebase, querying the knowledge graph consumed ~3,400 tokens versus ~412,000 tokens using file-by-file search — a 121x average reduction.
| Query Type | LeanKG (tokens) | File-by-file (tokens) | Savings |
|---|---|---|---|
| Find function by pattern | ~200 | ~45,000 | 225x |
| Trace call chain (depth 3) | ~800 | ~120,000 | 150x |
| Dead code detection | ~500 | ~85,000 | 170x |
| List all routes | ~400 | ~62,000 | 155x |
| Architecture overview | ~1,500 | ~100,000 | 67x |
Total Tokens (Graph)
~3,400
vs 412,000 traditional
Average Savings
121x
per query set
Token Cost Reduction
99.2%
at $3-15 per million
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
Works with your
favorite AI tools.
Official MCP integration. Supported by Claude, Cursor, OpenCode, and more.
One-line install for any AI tool: