lens-mcp
Deterministic navigation maps over code AND markdown for AI agents: one MCP server, two lenses (tree-sitter TS/JS/Python + markdown). Map a whole project, read one function or one doc-section, ~99% less context. Merges codelens + docslens.
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_bodyreads one function — often ~99% less context than Reading the file it lives in.headingreads one doc section — the referenced heading and its subsections, nothing else.mapreturns 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
| Tool | What it does |
|---|---|
map |
Whole-tree surface in one call: per code file → structure; per doc → title + outline. Both families, one response. |
info |
Version, sandbox root, supported languages/extensions, tool list, every output cap, and the lens contract. |
lens_system |
Install 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)
| Tool | What it does |
|---|---|
overview |
One file's imports, exports, classes (+ methods), top-level functions, with line ranges. |
functions |
Every function incl. nested — signatures, params/types, parent scope, kind. |
function_body |
Verbatim source of ONE function — the focused read. |
comments |
Comments + TODO/FIXME/BUG/HACK/… markers (markersOnly for the debt list). |
find |
Locate a definition by name — functions, classes, and now const/type/enum/exports — across a directory. |
references |
The inverse: who uses a symbol — call sites, imports, type-refs — tree-sitter-precise, no grep false positives. |
Docs (markdown — .md .markdown .mdx)
| Tool | What it does |
|---|---|
outline |
Full heading hierarchy (the TOC) with line numbers. |
heading |
Read ONE section by heading text / slug / line number. |
links |
Extract inline / image / wikilink / autolink / reference links. |
search |
Case-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 inmap/findappear with an inlineerror, 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.
inforeports the root. - Errors name the fix —
{error, path, hint}, withisErrorset.
Install
One line clones, installs, and writes a ready-to-paste MCP config with this install's absolute path:
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:
{
"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 copymcp-config.jsoninto a project as.mcp.json) - Cursor / Windsurf: merge
mcp-config.jsoninto~/.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:
./update.sh # git pull --ff-only + reinstall + self-test
<sub>Prefer to do it by hand? npm install && npm run build && npm test, then
run node dist/index.js.</sub>
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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。