codelens-mcp

codelens-mcp

A deterministic structural code map server for AI agents, giving them 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, it runs anywhere Node 18+ works.

Category
访问服务器

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 insteadgit 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.

Tool What it does
map Per-file structural overview of a whole directory tree in one call. Skips node_modules, dist, venv, hidden dirs, etc. The orientation tool.
overview One file's top-level structure: imports, exports, classes (with method names), functions — all with 1-based line/endLine.
functions Every 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.)
comments All 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_body Verbatim 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.
info Server 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

Extension Language Grammar
.ts, .mts, .cts TypeScript tree-sitter-typescript
.tsx TypeScript + JSX tree-sitter-tsx (dedicated grammar — JSX parses correctly)
.js, .jsx, .mjs, .cjs JavaScript tree-sitter-javascript
.py Python tree-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

npm install
npm 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:

{
  "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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选