codelens-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codelens-mcp show me the overview of src/utils.ts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 unifiedmapthat 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.
Related MCP server: code-analyze-mcp
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 |
| Per-file structural overview of a whole directory tree in one call. Skips |
| One file's top-level structure: imports, exports, classes (with method names), functions — all with 1-based |
| 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, |
| All comments with line ranges, kind ( |
| Verbatim source of one function (with decorators) by bare or dotted name ( |
| "Where is X defined?" — locate function/method/class definitions by name across a directory. Definitions only, not call sites. |
| 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 |
| TypeScript | tree-sitter-typescript |
| TypeScript + JSX | tree-sitter-tsx (dedicated grammar — JSX parses correctly) |
| JavaScript | tree-sitter-javascript |
| 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: trueplusparseErrorsline ranges, because tree-sitter error-recovery can drop code near the error.Errors set
isErroron 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;isErroronly when every file failed.Every cap is visible:
truncatedflags 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.
Available Tools
7 toolscommentsA
All comments in a file with 1-based line ranges, kind (line | block | doc — doc covers /** */ and Python docstrings in real docstring position), and marker detection. Returns JSON {path, language, hasErrors, comments[{line, endLine, text, kind, marker}]}. marker is TODO|FIXME|FIX|BUG|HACK|NOTE|XXX when the comment contains that UPPERCASE word (case-sensitive to avoid prose false-positives), else null. Set markersOnly:true to get only marked comments (the debt list). Comment text clips at 600 chars (textTruncated:true); list caps at 500. Languages: TS/TSX/JS/JSX/Python. Use for surveying docs/debt without reading whole files. 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.
Inputs: path (required), markersOnly.
findA
Locate a function, method, or class by name across a directory — "where is X defined?" without grepping. Returns JSON {query, path, matches[{file, name, kind, line, signature, parent}], filesScanned, totalSupportedFiles, truncated, skipped?}. kind is function|method|arrow|getter|setter|class. Matching is case-insensitive substring by default; pass exact:true for exact-name match. Files that could not be searched (oversized/unreadable) are listed in skipped with the reason — never silently ignored. Caps: scans up to 300 files, returns up to 100 matches — truncated:true means there may be more (narrow the path or use exact:true). Finds DEFINITIONS only (not call sites — use grep for those). Languages: TS/TSX/JS/JSX/Python. 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.
Inputs: name (required), path, exact.
function_bodyA
Verbatim source of ONE function — the focused read. Instead of Reading a whole file to inspect one function, get exactly that function's source (including its signature and decorators). Returns JSON {path, name, parent, kind, signature, line, endLine, async, exported, hasErrors, body}. name matches the bare name or the dotted qualified form from functions/find output (e.g. 'Widget.render'); if the name is ambiguous, the call FAILS listing the candidates with their lines — pass the qualified name or line to pick one, it never guesses. body is real source, capped at 20000 chars (truncated.bodyChars = true length — Read line..endLine for the rest). The body IS the territory for this one function, so you may reason about its internals — but not about its callers/callees, and re-Read before editing (files change). Languages: TS/TSX/JS/JSX/Python.
Inputs: name (required), path (required), line.
functionsA
Every addressable function in a file — nested functions, class methods, getters/setters, class-field arrows, namespace members, object-literal methods/properties, default-export functions — with reconstructed signatures. NOT listed: anonymous callbacks passed as arguments (they have no name to navigate to), TS overload signature declarations (only implementations), Python lambdas. Returns JSON {path, language, hasErrors, functions[{name, signature, params[{name,type}], returnType, line, endLine, async, exported, kind, parent}]}. kind is function|method|arrow|getter|setter; parent is the enclosing scope, dotted for nesting (e.g. 'Widget.render'), null at top level; default exports are named 'default'. hasErrors:true = syntax errors, items may be missing. Caps at 500 entries (truncated.functions = true total). Languages: TS/TSX/JS/JSX/Python. Use it to pick the right line range to Read, or to survey an API surface. 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.
Inputs: path (required).
infoA
Server self-description: version, working directory (the path sandbox root — every path you pass must be inside it), supported languages/extensions, tool list, and all output caps. Returns JSON {name, version, workingDirectory, languages, tools[], limits, contract}. Read-only, no parameters. Call this first if a path is rejected or you need to know what the server can see.
Inputs: no named parameters.
mapA
Per-file structural overview of a whole directory tree in one call — the orientation tool for an unfamiliar codebase. Walks the directory recursively (skipping node_modules, dist, build, venv, pycache, hidden dirs and other build/dependency dirs), parses every supported file, and returns JSON {path, files[{path, language, totalLines, classes[], functions[], hasErrors?, error?}], totalSupportedFiles, filesParsed, truncated}. Caps: 200 files per call (truncated:true when more exist — map subdirectories individually to go deeper), 100 names per list per file. Unparseable files appear with an inline error instead of vanishing. Languages: TS/TSX/JS/JSX/Python; other files are not counted. Use before overview/functions to decide which files matter. 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.
Inputs: path (required).
overviewA
Structural map of source files: imports, exports, classes (with method names, including class-field arrow methods), and top-level functions — each with 1-based line/endLine so you can jump straight to a Read. Returns JSON {path, language, totalLines, hasErrors, imports[], exports[], classes[{name,line,endLine,methods[]}], functions[{name,line,endLine,exported}]}. hasErrors:true means the file has syntax errors and items may be missing (parseErrors lists the offending line ranges). Nested functions are NOT listed here (use the functions tool). Lists cap at 500 entries; when capped, truncated. holds the true total. Languages: TypeScript (.ts/.tsx/.mts/.cts), JavaScript (.js/.jsx/.mjs/.cjs), Python (.py). Python exports come from all. Use this FIRST to orient in an unfamiliar file. 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.
Inputs: path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
overview and functions both list functions/classes, but overview provides a high-level structural map while functions exhaustively lists all addressable functions; the descriptions clearly differentiate them. map covers directory trees, find locates definitions by name, and function_body returns verbatim source, so each tool has a distinct role with minor potential confusion.
Most tool names are simple lowercase nouns (overview, functions, comments, map, info), but 'find' is a verb and 'function_body' uses an underscore, breaking a uniform pattern. The naming is still predictable and readable, though not consistently verb_noun or single-style.
Seven tools is well-scoped for a code navigation and analysis server. Each tool serves a distinct purpose, and none feel redundant or unnecessary.
The toolset covers the core navigation lifecycle: directory maps, file overviews, function details, comment exploration, definition lookup, and focused source extraction. Missing are call sites or full-text search, but the stated purpose of locating code is well covered.
Maintenance
Related MCP Connectors
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Code-map tools for AI agents: see a repo's structure first, then edit only what matters.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides code context and analysis for AI assistants by extracting directory structures and code symbols using WebAssembly Tree-sitter parsers with zero native dependencies.143 npm20MIT
- AlicenseNot gradedqualityBmaintenanceStandalone 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.7Apache 2.0

loctree-mcpofficial
FlicenseNot gradedqualityBmaintenanceStructural code intelligence for AI agents. Scan once, query everything — dead exports, circular imports, dependency graphs, and more. CLI + MCP server.6 npm10-- AlicenseNot gradedqualityDmaintenanceAn MCP server that indexes your codebase using tree-sitter AST parsing and gives AI tools instant access to structural intelligence like dependency graphs, call trees, and dead code detection from a local SQLite database.MIT