Codelens Mcp

io.github.segentic-lab由 GitHub 帳號 segentic-lab 發布v0.2.0更新於 Oct 24, 2026

Deterministic code maps for AI agents: 7 tree-sitter tools for TS/JS/Py — map, find, function_body

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

一個本機 stdio MCP 伺服器,為助理提供 TypeScript、JavaScript 與 Python 程式碼的確定性結構地圖,讓它不必讀取整個檔案就能定位程式碼。

可以做什麼
一次呼叫即可產生整個目錄樹中每個檔案的結構概覽,並略過 node_modules、dist 與隱藏目錄。概述單一檔案的匯入、匯出、類別與函式,並附上行號範圍。列出所有可定址的函式及其簽章、型別與父層作用域,並依名稱讀取某個函式的原始原始碼。在目錄中尋找函式、方法或類別的定義位置,並列出帶有 TODO/FIXME 類標記的註解。回報伺服器版本、沙箱根目錄、支援的語言與各項上限。
適用情境
當助理在 TypeScript、JavaScript 或 Python 專案中工作,需要快速掌握專案結構、定位定義,或只取單一函式主體而不把整個檔案讀進上下文時適用。請注意 README 說明此專案已被後繼伺服器取代,不再繼續開發。
執行需求
本機 Node.js 18+ 執行環境;README 的安裝步驟以 npm 從原始碼建置,並以 stdio 執行編譯後的進入點。需從要分析的專案目錄啟動,因為它只讀取工作目錄下的檔案。未宣告任何帳號、金鑰或環境變數。
安裝前請注意
工具為唯讀,但路徑沙箱把存取限制在啟動目錄內,因此要從正確的專案啟動。README 標明此專案已被後繼伺服器取代且不再開發,採用前請先確認。語法錯誤會被標示出來,而不會被默默忽略。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Codelens Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

codelens-mcp

⚠️ Superseded by lens-mcp

codelens has merged into lens-mcp — one MCP server that maps both code and markdown docs. It carries every codelens tool (map, overview, functions, function_body, comments, find, info) unchanged, plus doc tools (outline, heading, links, search) and a unified map that returns a whole project's code structure and doc outlines in one call.

Use lens-mcp instead — git clone https://github.com/segentic-lab/lens-mcp. This repo remains only so existing links resolve; it is no longer developed.

(The description below is retained for reference.)


Deterministic structural code maps for AI agents. An MCP server (stdio) that gives agents the shape of a codebase — imports, exports, classes, functions, signatures, comments, TODO-markers — without reading whole files into context. Powered by tree-sitter WASM grammars: no native build step, installs anywhere Node 18+ runs.

The contract: codelens is a navigation map. Use it to locate code, then Read the actual source before judging or modifying it. A signature is not the body; an outline is not the section.

Tools

7 read-only tools. Every list in every response is capped, and every cap is reported with an explicit truncated flag — no silent cutoffs.

ToolWhat it does
mapPer-file structural overview of a whole directory tree in one call. Skips node_modules, dist, venv, hidden dirs, etc. The orientation tool.
overviewOne file's top-level structure: imports, exports, classes (with method names), functions — all with 1-based line/endLine.
functionsEvery addressable function in a file — nested functions, methods, getters/setters, class-field arrows, object-literal properties, default exports — with reconstructed signatures, param types, return type, async/exported flags, and parent scope. (Anonymous callbacks passed as arguments and Python lambdas are not listed — they have no name to navigate to.)
commentsAll comments with line ranges, kind (line/block/doc), and TODO/FIXME/FIX/BUG/HACK/NOTE/XXX marker detection (uppercase-only, no prose false-positives). markersOnly: true returns just the debt list.
function_bodyVerbatim source of one function (with decorators) by bare or dotted name (Widget.render) — the focused read that replaces whole-file Reads. Ambiguous names fail listing the candidates; it never guesses.
find"Where is X defined?" — locate function/method/class definitions by name across a directory. Definitions only, not call sites.
infoServer self-description: version, working directory (the path sandbox root), languages, caps.

overview, functions, and comments accept a single path or an array of up to 20 paths per call.

Languages

ExtensionLanguageGrammar
.ts, .mts, .ctsTypeScripttree-sitter-typescript
.tsxTypeScript + JSXtree-sitter-tsx (dedicated grammar — JSX parses correctly)
.js, .jsx, .mjs, .cjsJavaScripttree-sitter-javascript
.pyPythontree-sitter-python

Path sandbox

The server only reads files under its own working directory (the directory it was launched from). Relative paths resolve against it; absolute paths are accepted only if they point inside it; symlinks that escape it are rejected. The info tool reports the root, and every rejection names it. Launch the server from the project you want mapped.

Honesty guarantees

  • A file with syntax errors is never reported as a clean success: hasErrors: true plus parseErrors line ranges, because tree-sitter error-recovery can drop code near the error.
  • Errors set isError on the MCP result and return {error, path, hint} — the hint says how to fix the call.
  • Batch calls return per-file results plus an honest {requested, succeeded, failed} summary; isError only when every file failed.
  • Every cap is visible: truncated flags carry the true totals.

Install & run

bash
npm installnpm run build    # tsc → dist/npm test         # build + 62 tests (51 unit, 11 stdio e2e)node dist/index.js   # stdio MCP server (launch from the project to analyze)

MCP client config:

json
{  "mcpServers": {    "codelens": {      "command": "node",      "args": ["/path/to/codelens-mcp/dist/index.js"],      "cwd": "/path/to/project-to-analyze"    }  }}

For agent authors

AGENTS.md in this repo is a paste-ready guide for teaching an agent to use these tools well — core model, per-tool tips, and the pitfalls (path sandbox, language coverage, the map-vs-territory rule).

License

AGPL-3.0 — see LICENSE.

來源:README.md,提交 9c05ee5

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

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

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分