Graphlens Mcp

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

Semantic code graph MCP server for coding agents

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

概览

AI 生成的概览

一个本地 MCP 服务器,为项目构建语义代码图,让编码助手按符号搜索并追踪调用者、被调用者和引用,而不必逐文件 grep。

可以做什么
按名称、内容或语义搜索代码,可用路径模式限定范围,返回带签名和位置的图节点。一次调用查看某个符号的邻域:调用者、被调用者、实现者与子类、非调用引用,用于影响分析。读取指定符号或文件的符号大纲,含源码、签名和位置。通过文件系统监视器和启动时的一次性核对保持图最新,并标记降级或正在索引的结果。
适用场景
当编码助手在多文件代码库上工作,需要可靠回答谁调用了某函数、它依赖什么、修改签名会破坏什么时,值得添加。最适合 Python、TypeScript、Go、Rust 或 PHP 项目,尤其是希望避免逐文件缓慢阅读的场景。
运行要求
本地 Python 3.13 或更高版本运行时;以 PyPI 包安装,用 uvx 或工具安装器运行。Python 分析开箱即用;TypeScript、Go、Rust 和 PHP 需要各自的工具链(Node、Go、rust-analyzer)才能获得完整跨文件语义,否则标记为降级。图数据保存在项目下的本地 SQLite 文件中。
安装前请注意
init 命令会向编码助手的配置文件写入 MCP 服务器条目并安装导航技能,请检查这些改动。它会把项目源码索引到本地数据库,应将该目录排除在版本控制之外。首次运行若无网络,语义搜索会回退为名称和内容匹配。项目自称处于早期阶段,增量重新链接存在已知限制。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

graphlens-mcp

[CI] [Docs] [Python] [License: MIT]

A free, MIT-licensed MCP server that gives coding agents (Claude Code, Cursor, and compatible clients) a semantic code graph of your project — symbols, cross-file calls, references, imports and cross-language boundaries.

Instead of reading files top-to-bottom or grepping for names, the agent navigates the structure: who calls this function, what does it depend on, what breaks if I change its signature. It is a thin runtime layer over the graphlens analysis engine: graphlens provides the mechanisms (parsing, stable node identity, resolvers); graphlens-mcp owns the storage, freshness and the agent-facing surface.

📖 Documentation: https://neko1313.github.io/graphlens-mcp/

Status: early. The core navigation works; see Known limitations.

Why

Coding agents discover structure the slow way — grep, glob, read one file at a time — rebuilding call paths by hand before the real work even starts. The motivation is the same as every other code-context tool: stop the agent from grepping. The approach is what sets graphlens apart.

Most tools answer this by building their own model of your code — an ad-hoc graph stitched from heuristics, where every tool maps the codebase a little differently and nothing is authoritative. graphlens takes the opposite bet: it builds on the language's own real analysis engines — rust-analyzer, gopls, the TypeScript compiler, the bundled ty type engine — the LSP-grade tooling the industry already trusts. That yields a stable, real picture of the project (who actually calls what, across files and languages), not a bespoke approximation. And a stable foundation is something you can build on: attach context to the parts of a change that matter, auto-extract semantic clusters, answer impact questions reliably.

