reference-mcp
The reference-mcp server helps AI agents deeply understand and navigate Python codebases by building a tree-sitter index and exposing structured tools for code exploration:
repo_overview— High-level summary of the repository: languages, layout, file/LOC/symbol counts, entry points, tests, config files, and frameworks.get_file_outline— View the symbol skeleton (classes, methods, functions, variables with line numbers) of a file or directory without reading full source bodies.find_symbol— Locate where a function, class, method, or variable is defined, with optional full source and "did you mean" suggestions.find_references— Find every usage/call site of a symbol across the repo with file:line context.trace_call_graph— Trace callers or callees of a function to N levels, returning an indented call tree with file:line references.get_type_hierarchy— Visualize a class's full type hierarchy: superclasses upward and subclasses/Protocol-ABC implementations downward.search_code— Search via exact text, regex, or natural-language semantic queries (e.g., "where is auth handled?"), with path glob filtering and pagination.get_dependencies— Show what a file imports (internal vs. external) and which files depend on it (blast radius).code_history— Explore git blame, recent commits, churn stats, and author history for a file or specific line range to understand why code exists.find_tests— Map a symbol to the tests that cover it, or a test file to the symbols it exercises.
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., "@reference-mcp what is this project about?"
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.
reference-mcp
An MCP server whose tools help an AI agent comprehend a codebase — get oriented, navigate by meaning rather than text, trace relationships, and understand why code is shaped the way it is.
It builds its own tree-sitter index of a Python project (no language servers required) and exposes a small set of consolidated, high-leverage tools designed around current agent tool-design best practices: human-readable returns, built-in token budgeting and pagination, and actionable errors.
Tools
Tool | What it answers |
| "What is this project?" — languages, layout, entry points, tests, configs. |
| "What's in this file?" — symbol skeleton without reading bodies. |
| "Where is X defined?" — locate a function/class/method/var, optionally with body. |
| "Where is X used?" — call sites and usages with context. |
| "Where is the code that …?" — lexical/regex search, or natural-language semantic search (optional). |
| "What does this import / what depends on it?" — forward and reverse deps. |
| "Why is this code here?" — git blame/log/churn for a symbol or region. |
| "What tests cover this?" — symbol ⇄ test mapping. |
| "What calls this / what does it call?" — callers/callees to N levels. |
| "What's the class tree?" — subclasses, superclasses, implementations. |
Related MCP server: codeweave-mcp
Quickstart
uv sync --extra dev
# Point the server at a codebase and run it over stdio:
REFERENCE_MCP_REPO=/path/to/your/project uv run reference-mcp
# Or inspect interactively:
npx @modelcontextprotocol/inspector uv run reference-mcpSemantic search (optional)
Lexical search works out of the box. To also enable natural-language search ("where is auth handled?"), install the local-embeddings extra — no API key, no network at query time once the model is cached:
uv sync --extra semanticThen call search_code with mode="semantic". It embeds each symbol
(name + signature + docstring) with fastembed
(ONNX, model BAAI/bge-small-en-v1.5 by default, override via
REFERENCE_MCP_EMBED_MODEL), caches the vectors in the index cache dir, and ranks
by cosine similarity. Without the extra, mode="semantic" returns install guidance
instead of failing.
Register with an MCP client
{
"mcpServers": {
"reference": {
"command": "uv",
"args": ["run", "reference-mcp"],
"env": { "REFERENCE_MCP_REPO": "/path/to/your/project" }
}
}
}Configuration
Env var | Default | Purpose |
| cwd | Absolute path to the codebase to analyze. |
|
| Where the SQLite index is stored (never inside your repo). |
|
| Soft per-response token cap. |
Design notes
Read-only. The server never edits your code; it only reads and indexes it.
Incremental index. Files are re-parsed only when their content hash changes.
Precision tradeoff. Reference/call-graph resolution is scope- and import-aware name matching, not full type inference. Accurate for most Python; a future LSP backend can slot in behind the same tool surface for dynamic-dispatch-heavy code. To curb false positives,
find_referencesignores matches inside strings/comments (tree-sitter span masking), andtrace_call_graphdrops anobj.method()call when its name matches several methods. The residual case it cannot resolve: anobj.method()call whose name matches exactly one project method of an unrelated type (e.g. adict.get()call when the project defines a singlegetmethod) — undecidable without type inference.
Development
uv run ruff check . # lint
uv run ruff format . # format
uv run mypy # type-check (src/)
uv run pytest # unit + integration tests
uv run python evals/run_evals.py # eval harness (must be 100%)CI runs all of the above on every push and PR (see .github/workflows/ci.yml).
Available Tools
10 toolscode_historyA
Explain WHY code looks the way it does using git: recent commits touching a file, churn stats (commit count, authors, age), and optional line-range blame.
Provide start_line/end_line to get blame for a specific region. Requires the
repo to be a git checkout.
Inputs: file (required), start_line, end_line, max_commits. Returns: result
find_referencesA
Find every USE-SITE of a symbol (calls, attribute access, imports) across the repo, each with file:line and the source line.
Resolution is scope/import-aware name matching, not full type inference — very
accurate for module-level functions/classes; methods may include same-named
calls on unrelated types. Use find_symbol to see where it is defined instead.
Inputs: name (required), include_definitions, limit, offset. Returns: result
find_symbolA
Locate where a function/class/method/variable is DEFINED.
Returns each definition's kind, qualified name, and 'path:line'. With
include_body=True, also returns the full source of each match. If nothing
matches you get 'did you mean' suggestions.
Do NOT use to find usages/call sites — use find_references. Do NOT use for
free-text search — use search_code.
Inputs: name (required), kind, include_body, response_format, +2 more. Returns: result
find_testsA
Map a symbol to the tests that exercise it — or a test file to the symbols it exercises.
If 'target' is a test file path, returns the modules/symbols it pulls in.
Otherwise treats it as a symbol name and returns the test files + test_*
functions that reference it. Use before changing code to know what to run.
Inputs: target (required). Returns: result
get_dependenciesA
Show what a file imports (internal vs external) and which files import IT (reverse dependencies / blast radius).
Use to gauge the impact of changing a module. Returns import edges with line numbers and the list of dependent files.
Inputs: path (required), response_format. Returns: result
get_file_outlineA
List the symbol skeleton of a file or directory WITHOUT reading bodies — the cheapest way to understand what a file contains.
Returns a nested outline (classes, methods, functions, module vars) with line numbers. Prefer this over reading a whole file when you only need its shape.
Inputs: path (required), response_format. Returns: result
get_type_hierarchyA
Show a class's type hierarchy: superclasses upward and subclasses / Protocol-ABC implementations downward.
Returns two indented trees with 'path:line'. External bases (e.g. pydantic
BaseModel) appear as leaves marked external/unresolved.
Inputs: name (required), depth. Returns: result
repo_overviewA
Summarize the entire repository in one call — run this FIRST on an unfamiliar codebase.
Returns: project name, file/LOC/symbol counts, detected package manager,
config files, entry points, test setup, notable frameworks, and a per-top-level
-package size map (files/LOC/classes/functions).
Do NOT use for finding a specific symbol or file — use find_symbol or
get_file_outline for that.
Inputs: no named parameters. Returns: result
search_codeA
Search the repo, filtered and paginated. mode='lexical' does exact/regex text matching; mode='semantic' ranks symbols by natural-language meaning ("where is auth handled?").
Returns file:line plus the matching line (lexical) or matched symbol (semantic).
Use this when you do NOT know the exact symbol name. Prefer find_symbol /
find_references when you DO — they are structural and far more precise.
Inputs: query (required), mode, regex, path_glob, +3 more. Returns: result
trace_call_graphA
Trace the call graph from a function — callers or callees — to N levels, in one call (instead of chaining find_references by hand).
Returns an indented tree of qualified names with 'path:line'. Recursion and the
depth limit are marked inline. Shares the name-resolution precision tradeoff of
find_references.
Inputs: name (required), direction, depth. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct aspect of code analysis (e.g., symbol definition vs. references vs. call graph), with no overlap in purpose. Descriptions clearly differentiate them.
Most tools follow a verb_noun pattern (find_symbol, search_code, get_file_outline, trace_call_graph), with a few exceptions like repo_overview and code_history that are still clear and not confusing.
10 tools is well-scoped for a code reference server, covering all major analysis needs without bloat. Each tool serves a clear, non-redundant purpose.
The tool surface is comprehensive, covering repo overview, file outline, symbol definition, references, call graph, dependencies, tests, type hierarchy, search, and git history. No obvious gaps for understanding a codebase.
Maintenance
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Repository knowledge graph MCP server for codebase understanding and debugging.
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that transforms codebases into intelligent, queryable knowledge bases, enabling AI assistants to perform semantic search, explore architecture, and analyze code relationships.166-
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI agents structured code understanding and precise code intelligence via local indexing of AST, call graphs, and semantic search.73 npm4Apache 2.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI agents to navigate and understand codebases through file descriptions, semantic search, and code recommendations without repeatedly scanning files.MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI coding agents structured access to a project's architecture, rules, modules, and technical decisions.MIT