Lain

io.github.spuentesp由 GitHub 账号 spuentesp 发布v0.10.0更新于 Oct 24, 2026

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

已验证STDIO仅桌面知识与记忆开发者工具

概览

AI 生成的概览

本地代码知识图谱 MCP 服务器,让编码助手在改代码前查看调用方、依赖、符号与 Git 共同变更。

可以做什么
  • 查看符号的爆炸半径与变更风险,评估改动影响
  • 追踪函数间调用链,查找入口点与锚点
  • 按名称或语义搜索符号,语义搜索为可选项
  • 跨仓库追踪符号,做跨仓库影响分析与组织级搜索
  • 通过意图、在线状态与建议性文件声明协调多个代理
  • 结合静态调用方、约定匹配、运行时追踪与 Git 共同变更解释分发
适用场景
适合代理在 Git 仓库中修改代码、需要知道某个函数被谁依赖、代码如何到达它,或哪些文件通常一起变更的场景。也适用于需要跨仓库影响分析的多仓库环境。
运行要求
以本地 stdio 进程运行,可从 npm(macOS、Linux、x64 Windows)或发布安装脚本安装;仅从源码构建时需要 Rust 1.89 以上。setup 会写入宿主机的 MCP 配置,之后需重启代理。首次运行会下载并校验平台二进制,需要网络访问,之后可离线使用。语义搜索所需的嵌入模型为可选。
安装前请注意
发布安装脚本会把远程脚本直接交给 shell 执行,运行前应先审阅。索引跟随提交而非未提交的修改,重新索引前答案可能过时。静态分析无法证明所有动态调用,空结果会标为证据不足,并不代表改动安全。若要把 HTTP 服务器暴露到 localhost 之外,需设置 LAIN_BIND_ADDR 与 LAIN_API_KEYS。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Lain,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Lain

A code graph for coding agents. Lain maps callers, dependencies, symbols, and Git co-changes, then exposes them through the Model Context Protocol (MCP). Before an agent edits a function, it can inspect what depends on it and how the rest of the code reaches it.

[Lain Command Center demo]

The demo traces a symbol across the bytes and tokio repositories. Agents query the same graph through MCP; the browser shows what Lain indexed and where an answer came from.

Ask your agent:

text
If I change validate_token, what breaks?Show me the call chain from entry to helper_a.Which files usually change with auth.rs?Is another agent already editing this code?

Lain answers with symbol names and source paths from a local index. The index stays on disk between runs and can cover more than one repository. It follows commits, not uncommitted edits: after committing, a re-index pass (lain reindex or a fresh session) brings it current — and answers that may miss recent work say so instead of going quiet. Semantic search is optional; graph queries work without an embedding model.

Install

Using the release installer:

bash
curl -fsSL https://raw.githubusercontent.com/spuentesp/lain/main/install.sh | bashsource ~/.zshrc   # or ~/.bashrclain --version

Or from npm (macOS, Linux, and x64 Windows):

bash
npm install -g @spuentesp/lain-mcplain --version

Two npm notes:

  • npm install -g fails with EEXIST when an unrelated lain file already sits in npm's global bin directory — for example an older manual copy in ~/.local/bin when your npm prefix is ~/.local. The npm error itself cannot tell the file is unrelated; move or remove it, or install under a different prefix: npm install -g --prefix ~/.local/lain-npm @spuentesp/lain-mcp (then add ~/.local/lain-npm/bin to your PATH).
  • If npm install scripts were disabled (--ignore-scripts, a locked-down CI), the platform binary is not fetched during install. The first lain run downloads and verifies it, so that first run needs network access; once cached, lain works offline.

Rust 1.89 or newer is only needed when building from source. The quickstart covers non-interactive installation and the optional local embedding model.

Connect an agent

Run one setup command from the repository you want Lain to index:

bash
lain setup --agent claude-codelain setup --agent codexlain setup --agent cursorlain setup --agent vscodelain setup --agent continue

Use lain setup --agent generic for another MCP host. Each adapter writes the client's own configuration — claude mcp add for Claude Code, ~/.codex/config.toml for Codex, ~/.cursor/mcp.json for Cursor, .vscode/mcp.json (or the user-scoped mcp.json) for VS Code, a block file under the repository's .continue/mcpServers/ for Continue. generic writes this project-level .mcp.json:

