LeanKG MCP

A code knowledge graph for your agent: callers, dependents and blast radius over MCP instead of reading files

  • 222 ★ on the repository
  • Last commit
  • Apache-2.0
MCP server

Extended access

Why this level

  • The MCP `read` call returns project file contents, and memory is written to the `.leankg/` folder inside the repository
  • Without a token every HTTP, REST and RPC caller becomes an administrator, which is why a non-loopback bind is refused
  • With embeddings from an external provider such as openai, code text goes to that service
All reasons and checks

freepeak/leankg

Install

Manual install

go install github.com/FreePeak/LeanKG/cmd/leankg@latest

Needs Go 1.25 or newer. Embeddings come as a second binary, `leankg-embed`.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • The MCP `read` call returns project file contents, and memory is written to the `.leankg/` folder inside the repository
  • Without a token every HTTP, REST and RPC caller becomes an administrator, which is why a non-loopback bind is refused
  • With embeddings from an external provider such as openai, code text goes to that service

This is third-party code. Review the repository files before installing.

What it does

LeanKG builds a knowledge graph of your project code and serves it to an agent over MCP. Instead of a grep-and-open-files chain the agent gets a targeted subgraph: who calls a function, what depends on a file, which tests and docs sit nearby, how wide an edit will reach. It is a single Go binary without CGO, the default storage is SQLite in `.leankg/leankg.db`, and Postgres is an opt-in. Two steps start it: `leankg index .` indexes the project and `leankg install --target claude-code` writes the MCP entry (`cursor`, `codex`, `gemini`, `opencode` and `omp` work as well). The server has three tools, `import`, `query` and `status`, and about thirty actions: a search ladder from exact name to fuzzy to semantic, `impact` for blast radius, `callers`, `path`, `explain`, code pattern search and PRD requirement tracing. On top of the code there is a team layer: environments, services, incidents and markdown memory between sessions. The README claims token use down by up to 65% and tool calls by up to 85%; these are the author measurements.

Who it is for. Developers on large multi-module repositories where the agent burns context on finding callers and judging the impact of an edit.

Good fit when

  • Before editing a function or file you must see who depends on it and what will break: `leankg impact src/main.go`
  • The agent rereads the same files over and over, and the context runs out before the task does
  • One server has to serve graphs of several repositories through `LEANKG_PROJECT_DIRS`
  • You want a markdown project memory between sessions: the server starts with the `--memory` flag
  • You want to link PRD requirements to code and see that each one is implemented

Not a fit when

  • A root with tens of thousands of nested files: the unit of scope is a repository, child projects are registered one at a time
  • Windows: the README requires macOS or Linux
  • You need an exact cross-package call graph with type resolution: LeanKG does not do that resolution

Example request

Using LeanKG, show what breaks if I change the parseConfig signature and which tests cover it

MCP

Transport
stdio, http
Authentication
not required

Environment variables

LEANKG_EMBED_PROVIDER
Embedding provider for semantic search: local, openai or deterministic.
LEANKG_PROJECT_DIRS
List of project directories for multi-project mode.

Limitations

Call edges are built within a package without import or type resolution, so calls across packages are resolved approximately. Files of 1 MiB and larger are skipped as vendored or minified, and call targets shorter than four characters are dropped as noise. In a git repository the index is built from HEAD objects: uncommitted, untracked and ignored files do not reach the graph. Semantic search needs an embedding provider in `LEANKG_EMBED_PROVIDER`; without it exact and fuzzy search work.

How to disable. Remove the `leankg` entry from the MCP client configuration and delete the `leankg` and `leankg-embed` binaries from `$(go env GOPATH)/bin`. The local index lives in the `.leankg/` folder of the project.

FAQ

How do I connect LeanKG to Claude Code?

Index the project with `leankg index .`, then run `leankg install --target claude-code` and restart the client. The entry launches `serve --stdio --memory`, so the agent gets the code graph and markdown memory without a second server.

Why do answers come from another project?

The server picks the project from the working directory of its process. Start it with `--project DIR`; `query` and `impact` also read the `LEANKG_PROJECT` variable. A multi-project server refuses to answer until the request names the project.

How do I tell that the index is built?

`leankg doctor` prints the store path, the element and file counts and the write watermark. Exit code 0 means pass and 2 means fail. `leankg status` adds freshness and embed state.

Can I expose the server to the local network?

A non-loopback bind is refused until a token is configured (`leankg auth token create` or the `LEANKG_TOKEN_ADMIN`, `LEANKG_TOKEN_CONTRIBUTOR` and `LEANKG_TOKEN_VIEWER` variables). Without a token every caller becomes an administrator.

How do I get LeanKG without a Go toolchain?

Take a prebuilt `leankg-<os>-<arch>.tgz` archive from the releases: it holds both binaries and a checksum file for linux and darwin on amd64 and arm64. An installed copy updates with `leankg update`.

Discussion

No questions or reviews yet.

Local static analysis for Go with an MCP server: call graphs, change impact, symbol search and review before and after edits

MCP serverMinimal access231Repository stars

DevLens analyzes a repo once and serves agents ranked files, call flow and change impact over MCP, no file-by-file reading

MCP serverExtended access70Repository stars
Official

A local code graph with version history: an MCP server that tells the agent who calls a function and what an edit breaks

MCP serverExtended access516Repository stars

Local code graph for agents: an MCP server returns entry points, symbol links and change impact in one call

MCP serverExtended access77.5KRepository stars

An MCP server that builds a code knowledge graph: semantic search, call graph, HTTP route tracing and change impact analysis.

MCP serverExtended access95Repository stars

Comparison with similar tools

Cards that share the main search query, and how they differ.

ToolOfficialAuthenticationRepository starsMain difference
LeanKG (this card)nonot required222
codebase-memory-mcpnonot required48,598It also builds a code graph for agents; LeanKG starts from one Go binary on SQLite and adds a team layer with environments, incidents and requirement tracing.
GitNexusnonot required48,470GitNexus solves a nearby task by giving an agent a repository dependency graph; LeanKG has three MCP tools with a search ladder and markdown memory between sessions.
code-graph-ragnonot required5,352Code-Graph-RAG builds a code graph for natural-language questions; LeanKG keeps the index in SQLite and computes edit blast radius with `impact`.

README in short

The README opens with a with-and-without comparison, then gives a quick start, install routes (go install, prebuilt archives, a source build, a container), a table of questions and how to ask them, the feature list, CLI commands and known limits.

README badge

Report a problem