LeanKG Knowledge Graph
LeanKG: Stop Burning Tokens. Start Coding Lean.
What is LeanKG Knowledge Graph?
LeanKG Knowledge Graph is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to leankg: stop burning tokens. start coding lean.
LeanKG: Stop Burning Tokens. Start Coding Lean.
This server falls under the Knowledge & Memory category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- LeanKG: Stop Burning Tokens. Start Coding Lean.
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx leankgConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use LeanKG Knowledge Graph
LeanKG is a token-efficient knowledge graph MCP server built in Rust that indexes your codebase into a graph database and exposes 40 MCP tools for querying relationships, calculating blast radius, finding dependencies, and visualizing microservice topologies without flooding the AI context window. It supports both SQLite (for local single-developer use) and RocksDB (for team deployments), and integrates with Claude Code, Cursor, OpenCode, Gemini, Kilo, and Antigravity. Developers use LeanKG to give AI agents precise, structured knowledge about large codebases rather than pasting raw files, dramatically reducing token usage while improving code navigation accuracy.
Prerequisites
- Rust 1.75+ (if building from source) or use the install script for pre-built binaries
- macOS or Linux operating system
- Docker and Docker Compose (optional, for RocksDB team deployment mode)
- An MCP-compatible client: Claude Code, Cursor, Gemini CLI, OpenCode, or Kilo
Install LeanKG using the one-line install script
Use the official install script and specify your target client. Supported targets are: opencode, cursor, claude, gemini, kilo, antigravity.
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- claudeInitialize LeanKG in your project
Run `leankg init` in your project root to set up the knowledge graph database. Then index your source directory.
cd /path/to/your/project
leankg init
leankg index ./src(Optional) Enable file watching for continuous indexing
Start the file watcher to automatically update the knowledge graph as you edit code, keeping the graph in sync with your changes.
leankg watch ./srcConfigure Claude Desktop manually (if not using the install script)
Add LeanKG as an MCP server in claude_desktop_config.json pointing to the leankg binary and your project database.
{
"mcpServers": {
"leankg": {
"command": "leankg",
"args": ["mcp"],
"env": {
"LEANKG_DB_ENGINE": "sqlite",
"LEANKG_AUTO_INDEX": "1"
}
}
}
}Verify token savings and explore the knowledge graph
Use the LeanKG CLI to check your graph metrics and token savings, and optionally launch the web UI for visual exploration.
leankg metrics --json # View token savings statistics
leankg impact src/main.rs --depth 3 # Calculate blast radius for a file
leankg web # Launch visual graph UI at localhost:8080LeanKG Knowledge Graph Examples
Client configuration
Claude Desktop config for LeanKG with SQLite storage and auto-indexing enabled
{
"mcpServers": {
"leankg": {
"command": "leankg",
"args": ["mcp"],
"env": {
"LEANKG_DB_ENGINE": "sqlite",
"LEANKG_AUTO_INDEX": "1",
"LEANKG_CACHE_MAX_TOKENS": "500000"
}
}
}
}Prompts to try
Queries that leverage LeanKG's graph-based code knowledge to help with large codebases
- "What files would be affected if I change the UserService class?"
- "Show me the dependency graph for the authentication module"
- "Which functions call the database connection pool directly?"
- "What is the blast radius of modifying src/api/routes.rs?"Troubleshooting LeanKG Knowledge Graph
'leankg: command not found' after installation
The install script places the binary in ~/.local/bin or ~/bin. Ensure this directory is in your PATH by adding `export PATH="$HOME/.local/bin:$PATH"` to your shell profile (.bashrc or .zshrc) and reloading with `source ~/.zshrc`.
Knowledge graph is out of date after code changes
Run `leankg index ./src` again to reindex, or start the file watcher with `leankg watch ./src` to keep the graph synchronized automatically as files change.
High memory usage with large codebases
Reduce the memory-mapped I/O window by setting `LEANKG_MMAP_SIZE` to a smaller value (e.g. 33554432 for 32 MiB), or switch to RocksDB storage with `LEANKG_DB_ENGINE=rocksdb` which handles larger datasets more efficiently.
Frequently Asked Questions about LeanKG Knowledge Graph
What is LeanKG Knowledge Graph?
LeanKG Knowledge Graph is a Model Context Protocol (MCP) server that leankg: stop burning tokens. start coding lean. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install LeanKG Knowledge Graph?
Follow the installation instructions on the LeanKG Knowledge Graph GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with LeanKG Knowledge Graph?
LeanKG Knowledge Graph works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is LeanKG Knowledge Graph free to use?
Yes, LeanKG Knowledge Graph is open source and available under the Apache-2.0 license. You can use it freely in both personal and commercial projects.
LeanKG Knowledge Graph Alternatives — Similar Knowledge & Memory Servers
Looking for alternatives to LeanKG Knowledge Graph? Here are other popular knowledge & memory servers you can use with Claude, Cursor, and VS Code.
MemPalace
★ 52.6kA local AI memory system that stores all conversations verbatim and organizes them into navigable structures. It provides 19 MCP tools for AI assistants to search and retrieve past decisions, debugging sessions, and architecture debates automatically
Kratos
★ 25.7k🏛️ Memory System for AI Coding Tools - Never explain your codebase again. MCP server with perfect project isolation, 95.8% context accuracy, and the Four Pillars Framework.
Context Mode
★ 15.4kAn MCP server that preserves LLM context by intercepting large data outputs and returning only concise summaries or relevant sections. It enables efficient sandboxed code execution, file processing, and documentation indexing across multiple programm
Memu
★ 13.7kMemory for 24/7 proactive agents like OpenClaw.
MemOS
★ 9.3kMemOS (Memory Operating System) is a memory management operating system designed for AI applications. Its goal is: to enable your AI system to have long-term memory like a human, not only remembering what users have said but also actively invoking, u
Everos
★ 5.4kBuild, evaluate, and integrate long-term memory for self-evolving agents.
Browse More Knowledge & Memory MCP Servers
Explore all knowledge & memory servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up LeanKG Knowledge Graph in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use LeanKG Knowledge Graph?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.