Lens Mcp

io.github.segentic-lab由 GitHub 账号 segentic-lab 发布v0.1.2更新于 Oct 24, 2026

Deterministic navigation maps over code + markdown + Prisma for AI agents: 13 MCP tools

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

概览

AI 生成的概览

一个本地 MCP 服务器,为助手提供项目内 TypeScript、JavaScript、Python、Prisma 和 Markdown 文件的确定性导航地图。

可以做什么
一次调用即可获取整个项目的代码结构与文档大纲,并查看版本、输出上限、沙箱根目录以及服务器自身的安装与更新状态。查看单个代码文件的导入、导出、类与函数,列出所有函数及其签名和作用域,读取某个函数的原文。按名称在目录中查找符号定义,并列出使用该符号的调用点、导入和类型引用。列出注释与 TODO/FIXME 类标记,并对 Markdown 文档做大纲、按标题读取、链接提取和全文搜索。通过 overview、find 和 map 工具覆盖 Prisma schema 的模型、枚举、字段与关系。
适用场景
适合助手在陌生或大型代码库中工作时使用,避免为找一个函数或正确的文档章节而消耗上下文去列目录、grep 和通读整个文件。最适合在阅读真实源码前快速定位代码与文档。
运行要求
作为本地 stdio 进程在用户机器上运行(仅桌面端)。需要 Node.js 18 或更高版本;tree-sitter 以 WebAssembly 运行,无需系统软件包或原生编译。安装方式是克隆仓库并运行其安装脚本,脚本会执行 npm ci、构建、自测并生成客户端配置。只能读取其工作目录下的文件。
安装前请注意
属于只读导航:输出是地图和签名而非完整正文,助手在判断或修改前应阅读真实源码。文件访问限于工作目录,越界的符号链接会被拒绝。lens_system 工具可运行自更新脚本,拉取并重新安装服务器,会改动本地文件。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

lens-mcp

Deterministic navigation maps over code AND markdown — for AI agents. One MCP server, two lenses: tree-sitter for source (TypeScript / JavaScript / Python) and a markdown lens for docs. It answers "where is X and what's the shape of this project?" in one cheap call — so an agent spends context on thinking, not on browsing files.

Speaks the Model Context Protocol; works with any MCP client — Claude Code, Cursor, Codex, or your own agent.

Why

An agent orienting in an unfamiliar repo otherwise burns tokens ls-ing, grep-ing, and Reading whole files to find the one function or the right doc. lens returns the map instead of the territory:

  • function_body reads one function — often ~99% less context than Reading the file it lives in.
  • heading reads one doc section — the referenced heading and its subsections, nothing else.
  • map returns the whole project's surface — every code file's structure and every doc's outline — in a single call.

Every output is deterministic (real parsing, not a model summarizing), capped with an honest truncated flag, and framed by one contract:

lens is a navigation map. Use it to locate, then Read the real source/section before judging or modifying it. A signature is not the body; an outline is not the section.

Tools (13)

Orientation

ToolWhat it does
mapWhole-tree surface in one call: per code file → structure; per doc → title + outline. Both families, one response.
infoVersion, sandbox root, supported languages/extensions, tool list, every output cap, and the lens contract.
lens_systemInstall status, self-update (update.sh under the hood), and fetch the current AGENTS.md — lens's self-maintenance tool.

Code (tree-sitter — .ts .tsx .mts .cts .js .jsx .mjs .cjs .py) + Prisma (.prisma)

ToolWhat it does
overviewOne file's imports, exports, classes (+ methods), top-level functions, with line ranges.
functionsEvery function incl. nested — signatures, params/types, parent scope, kind.
function_bodyVerbatim source of ONE function — the focused read.
commentsComments + TODO/FIXME/BUG/HACK/… markers (markersOnly for the debt list).
findLocate a definition by name — functions, classes, and now const/type/enum/exports — across a directory.
referencesThe inverse: who uses a symbol — call sites, imports, type-refs — tree-sitter-precise, no grep false positives.

Docs (markdown — .md .markdown .mdx)

ToolWhat it does
outlineFull heading hierarchy (the TOC) with line numbers.
headingRead ONE section by heading text / slug / line number.
linksExtract inline / image / wikilink / autolink / reference links.
searchCase-insensitive full-text search across docs (heading hits ranked first).

overview/find/map also cover Prisma schemas (schema.prisma → models, enums, fields, relations). JSON config/i18n isn't structurally mapped — lens says so honestly and points you to grep.

Call a code tool on a .md (or a doc tool on a .ts) and it fails with a helpful pointer to the right tool — no silent confusion.

Honest by construction

  • Never silent data loss — a file with syntax errors returns hasErrors + parseErrors, still extracting what it can; unparseable files in map/find appear with an inline error, never vanish.
  • Caps everywhere — every list is bounded (see info.limits) and every cap is reported with the true total. A context-saving tool with unbounded output is self-refuting.
  • Path sandbox — only files under the server's working directory are readable; escaping symlinks are rejected. info reports the root.
  • Errors name the fix — {error, path, hint}, with isError set.

Install

One line clones, installs, and writes a ready-to-paste MCP config with this install's absolute path:

bash
git clone https://github.com/segentic-lab/lens-mcp && cd lens-mcp && ./install.sh

No system packages and no native build — tree-sitter runs as WebAssembly, so it works anywhere Node 18+ runs (Linux, macOS, Windows via WSL/Git Bash). The installer checks Node, runs npm ci, builds (tsc → dist/), self-tests the full suite (143 tests), and generates mcp-config.json.

Register it with your client — the generated mcp-config.json looks like:

json
{  "mcpServers": {    "lens": { "command": "node", "args": ["/abs/path/lens-mcp/dist/index.js"] }  }}
  • Claude Code: claude mcp add lens -- node /abs/path/lens-mcp/dist/index.js (or copy mcp-config.json into a project as .mcp.json)
  • Cursor / Windsurf: merge mcp-config.json into ~/.cursor/mcp.json
  • Codex CLI: add [mcp_servers.lens] with the same command/args to ~/.codex/config.toml

lens reads files under its working directory — the project your client launches it in. Point it at a project and call map("."). Nothing outside the working directory is readable.

Update later, in place:

bash
./update.sh          # git pull --ff-only + reinstall + self-test

Prefer to do it by hand? npm install && npm run build && npm test, then run node dist/index.js.

Lineage

lens-mcp supersedes the earlier split servers codelens-mcp (code) and docslens-mcp (docs) — same engines, one server, one pipeline. Sibling of periscope-mcp (web-app QA); built to the same standard: honest errors, caps + truncated flags everywhere, docs == behavior, tests before release.

Built by Segentic Lab. AGPL-3.0.

来源:README.md,提交 57d14c3

工具

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

版本历史

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

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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