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 分