lens-mcp
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.
Related MCP server: code-analyze-mcp
Tools (13)
Orientation
Tool | What it does |
| Whole-tree surface in one call: per code file → structure; per doc → title + outline. Both families, one response. |
| Version, sandbox root, supported languages/extensions, tool list, every output cap, and the lens contract. |
| Install status, self-update ( |
Code (tree-sitter — .ts .tsx .mts .cts .js .jsx .mjs .cjs .py) + Prisma (.prisma)
Tool | What it does |
| One file's imports, exports, classes (+ methods), top-level functions, with line ranges. |
| Every function incl. nested — signatures, params/types, |
| Verbatim source of ONE function — the focused read. |
| Comments + |
| Locate a definition by name — functions, classes, and now |
| 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 |
| Full heading hierarchy (the TOC) with line numbers. |
| Read ONE section by heading text / slug / line number. |
| Extract inline / image / wikilink / autolink / reference links. |
| 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.shNo 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.jsonCodex 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-testPrefer 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.
Maintenance
Related MCP Servers
- Alicense-qualityCmaintenanceAn MCP server for semantic code search & navigation that helps AI agents work efficiently without burning through costly tokens. Instead of reading entire files, agents can search conceptually and jump directly to the specific functions, classes, and code chunks they need.Last updated118MIT
- Alicense-qualityBmaintenanceStandalone MCP server for code structure analysis using tree-sitter. Directory trees, symbol definitions, and call graphs without reading raw source files. Supports Rust, Python, Go, Java, TypeScript, Fortran, JavaScript, C/C++, and C#. Benchmarked up to 68% fewer tokens vs native tools.Last updated7Apache 2.0
- Alicense-qualityCmaintenanceToken-efficient code intelligence MCP server that indexes codebases with tree-sitter AST parsing and provides 150 tools for AI agents, using 61-95% fewer tokens than traditional grep/Read workflows.Last updated2134Business Source 1.1
- FlicenseAqualityBmaintenanceA code-intelligence MCP server for coding agents that combines a static repository map (via tree-sitter) with precise live navigation (via LSP), providing structured, token-budgeted responses anchored to file:line.Last updated14
Related MCP Connectors
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Token-efficient MCP memory for Markdown vaults. Tiered search, GraphRAG, AI memories.
An MCP server that gives your AI access to the source code and docs of all public github repos
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/segentic-lab/lens-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server