json
{  "mcpServers": {    "lain": {      "command": "/home/you/.local/lain/lain",      "args": ["mcp"]    }  }}

command is always the absolute path of the lain binary that ran setup — not the bare name — so the agent runs the same binary no matter which PATH it inherits. That path depends on the install: the release installer puts the binary at ~/.local/lain/lain, while the npm package registers the verified cache binary it launches (~/.cache/lain/<version>/<target>/lain on Linux, ~/Library/Caches/lain/… on macOS, %LOCALAPPDATA%\lain\Cache\… on Windows). Setup finishes by starting exactly that command once and verifying the MCP handshake.

On a terminal, lain setup without --agent asks which client to configure (Enter picks Claude Code), and without --lsp asks which optional language servers to install (Enter installs none). Non-interactive runs default to generic and no language servers, so scripts should pass --agent and --lsp explicitly.

Restart the agent after setup. Lain walks up from the agent's working directory to find .git, builds .lain/graph.bin, and serves the repository over stdio. No repos.yaml is needed for one repository.

Languages

Parsers for Rust, Python, TypeScript, JavaScript, Go, Java, C, C++, C#, Ruby, Swift, Kotlin, Scala and PHP are built into the binary, as are the <script> blocks of Vue and Svelte components. Every one gets definitions and a call graph with nothing else installed.

Language servers are optional and only add precision. lain setup lists the languages it found and asks which servers to install; pressing Enter installs none. Non-interactive runs install none unless you name them:

bash
lain setup --lsp python,go      # just theselain setup --lsp detected       # every missing one for this repositorylain setup --lsp none

First query

Ask the connected agent:

text
Use Lain to show the blast radius of validate_token.

Or call the same tool from a terminal:

bash
lain oneshot get_blast_radius validate_token

Use a symbol from your repository in place of validate_token. If the graph isn't ready or an answer looks stale, run lain doctor.

Multiple repositories

bash
lain repos add bytes https://github.com/tokio-rs/bytes.gitlain repos add tokio https://github.com/tokio-rs/tokio.gitlain workspaces create tokio-stack --members bytes,tokiolain server --config ./repos.yaml --transport http --port 9999

Open http://localhost:9999 for the Command Center. The server listens on localhost only; set LAIN_BIND_ADDR=0.0.0.0 (with LAIN_API_KEYS=key1,…) to expose it on the network. Federation adds organization-wide search and cross-repository blast-radius queries. The federation guide covers configuration, source types, and failure states. After a federation schema upgrade, run lain reindex to rebuild the on-disk graph from the sources.

Check the graph

From a source checkout:

bash
scripts/demo.sh --quick

The script creates a small repository with a known call graph, starts a real Lain server, and compares the answers with that graph. It exits non-zero when a check fails. A full run also records timings against this repository.

What Lain provides

NeedTool or feature
See callers before changing a symbolget_blast_radius, assess_change
Trace how two functions connectget_call_chain
Find architectural entry pointsfind_anchors, list_entry_points
Search by name or meaningfind_symbol, search_code
Follow a symbol across repositoriesget_cross_repo_blast_radius, search_org
Keep agents from editing the same code blindlyintents, presence, and advisory file claims

Static analysis can't prove every dynamic call through a message bus, dependency injection container, or reflective router. explain_dispatch combines static callers with convention matches, runtime traces, and Git co-change evidence; an empty result becomes insufficient_evidence, not a claim that the edit is safe.

Documentation

Start hereCovers
QuickstartInstallation, first query, and first aid
User manualCLI reference, tuning, operation, and troubleshooting
Tool guideMCP tools, arguments, outputs, and limits
Skill bundleAgent-loadable skills and role recipes
FederationMulti-repository configuration and queries
MultiplayerAgent presence, intents, claims, and hooks
ArchitectureGraph construction and design choices
Documentation indexEvery maintained document

Project status

[CI] [SafeSkill] [OpenSSF Scorecard] [OpenSSF Best Practices] [SBOM] [Build Provenance]

License

MIT — Copyright (c) 2026 spuentesp

来源:README.md,提交 7fe8cf2

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.10.0最新Oct 14, 2026
  2. v0.1.0Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分