
LeanKG
by FreePeak·★ 188·Score 50
LeanKG is a local-first knowledge graph that indexes codebases and exposes them via MCP for AI-assisted development with significant token savings.
Overview
LeanKG is a Rust-based local knowledge graph designed to provide AI coding tools with accurate codebase context. It indexes code files, builds dependency graphs, and exposes an MCP server that allows AI tools like Cursor, OpenCode, and Claude Code to query the knowledge graph directly. The system offers features such as impact radius calculation, dependency graph visualization, token optimization, and multi-language support. Unlike cloud-based solutions, LeanKG operates locally without external database dependencies, addressing the high token consumption problem when AI tools process full codebase context.
Try asking AI
After installing, here are 7 things you can ask your AI assistant:
When to choose this
Choose LeanKG when you need a local, self-hosted knowledge graph to improve AI coding tools' accuracy with codebase context without cloud dependencies.
When NOT to choose this
Don't choose LeanKG if you need cloud-based collaboration features or require write access to the knowledge graph, as it's primarily a read-only system.
Tools this server exposes
12 tools extracted from the READMEsearch_codeSearch for code patterns or specific implementations in the knowledge graph
find_dependenciesFind dependencies between code elements and analyze impact radius
get_element_infoRetrieve detailed information about a specific code element
detect_clustersIdentify functional code communities and clusters in the codebase
trace_featureTrace feature implementation across the codebase
annotate_codeAdd annotations to code elements for better context
export_graphExport the knowledge graph in various formats
analyze_qualityAnalyze code quality and find oversized functions
get_metricsView token savings and context reduction metrics
detect_changesDetect changes in codebase and classify risk level
run_commandExecute shell commands with RTK compression to save tokens
register_repoRegister a new repository for multi-repo context management
Comparable tools
Installation
Installation
One-Line Install (Recommended)
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- <target>Supported targets include: cursor, claude, opencode, kilo, antigravity, gemini, codex
Install via Cargo
cargo install leankg && leankg --versionClaude Code Integration
# Install with Claude Code hooks
leankg setup
# Restart Claude Code or run:
/reload-pluginsConfiguration
LeanKG creates MCP configuration during setup. For manual setup, see docs/mcp-tools.md for MCP server configuration.
FAQ
- What AI tools does LeanKG support?
- LeanKG supports Cursor, Claude Code, OpenCode, Kilo Code, Gemini CLI, Google Antigravity, and Codex with varying levels of integration including auto-setup, session hooks, and plugins.
- How does LeanKG reduce token consumption?
- Instead of processing full codebase context, LeanKG builds a knowledge graph that allows AI tools to query targeted subgraphs, reducing context tokens from 15,000-45,000 to focused relevant code.
- Is LeanKG cloud-based?
- No, LeanKG is a local-first solution that operates entirely on your machine without cloud services or external database dependencies.
Compare LeanKG with
Last updated · Auto-generated from public README + GitHub signals.