Lean KG
About
A local, Rust-based Knowledge Graph MCP server. Cuts AI coding token usage by up to 98% by intelligently querying your codebase instead of sending full files.
Details
- Author
- freepeak
- Downloads
- 153
- Categories
- Developer Tools, Knowledge Base, Database, Other
Jump to
- Reduces token usage by up to 98% (from ~10,000+ to ~40 tokens per query).
- 100% local execution — runs securely on your machine with Rust and CozoDB.
- Deep code understanding via Graph RAG, including call graphs and circular dependencies.
- Universal MCP support for any MCP-compatible AI host.
- Provides tools like analyze_dependencies and extract_signatures.
Visit the LeanKG GitHub repository for full installation instructions, benchmarks, and supported languages. After installation, the MCP server exposes tools that your AI assistant can invoke — no additional configuration steps beyond connecting it to an MCP-compatible host (e.g., Claude Desktop, Cursor, Windsurf, OpenCode).
Enterprise-ready code knowledge graph for AI coding agents
Multi-repo · env governance · incidents & services · req↔code · −65% tokens / −85% tool calls
Postgres + pgvector is required (only storage engine). From a LeanKG checkout:
docker compose up -d postgres # host :5433
Default URL:postgresql://postgres:postgres@localhost:5433/leankg(override withLEANKG_PG_URL).
One-liners below donotstart Postgres — they fail if:5433is down.
# Docker — index + embed + MCP HTTP (Postgres must already be up) curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/docker-up.sh | bash # Agent — binary + MCP wiring (cursor | claude | opencode | gemini | kilo | antigravity | docker | update) curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- cursor
Skip cold embed:LEANKG_SKIP_EMBED=1 curl -fsSL …/docker-up.sh | bash
docker compose up -d # Postgres :5433 + MCP :9699 # or MCP only (bring your own PG via LEANKG_PG_URL): docker run -d --name leankg -p 9699:9699 \ -e LEANKG_PG_URL=postgresql://postgres:postgres@host.docker.internal:5433/leankg \ -v "$(pwd):/workspace" freepeak/leankg:latest curl http://localhost:9699/health
cargo install leankg # or: git clone https://github.com/FreePeak/LeanKG.git && cd LeanKG && cargo build --release
# 1. Postgres (once) docker compose up -d postgres # 2. Index your project leankg setup # wire MCP into your agents cd your-project leankg init && leankg index ./src && leankg status leankg impact src/main.rs --depth 3 leankg mcp-stdio --watch # local agents leankg mcp-http --port 9699 # HTTP / Docker
Docker MCP: passcontainerpaths asproject=(e.g./workspace), never the host Mac path.
Server-side setup pipeline (clone -> index -> embed)
leankg setupwith no flags keeps the legacy client-side behavior (register MCP + hooks). Pass pipeline flags to instead clone a list of repos and index each one server-side:
# Status: print the resolved repo list without running anything LEANKG_REPOS="github.com/org/repo-a,github.com/org/repo-b" leankg setup --status # Clone + index + embed each repo under LEANKG_CLONE_ROOT (default: cwd) LEANKG_REPOS="github.com/org/repo-a,github.com/org/repo-b" \ LEANKG_GIT_REF=main \ LEANKG_CLONE_ROOT=/srv/repos \ leankg setup --clone --index --embed
- LEANKG_REPOS— comma-separatedhost/namespacepaths to clone.
- LEANKG_PROJECT_DIRS— comma-separated dirs already mounted on disk (skips clone; falls back to indexing what exists when no git token is set).
Env knobs:LEANKG_GIT_HOST(defaultgithub.com),LEANKG_GIT_REF(defaultmain),LEANKG_CLONE_ROOT/CLONE_ROOT,LEANKG_ENV(defaultlocal), git token viaGITLAB_TOKEN/GIT_TOKEN/GITHUB_TOKEN. Each cloned repo gets a minimal.leankg/leankg.yaml, thenleankg indexandleankg embed --waitrun inside it. Asetup.donemarker prevents re-runs.
SetLEANKG_SETUP=1onleankg mcp-httpto run the same pipeline once after the server binds (spawned as a background task; the server stays healthy).
UI talks REST (:8080), not MCP (:9699). Start the API, then the Vite app inui-v2/:
# Terminal A — REST API (+ embedded UI if assets are in src/embed/) leankg serve --port 8080 # open http://127.0.0.1:8080/ # Terminal B — hot-reload explorer (recommended for local UI work) cd ui-v2 npm install npm run dev # open http://127.0.0.1:5173/?path=src
Vite proxies/api→127.0.0.1:8080. Status should showconnected.
Details:ui-v2/README.md·docs/web-ui.md
Peers in this space are mostly personal / single-repo. LeanKG is thecompany platform: shared index, ops graph, and measured agent economics.
Deep dives:ROI vs Graphify·Competitive one-pager·Research matrix
Agents normally rebuild structure with grep → open files → huge context. LeanKG returns atargeted subgraph(callers, dependents, blast radius, tests, docs) plus theteam layer(env, services, incidents, requirements) over MCP.
- MCP-native— search, impact, call graphs, ontology, architecture, team knowledge
- Postgres + pgvector— only storage engine; HNSW semantic search (--features embeddings/ Docker)
- Procedural ontology— hot-reloadontology/workflows.yaml→kg_trace_workflow
- Impact & deps—imports,calls,tested_by,http_calls,service_calls
- Web UI v2— Force / Tree / Circles explorer (leankg serve+cd ui-v2 && npm run dev)
- Languages— Rust, Go, C/C++, Java, Kotlin, TS/JS, Python, Ruby, PHP, Dart, Swift, ObjC, Terraform, CI YAML (*depth varies)
Discover first — donotopen withquery_graph:
get_overview_context→mcp_status→concept_search→semantic_search→search_code/find_function→ impact / deps /get_context
Catalog:docs/mcp-tools.md· Setup:docs/agentic-instructions.md
leankg init | index ./src | status | update leankg impact <file> --depth 3 leankg path <from> <to> | explain <symbol> | graph-query "<q>" leankg embed --init && leankg embed # --features embeddings leankg mcp-stdio --watch | mcp-http --port 9699 | serve --port 8080 leankg ontology sync | ontology trace <workflow>
UI hot-reload:cd ui-v2 && npm install && npm run dev→http://127.0.0.1:5173
Requirements:macOS or Linux · Docker recommended for teams · Rust 1.75+ only when building from source.
- Fork + feature branch (prefer a worktree)
- Update docs when behavior changes
- cargo build --release && cargo test
- Open a PR with summary + test plan
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
An MCP server that indexes local code into a graph database to provide context to AI assistants.
Local-first knowledge graph for developers. Watches project files, extracts entities and relationships via LLMs, and lets you query across projects with natural language and source citations.
Knowledge graph for token-efficient code reviews with Tree-sitter parsing, dual-mode embedding (ONNX + LiteLLM), and blast-radius analysis via MCP tools.
A server for CodeFuse-CGM, a graph-integrated large language model designed for repository-level software engineering tasks.
Code Rag with Graph - local only installation
A blazingly fast codebase graphRAG implementation in 100% Rust
Graph-powered code intelligence MCP server with semantic search, knowledge graph, and dependency analysis for Claude Code, Cursor, and Copilot.
Graph-based long-term memory skill for AI (LLM) coding agents — faster context, fewer tokens, safer refactors
Developer context continuity system that builds a temporal knowledge graph of your codebase — modules, symbols, decisions, and open problems — and serves it to AI coding agents via 12 MCP tools, so every agent session starts knowing your architecture without manual context pasting.
Memtrace gives AI coding agents structural memory — your codebase as a live knowledge graph so agents stop re-deriving code structure from scratch and start reasoning from fact.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





