segentic-lab

lens-mcp

Community segentic-lab
Updated

Deterministic navigation maps over code AND markdown for AI agents — one MCP server, two lenses (tree-sitter TS/JS/Python + markdown). map the whole project, read one function or one doc-section, 99% less context. Merges codelens + docslens.

lens-mcp

Deterministic navigation maps over code AND markdown — for AI agents. OneMCP server, two lenses: tree-sitter for source (TypeScript / JavaScript /Python) and a markdown lens for docs. It answers "where is X and what's theshape of this project?" in one cheap call — so an agent spends context onthinking, not on browsing files.

Speaks the Model Context Protocol; workswith 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 rightdoc. lens returns the map instead of the territory:

  • function_body reads one function — often ~99% less context than Readingthe file it lives in.
  • heading reads one doc section — the referenced heading and itssubsections, nothing else.
  • map returns the whole project's surface — every code file's structureand every doc's outline — in a single call.

Every output is deterministic (real parsing, not a model summarizing), cappedwith an honest truncated flag, and framed by one contract:

lens is a navigation map. Use it to locate, then Read the realsource/section before judging or modifying it. A signature is not the body;an outline is not the section.

Tools (11)

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.

Code (tree-sitter — .ts .tsx .mts .cts .js .jsx .mjs .cjs .py)

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 function/method/class definition by name across a directory.

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

Call a code tool on a .md (or a doc tool on a .ts) and it fails with ahelpful 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 in map/findappear with an inline error, never vanish.
  • Caps everywhere — every list is bounded (see info.limits) and every capis reported with the true total. A context-saving tool with unbounded outputis self-refuting.
  • Path sandbox — only files under the server's working directory arereadable; escaping symlinks are rejected. info reports the root.
  • Errors name the fix{error, path, hint}, with isError set.

Install

One line clones, installs, and writes a ready-to-paste MCP config with thisinstall'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 itworks anywhere Node 18+ runs (Linux, macOS, Windows via WSL/Git Bash). Theinstaller checks Node, runs npm ci, builds (tsc → dist/), self-tests the fullsuite (135 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 copy mcp-config.json into a project as .mcp.json)
  • Cursor / Windsurf: merge mcp-config.json into ~/.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 clientlaunches it in. Point it at a project and call map("."). Nothing outside theworking directory is readable.

Update later, in place:

./update.sh          # git pull --ff-only + reinstall + self-test

Prefer to do it by hand? npm install && npm run build && npm test, thenrun node dist/index.js.

Lineage

lens-mcp supersedes the earlier split servers codelens-mcp (code) anddocslens-mcp (docs) — same engines, one server, one pipeline. Sibling ofperiscope-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.

MCP Server · Populars

MCP Server · New

    cbtw-apac

    QDrant Loader

    Enterprise-ready vector database toolkit for building searchable knowledge bases from multiple data sources. Supports multi-project management, automatic ingestion from Confluence/JIRA/Git, intelligent file conversion (PDF/Office/images), and semantic search. Includes MCP server for seamless AI assistant integration.

    Community cbtw-apac
    aks129

    HealthClaw Guardrails

    Open-source guardrails between AI agents and FHIR clinical data — PHI redaction, immutable audit, step-up auth, tenant isolation. MCP server + OpenAI/Gemini adapters. A healthclaw.io project.

    Community aks129
    opentargets

    Open Targets Platform MCP

    Official MCP server implementation for accessing Open Targets Data

    Community opentargets
    longsizhuo

    openInvest

    基于multiple LLM的风险投资助手

    Community longsizhuo
    CCCpan

    Gebaini

    中国数据核验 MCP Server | 身份核验/企业查询/车辆信息/OCR识别/风险评估 | 10个Tool覆盖5大类 | 微信: chenganp | 邮箱: [email protected]

    Community CCCpan