That foundation is the graphlens engine — parsing, stable node identity, and the resolvers. graphlens-mcp is a smart, agent-facing layer over it, and — honestly — a worked example of how to use the engine: it persists the graph (so the whole thing isn't held in memory), adds a semantic + clustering layer on top, keeps it fresh as you edit, and exposes it to agents as navigation tools plus a bundled skill. From that example it is growing into a self-sufficient system — one that, measured against the market's giants, aims for stable, reproducible results: better in some places, worse in others, but honest about which (see How it compares).

How it compares

graphlens-mcp ships with a reproducible A/B benchmark (benchmarks/) that drives the same agent against three interchangeable code-context MCP servers — graphlens, semble (semantic search), and codegraph (graph index) — plus a no-tools control that measures how much each server adds over the model's own memory. It runs across real Go / Rust / Python / TypeScript codebases and grades answers deterministically against oracle gold (no LLM judge), stratified into SIMPLE lookups vs HARD impact / cross-file questions, and reports accuracy alongside token / tool-call / dollar cost — because a cheaper arm at equal accuracy wins.

📊 Results (10 repos · 3 models, strong → genuinely weak · ~2,400 graded runs — full breakdown, significance tests and reproduction steps at docs: Benchmarks):

SIMPLE accuracyHARD accuracyHARD tokens (median)HARD completion
graphlens0.980 – 1.0000.899 – 0.92122.4k – 34.1k≥ 0.959 on every model
codegraph0.912 – 0.9900.655 – 0.93923.2k – 70.0kdrops to 0.765 on the weakest model
semble0.647 – 0.9610.555 – 0.85021.6k – 74.9kdrops to 0.688 on the weakest model
none (control)0.366 – 0.6810.453 – 0.6850.1k – 0.9k—

Accuracy alone hides the number that matters to a bill: tokens paid per task. graphlens's HARD-tier token spend stays flat (22k–34k) whether the driving model is strong or weak; codegraph's and semble's balloon past 70k on the weakest model — more than double graphlens's ceiling — for a worse answer, not a better one. graphlens is the only arm that stays clearly ahead of the no-tools control and keeps completion above 0.95 at every model tier: on the weakest model tested (gpt-oss-20b) it holds 0.900 HARD accuracy at roughly half the token cost of codegraph. Pairwise Wilcoxon signed-rank tests (matched by task) confirm the gap is statistically significant on the weaker models, not an artifact of a few outlier tasks — see the notebook for per-model p-values and effect sizes.

Install

Requires Python ≥ 3.13 (a constraint inherited from graphlens).

bash
uv tool install graphlens-mcp      # or: pipx install graphlens-mcp

Python language analysis works out of the box (the ty type engine ships as a dependency). Other languages parse immediately and unlock full cross-file semantics once their toolchain is present (Node for TypeScript, the Go toolchain, etc.); without it that language is reported as degraded rather than blocking init.

Quickstart (two commands)

bash
uv tool install graphlens-mcp        # 1. installcd your-project && graphlens-mcp init  # 2. index + configure your agent

init detects the project's languages, indexes the code into a local graph, writes the MCP server entry into your agent's config and installs the navigation skill. You do not run serve yourself — your agent launches it from the config. Restart the agent and ask it something like "what breaks if I change the signature of create_order?".

Commands

CommandWhat it does
graphlens-mcp initDetect languages → toolchain doctor → full index → configure agents → install skill
graphlens-mcp serveStart the MCP server over stdio. Launched by the agent, not by you
graphlens-mcp statusShow detected languages, toolchain status, and graph size/freshness
graphlens-mcp reindexForce a full rebuild (e.g. after installing a new toolchain)
graphlens-mcp removeDeregister from agents and (with --purge-db) delete the local graph

Useful init flags: --root <dir>, --agent claude_code --agent cursor (repeatable), --no-agent, --no-skills, --db <path>.

The graph lives at <project>/.graphlens/graph.db (SQLite). It is a regenerable cache — safe to delete; reindex rebuilds it. Add .graphlens/ to your VCS ignore (the bundled init flow assumes it is not committed).

Supported languages

LanguageEngineOut-of-box
Pythonty (bundled)Full semantics immediately
TypeScriptNode bridgedegraded without Node; full semantics with Node installed
GoGo toolchaindegraded without toolchain
RustSCIP / rust-analyzerdegraded without toolchain
PHPPHP parserdegraded without toolchain

graphlens-mcp status reports the actual resolver status per language. When a toolchain is missing, that language is reported as degraded (parsed structure, calls/types not fully resolved) with an install hint — it never blocks init.

Agent tools

Three tools — everything a symbol or file needs comes back as a navigable graph node, not a dead grep line. Each response carries a graph-quality status (ok | degraded) so the agent never mistakes a partial answer for a complete one, plus an indexing flag (true when a background reindex is running, so edges may be temporarily incomplete).

ToolPurpose
searchFind code by NAME, CONTENT, or MEANING — the one way in. Returns graph nodes with their signature (often enough to answer without a follow-up call). Content is matched literally, not as a regex. Scope with path_glob (e.g. "tests/*", "*.ts", "!tests/*" to exclude a subtree); set exhaustive=true to list every matching file (no cap, no signatures) instead of the ranked top-N
relationsA symbol's neighbourhood in one call: callers, callees, implementors/subclasses, and non-call references — each with its signature. The impact-analysis tool ("what breaks if I change X?", "what implements X?")
infoRead a specific target: a symbol (node id or name) → source + signature + location; a file path → its symbol outline

search and relations accept either a symbol name or a node id directly — you don't need to look up a node id first. Both cap their response size (a large hit set is ranked by relevance via a small bundled embedding model, not just truncated) and surface true counts (callers_total, references_total, …) when a list is capped, so the agent sees "15 shown of 22" instead of guessing. If the embedding model can't be fetched (e.g. a first run with no network), search transparently falls back to name/content matching.

Freshness model

A single mechanism keeps the graph current: a filesystem watcher (serve starts it by default; disable with --no-watch). When a file changes on disk the server re-indexes the connected set — the changed file plus the files that import it and the files it imports — with one full analyze, so cross-file edges are rebuilt correctly rather than left partial. Deleting a file prunes its symbols and refreshes its importers. There is no polling and no structure-only "skeleton" phase: every (re)index produces the full graph the resolver can give. As a backstop, a tool that touches a file the watcher hasn't processed yet triggers the same connected re-index on access.

Files created, deleted or edited while the server was down are invisible to an event-based watcher, so serve runs a one-shot reconcile at startup: it scans the project, indexes new files, prunes vanished ones, and refreshes any that changed — then hands off to the watcher.

Known limitations

  • Connected-set re-link, deep ripples: the watcher re-links the connected set of a change (the changed file plus its direct importers and imports), not the entire project. A rename that ripples through many indirection layers may need a full reindex for an exact graph. Creating a file that an unchanged file already imports is handled — a second importer pass re-links that importer once the new file is indexed.
  • Cross-language edges on incremental edits: synthesized COMMUNICATES_WITH edges are re-synthesized for every boundary a re-indexed file touches, so a new or moved exposer/consumer is linked without a full reindex. A change that leaves a boundary entirely (a file that stops exposing an endpoint others still consume) may still need a full reindex for an exact cross-language view; the boundary-based query resolves connections regardless.

Uninstall

graphlens-mcp remove deregisters the server from your agents; add --purge-db to also delete the local .graphlens/ cache.

Development

bash
uv sync --all-groups   # install lint + test toolingtask check             # ruff + format-check + ty + bandit + pytest (the CI gate)task docs:serve        # preview the docs site locally (needs Node + pnpm)

See the Architecture and Semantic search pages on the documentation site for the design and invariants.

License

MIT — see LICENSE.

来源:README.md,提交 f012d27

工具

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

版本历史

1
  1. v0.4.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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