mcpField
C
codelens-mcp

codelens-mcp

Local
github.comDeveloper Tools1Updated 17w ago

About codelens-mcp

codelens-mcp is a read-only MCP server for AI agents that maps TypeScript, JavaScript, and Python code to help locate code without first reading entire files. It has been superseded by lens-mcp and is no longer developed.

Key features

  1. 01Map directory and file structure
  2. 02Extract function signatures and ranges
  3. 03Read a single function body
  4. 04Find definitions and comments
  5. 05Report parse errors and truncation

Use cases

  1. 01Orient in an unfamiliar codebase
  2. 02Locate a function or class by name
  3. 03Read only the function under review

MCP support

It provides seven read-only code-navigation tools to MCP clients over stdio.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project 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 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.

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.

ToolWhat it does
mapPer-file structural overview of a whole directory tree in one call. Skips node_modules, dist, venv, hidden dirs, etc. The orientation tool.
overviewOne file's top-level structure: imports, exports, classes (with method names), functions — all with 1-based line/endLine.
functionsEvery 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.)
commentsAll 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_bodyVerbatim 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.
infoServer 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

ExtensionLanguageGrammar
.ts, .mts, .ctsTypeScripttree-sitter-typescript
.tsxTypeScript + JSXtree-sitter-tsx (dedicated grammar — JSX parses correctly)
.js, .jsx, .mjs, .cjsJavaScripttree-sitter-javascript
.pyPythontree-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.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.