Labsco
MCP SERVER

Lean KG

by FreePeak

A code knowledge graph an agent queries instead of reading files - across several repos, with documentation joined to the code it describes.

Code Intelligence & Repository Indexing
Summary
The doc-to-code join is what separates this from a symbol index.

Plenty of tools tell an agent where a function is defined. Answering which files implement a given requirement, and which documentation covers a file, needs documents in the same graph as the code - which is the bet here. The read-only split is the other detail worth planning for: serve queries from one binary and let a separate worker do the writing.

What it is

An indexer that builds a graph of a codebase in Postgres and serves it over MCP. Beyond symbols and dependencies it holds documentation, requirements and workflow concepts, so a question can cross from a written requirement to the code that implements it.

What you get
  • Find a file, locate a function definition, and search code elements by name or type
  • Call graphs, direct dependencies and dependents, and an impact radius bounded by hop count
  • A focused review context - a subgraph plus a structured prompt - for a change you are about to make
  • Concept and semantic search over the graph, with a compressed context read when the full context is too large
  • Documentation indexed alongside the code, so a requirement ID joins to the files that implement it and back again
  • Environment-aware filtering, conflict detection across environments, dead-code and diff-impact analysis
  • An agent diary written and read back across sessions, and graph snapshots you can export
Requirements

Postgres with pgvector is the only storage engine and has to be up first; the bundled compose file puts it on port 5433 and LEANKG_PG_URL overrides the connection string. Then init, migrate and index the project. Docker serves MCP on port 9699; installing from source is cargo install leankg. In production the project splits into two binaries - a read-only MCP server that rejects mutating tools, and a worker that owns indexing, watching and embedding.

Setup effort

One command plus a key — cargo install leankg, then supply credentials