sourcelens
Indexes C/C++ codebases and retrieves exact symbol definitions such as functions, classes, and methods on demand.
Indexes JavaScript/JSX codebases and retrieves exact symbol definitions and source bodies on demand.
Indexes Python codebases and retrieves exact function, class, and method source bodies on demand.
Indexes Rust codebases and retrieves exact symbol definitions and source bodies on demand.
Indexes TypeScript/TSX codebases and retrieves exact symbol definitions and source bodies on demand.
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., "@sourcelens index ~/code and show me the source for `handle_request`"
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.
sourcelens
Token-efficient local code retrieval as an MCP server. Index a codebase once with tree-sitter AST parsing, then query exact symbols — functions, classes, methods — instead of re-reading whole files into your context window.
Built from scratch, MIT-licensed. No paid license, no network, local-first.
Why
Reading whole files to find one function is a token incinerator. sourcelens parses source into an AST once, stores each symbol's name, kind, qualified name, signature, and exact byte offsets, then serves precise bodies on demand. Pull only the function you need — not the 800-line module around it.
Related MCP server: codegraph-mcp
Install
git clone https://github.com/Phyzx72/sourcelens.git
cd sourcelens
uv venv .venv && source .venv/bin/activate
uv pip install -e .Requires Python 3.10+.
Run
Stdio (default MCP transport):
sourcelens # or: python -m sourcelens.serverHTTP (for remote clients):
SOURCELENS_HTTP=1 SOURCELENS_PORT=8766 sourcelensThe index is a SQLite file at ~/.sourcelens/index.db by default. Override with SOURCELENS_DB=/path/to/index.db.
Tools
Tool | What it does |
| Walk + parse every supported file, store symbols + imports |
| Find symbols by name substring |
| Fetch a symbol's exact body (byte-precise, no whole-file read) |
| List all symbols in a file, source order |
| Which files import a module |
| What a file imports |
| Index counts + per-language breakdown |
| Supported languages |
Supported languages
Python (.py), JavaScript (.js/.jsx), TypeScript (.ts/.tsx), Go (.go), Rust (.rs), C/C++ (.c/.h/.cpp/.hpp).
Usage pattern (the whole point)
index_folder("/path/to/repo")— once.search_symbols("handle_request")— find it.get_symbol_source(name="handle_request")— get only that function's body.
Never Read a whole file to find one symbol again.
Tests
pip install -e '.[dev]'
python -m pytest tests/ -vLicense
MIT. See LICENSE.
Available Tools
8 toolsfind_importersA
Find files that import the given module/target.
Matches exact or suffix module paths (e.g. "os", "fmt", "utils.foo").
Inputs: target (required).
find_importsC
List what a single file imports, in source order.
Inputs: file (required).
get_file_outlineA
List every symbol declared in a file, in source order.
Use this instead of reading a whole file — it returns the outline (name, kind, line range, signature) so the agent can then pull only the symbol bodies it actually needs.
Inputs: file (required).
get_symbol_sourceA
Fetch a symbol's exact source by id, or by name (+optional file).
Returns the precise byte range from disk (no whole-file read), so an agent gets only the function/class body it needs. Provide symbol_id OR name.
Inputs: file, name, symbol_id.
index_folderA
Index every supported source file under path (absolute or relative).
Walks the tree, parses each file with tree-sitter, and stores symbols + imports in the local SQLite index. Safe to re-run; files are replaced idempotently by path. Returns counts of what was indexed.
Inputs: path (required).
list_languagesA
Return the languages this indexer supports.
Inputs: no named parameters.
search_symbolsA
Search indexed symbols by name substring.
Returns each match with its qualified name, kind, language, file path, and
line range. Use get_symbol_source to fetch exact body text. kind filters
to e.g. function/class/method; language to python/go/typescript/etc.
Inputs: query (required), kind, limit, language.
statsA
Return index stats: file count, symbol count, per-language breakdown.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
每个工具都有明确的资源+动作组合,但 find_importers 和 find_imports 的名称几乎相同,功能互为反向,可能造成误选。其余工具如 search_symbols 与 get_symbol_source 通过描述清楚区分。
大多数工具遵循 snake_case 的 动词_名词 模式,如 search_symbols、get_symbol_source、find_importers。但 stats 是纯名词,且动词在 list/index/search/get/find 之间不统一,存在轻微不一致。
8 个工具覆盖了索引、统计、符号搜索、源码获取、文件大纲和依赖分析,每个工具都有明确用途,没有冗余,范围对于代码索引服务器非常合适。
核心工作流(索引、查询符号、查看文件大纲、分析导入关系)覆盖完整。缺少显式的索引删除或清理操作,但 index_folder 的幂等重跑可以在一定程度上替代更新,代理也能通过重新索引绕过。
Maintenance
Related MCP Connectors
Ask a codebase what calls what: search, blast radius, paths between symbols, and diffs.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides token-efficient code retrieval for coding agents by indexing repositories and enabling ranked snippet search, symbol outlines, and surgical line reads.5 npmMIT
- FlicenseNot gradedqualityBmaintenanceProvides efficient code navigation and graph-based analysis for AI agents, enabling symbol resolution, callers, implementations, and type schemas with minimal token usage.-
- FlicenseAqualityDmaintenanceProvides codebase indexing and retrieval tools that give AI agents token-efficient, query-relevant context packages (symbols, imports, and dependencies) instead of scanning entire repositories.6-
- FlicenseNot gradedqualityBmaintenanceProvides graph-native code intelligence for coding agents, enabling them to navigate repositories through compact SQLite-backed symbol graphs and retrieve full source only for relevant symbols.-