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 分