# lain [Health: Active]

**Category:** 🧠 Knowledge & Memory  
**Repository:** https://github.com/spuentesp/lain  
**GitHub Stars:** 9  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/lain

## Description
High-performance knowledge graph MCP server for AI coding agents with semantic search.

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/spuentesp/lain), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
curl -fsSL https://raw.githubusercontent.com/spuentesp/lain/main/install.sh | bash
```

2. Install:

```sh
npm install -g @spuentesp/lain-mcp
```

3. Install:

```sh
npm install -g --prefix ~/.local/lain-npm @spuentesp/lain-mcp
```

4. Add to your MCP client:

```sh
lain setup --agent claude-code
```

5. Add to your MCP client:

```sh
lain setup --agent codex
```

6. Add to your MCP client:

```sh
lain setup --agent cursor
```

## Documentation

## What lain does

lain indexes source repositories into an on-disk graph that records symbols, definitions, callers, dependencies, call paths, and Git co-change patterns. An MCP-connected coding agent can use that graph to investigate a proposed edit before changing code. Typical questions include which callers may be affected, how an entry point reaches a helper, and which files commonly change alongside another file.

The index can cover one repository or a configured workspace containing multiple repositories. Cross-repository queries support organization-wide search and blast-radius analysis. Lain also tracks agent presence, intents, and advisory file claims so agents can identify overlapping work before editing the same area.

Built-in parsers cover Rust, Python, TypeScript, JavaScript, Go, Java, C, C++, C#, Ruby, Swift, Kotlin, Scala, PHP, and script blocks in Vue and Svelte components. Optional language servers can add precision.

## How it works

Lain walks upward from the agent's working directory to locate a Git repository, builds `.lain/graph.bin`, and serves the repository through MCP over stdio. The graph persists between runs and follows committed changes. After new work is committed, run `lain reindex` or start a fresh session to update it.

Static analysis cannot resolve every dynamic call through message buses, dependency injection, or reflection. For dispatch analysis, `explain_dispatch` combines static callers with convention matches, runtime traces, and Git co-change evidence. When the available evidence is insufficient, the result reports that condition rather than treating an empty result as proof that an edit is safe.

Semantic search is optional. Name-based and graph queries remain available without an embedding model.

## Setup and configuration

Install with the release installer or the npm package `@spuentesp/lain-mcp`. Source builds require Rust 1.89 or newer. When npm install scripts are disabled, the first invocation downloads and verifies the platform binary, so that initial run requires network access.

From the repository to index, run `lain setup --agent` with a supported client such as `claude-code`, `codex`, `cursor`, `vscode`, or `continue`. Use `generic` for another MCP host. Setup writes the selected client's configuration, uses the absolute path to the binary, and verifies the MCP handshake. Restart the agent afterward.

Language-server installation is optional. Specify languages with `--lsp python,go`, install all detected missing servers with `--lsp detected`, or disable them with `--lsp none`. For multiple repositories, add repositories and create a workspace, then run the server with a configuration file. HTTP mode listens on localhost by default; network exposure requires `LAIN_BIND_ADDR` and `LAIN_API_KEYS`.

## Tools and capabilities

- `get_blast_radius` and `assess_change` inspect likely effects of changing a symbol.
- `get_call_chain` traces the relationship between functions.
- `find_anchors` and `list_entry_points` help locate architectural entry points.
- `find_symbol` searches symbols, while `search_code` supports name or semantic search.
- `get_cross_repo_blast_radius` and `search_org` query across repositories.
- `explain_dispatch` combines static and additional evidence for indirect dispatch.
- Intents, presence, and advisory claims expose overlapping agent activity.

The same operations can be exercised from a terminal; for example, `lain oneshot get_blast_radius <symbol>` runs a blast-radius query without asking an agent.

## Limitations and notes

Results are based on indexed committed code and can lag behind recent commits until reindexing. Dynamic dispatch may remain unresolved even with supplemental evidence. The graph is local and persisted on disk, and the default HTTP server is restricted to localhost. Exposing it beyond localhost requires API keys as well as a bind-address setting.

_Full upstream README: https://allmcps.com/mcp/lain/readme_

