
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.
概覽
本機程式碼知識圖譜 MCP 伺服器,讓編碼助理在改程式碼前檢視呼叫端、相依性、符號與 Git 共同變更。
- 可以做什麼
- 檢視符號的影響範圍與變更風險,評估改動影響
- 追蹤函式間的呼叫鏈,找出進入點與錨點
- 依名稱或語意搜尋符號,語意搜尋為選用功能
- 跨儲存庫追蹤符號,進行跨儲存庫影響分析與組織層級搜尋
- 透過意圖、線上狀態與建議性檔案宣告協調多個代理
- 結合靜態呼叫端、慣例比對、執行時追蹤與 Git 共同變更來解釋分派
- 適用情境
- 適合代理在 Git 儲存庫中修改程式碼、需要知道某個函式被誰相依、程式碼如何抵達它,或哪些檔案通常一起變更的情境。也適用於需要跨儲存庫影響分析的多儲存庫環境。
- 執行需求
- 以本機 stdio 程序執行,可從 npm(macOS、Linux、x64 Windows)或發行版安裝腳本安裝;僅從原始碼建置時需要 Rust 1.89 以上。setup 會寫入宿主端的 MCP 設定,之後需重新啟動代理。首次執行會下載並驗證平台二進位檔,需要網路存取,之後可離線使用。語意搜尋所需的嵌入模型為選用。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Lain,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
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.
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:
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:
Or from npm (macOS, Linux, and x64 Windows):
Two npm notes:
npm install -gfails withEEXISTwhen an unrelatedlainfile already sits in npm's global bin directory — for example an older manual copy in~/.local/binwhen 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/binto yourPATH).- If npm install scripts were disabled (
--ignore-scripts, a locked-down CI), the platform binary is not fetched during install. The firstlainrun 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:
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:
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:
First query
Ask the connected agent:
Or call the same tool from a terminal:
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
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:
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
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
Project status
[CI] [SafeSkill] [OpenSSF Scorecard] [OpenSSF Best Practices] [SBOM] [Build Provenance]
License
MIT — Copyright (c) 2026 spuentesp
來源:README.md,提交 7fe8cf2
工具
0版本歷史
2- v0.10.0最新Oct 14, 2026
- v0.1.0Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分