repodigest-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., "@repodigest-mcppack_task_context to implement BM25 scoring, budget 1500"
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.
repodigest-mcp
Token-efficient code context for AI coding assistants: Python signatures, call graphs and budget-packed context, served locally over MCP.
repodigest-mcp is a Model Context Protocol server that wraps
RepoDigest's static analysis (AST parsing, call graph, BM25 search,
token-budgeted packing) so that Claude Code, Cursor, or any MCP client can ask for exactly the slice of a
codebase it needs instead of reading whole files.
The problem
Coding assistants explore a repository by reading files. To learn what one function accepts and returns, the assistant pulls in the entire file: every other function, every body, every import. On a real module that is routinely 90%+ noise for the question being asked, and it compounds over a session:
Context bloat. The window fills with code that doesn't matter, leaving less room for the code that does.
Cost and latency. You pay for every token in, on every subsequent turn.
Worse answers. Relevant details get buried in long contexts.
Most of what an assistant needs is structural, and structure can be extracted deterministically. A function's interface is its signature and docstring. Its blast radius is its callers and callees. The code relevant to a task is a neighbourhood in the call graph around the best-matching symbol. None of that needs a model; it needs an AST.
repodigest-mcp exposes those three operations as MCP tools. It runs as a local stdio subprocess: no daemon, no
cloud service, no telemetry, and your source is parsed on your machine. (The only network access is tiktoken
fetching its tokenizer vocabulary once on first use, after which it is cached.)
Related MCP server: pyscope-mcp
Tools
All three tools are read-only. Failures come back as MCP tool errors (is_error=True) with a message the model
can act on, never as a crash or an empty result.
Tool | Purpose |
A function/class/method's signature and docstring, without the body | |
Direct callers and callees, across files | |
Best-matching code for a task, packed into a token budget |
symbol_name accepts a fully-qualified name (pkg.mod.Class.method) or any dotted suffix (Class.method,
method). path is the repository root and defaults to ., the server's working directory.
get_symbol_signature(symbol_name, path)
Returns the definition header and docstring only. Classes come back with every method stubbed to its signature. For a method in a large file this is typically 90%+ fewer tokens than reading the file (measured below).
# repodigest.search.ranker.SymbolRanker.score (repodigest/search/ranker.py)
def score(self, query: str, symbol: str) -> float:
...The first line names the symbol the request resolved to and where it lives, which matters when you passed a short suffix.
get_symbol_dependencies(symbol_name, path)
Direct callers and callees from the repository call graph, across files. Returned as structured content:
{
"symbol": "repodigest.search.ranker.SymbolRanker.rank",
"kind": "method",
"file": "repodigest/search/ranker.py",
"callers": ["repodigest.search.ranker.SymbolRanker.top"],
"callees": ["repodigest.search.ranker.SymbolRanker.score"]
}Edges are matched by simple name, with no import or type resolution. Common names (
get,run) can produce false positives, andFoo()links to the classFoo, not toFoo.__init__.
pack_task_context(query, budget, signatures_only, path)
Given a natural-language query, the tool:
ranks every symbol in the repo with BM25 and takes the best match as the root;
expands breadth-first through the call graph, alternating callees and callers, nearest first;
packs symbols until the token budget is spent, skipping (never truncating) anything that no longer fits;
returns compact XML.
Parameter | Default | Meaning |
| required | What you're working on, e.g. |
|
| Max tokens ( |
|
| Pack everything except the root as signature + docstring |
|
| Repository root |
A real call, query="score symbols with BM25", budget=1500, signatures_only=true (abbreviated with …):
<context>
<file path="…/repodigest/search/ranker.py">
<symbol name="repodigest.search.ranker.SymbolRanker" kind="class" tokens="525">
<![CDATA[
class SymbolRanker:
"""BM25 ranking over a corpus of `{symbol: text}` documents."""
…
]]>
</symbol>
</file>
<file path="…/repodigest/cli.py">
<symbol name="repodigest.cli.pack_command" kind="function" tokens="247">
…
</symbol>
</file>
<usage total_tokens="772" budget="1500" symbols_packed="2" symbols_skipped="0" />
</context>The root is always included in full. Here it is a class, followed by one of its callers.
budget counts the packed source only. The XML tags around it are not counted, so leave roughly 10% headroom.
If the best match cannot fit, the tool says so instead of returning something misleading. This is a real
response from the same repository at budget=500:
Error executing tool pack_task_context: Best match 'repodigest.search.ranker.SymbolRanker' needs 525 tokens but the budget is 500; raise budget to at least 525.Errors the tools handle
Situation | Behaviour |
Symbol not found | Error, with "did you mean" suggestions for near misses |
Ambiguous suffix ( | Error listing the candidates (first 5, then |
| Error naming the path |
Directory with no Python symbols | Error, rather than an empty result |
Empty | Error explaining the constraint |
Root symbol larger than | Error stating the budget needed |
Unparsable or non-UTF-8 | Skipped with a warning on stderr; the rest is indexed |
Architecture
MCP client (Claude Code, Cursor, ...)
│ JSON-RPC over stdio
▼
server.py three read-only tools; translates failures into tool errors
│
▼
index.py cached per-repo index: symbol registry · call graph · BM25 ranker
│ file discovery, error-tolerant parsing, symbol resolution
▼
RepoDigest py_parser · CallGraph · SymbolRanker · ContextPackerRepoDigest does the analysis. index.py decides which files it sees and remembers the result.
Optimizations
mtime/size-cached indexer. Each repo root gets one index (registry, call graph, ranker), stamped with a
fingerprint of (path, mtime, size) for every Python file. A repeated call against an unchanged tree reuses the
index. Editing, adding or deleting a file changes the fingerprint and triggers a rebuild on the next call. A
warm lookup on the RepoDigest repo took under 5 ms.
Virtual environments and vendored code are excluded automatically. Discovery prunes:
hidden directories (
.venv,.git,.tox,.cache, ...);any directory containing a
pyvenv.cfg, so virtualenvs are caught whatever they are named (venv,myenv), while an ordinary package that merely happens to be calledenvis kept;site-packages,node_modulesand__pycache__.
This matters because RepoDigest's own directory walker globs every *.py under the root. Pointed at this
project's directory, it collected 1,825 files (nearly all of them from the virtualenv) and took about 5 s.
repodigest-mcp indexed the same directory in 0.03 s, and none of the virtualenv's symbols leaked into search
results. If you deliberately pass a virtualenv as the root, it is indexed.
Fault-tolerant parsing. One file with a syntax error or a stray non-UTF-8 byte does not take down the index. That file is skipped and logged.
Protocol-safe logging. On stdio, stdout belongs to the protocol. All logging goes to stderr; use
repodigest-mcp --log-level DEBUG to see more.
Token efficiency
Measured on RepoDigest's own source with cl100k_base. "Signature" is the exact string
get_symbol_signature returns, header line included. "Saved" compares it to reading the file the symbol lives in.
Symbol | Signature | Symbol source | Whole file | Saved vs. file |
| 40 | 200 | 1,221 | 96.7% |
| 40 | 146 | 766 | 94.8% |
| 48 | 346 | 877 | 94.5% |
| 110 | 196 | 1,803 | 93.9% |
| 37 | 189 | 450 | 91.8% |
| 166 | 677 | 1,221 | 86.4% |
Across these six symbols the saving versus reading the whole file is 86% to 97%. The gap narrows against the symbol's own body (44% to 86% here) because the body of a short function is not much larger than its signature: the big win comes from not reading the rest of the file. Your numbers will vary with file size and docstring density.
Installation
Requires Python 3.10+. repodigest is not published to PyPI, so install it from GitHub first, then install
this package in editable mode:
git clone https://github.com/nagendra-kon/repodigest-mcp.git
cd repodigest-mcp
python3 -m venv venv
source venv/bin/activate
pip install "repodigest @ git+https://github.com/nagendra-kon/repodigest.git" # the analysis engine
pip install -e ".[dev]" # this server + pytest
repodigest-mcp --versionIf you already have a local RepoDigest checkout, pip install -e ../repodigest works in place of the GitHub line.
Claude Code
Register the server with the absolute path to the venv's executable, because the client launches it as a
subprocess and it must use the interpreter that has the dependencies installed. From the repodigest-mcp
directory:
claude mcp add repodigest -- "$(pwd)/venv/bin/repodigest-mcp"Add --scope user to make it available in every project, or --scope project to share it via .mcp.json. Check
it with claude mcp list.
Cursor
Add the server to .cursor/mcp.json in your project (or ~/.cursor/mcp.json for all projects):
{
"mcpServers": {
"repodigest": {
"command": "/absolute/path/to/repodigest-mcp/venv/bin/repodigest-mcp",
"args": []
}
}
}Which repository does it read?
Tools default to path=".", the server's working directory. If your client starts the server somewhere other
than the project you're working on, pass path explicitly (for example, tell the assistant which directory to
use) or start the server from the right directory. The server is read-only, but path is not sandboxed: it will
read .py files under any directory the client names.
Try it
Once registered, ask your assistant things like:
"Show me the signature of
AuthService.login.""What calls
hash_password, and what does it call?""Pack context for adding rate limiting to the login handler, in 1,500 tokens."
Testing
pytest tests/ -v # 61 tests, ~2 sThe suite runs against a synthetic multi-file project built in a temp directory. That project includes a
fake virtualenv, a hidden directory, node_modules, a file with a syntax error and a non-UTF-8 file, so the
exclusion and fault-tolerance paths are exercised for real.
File | Tests | Covers |
| 38 | MCP client integration: every tool called through a real in-process MCP client session (schema, structured output, |
| 23 | Indexing edge cases: virtualenv, hidden-dir and vendored-dir exclusion (venv detected by |
The budget tests assert that reported total_tokens never exceeds budget, that the per-symbol token counts sum
to the total, that smaller budgets pack fewer symbols and report what was skipped, and that a root symbol that
cannot fit is an error rather than a silent empty result. Integration tests use the official MCP Python client.
Limitations
Python only. Symbols are top-level functions, classes and methods; nested functions are not indexed separately.
Name-based call graph. See the note under
get_symbol_dependencies.Token counts are a proxy. They use
tiktoken'scl100k_base, not Claude's own tokenizer, so treat budgets as close approximations. The budget also excludes the XML markup.mcp>=2.0only. MCP SDK 2.x renamedFastMCPtoMCPServer; this package targets the 2.x API.
License
MIT. Built on RepoDigest.
This server cannot be deployed
Maintenance
Related MCP Connectors
Codebase graphs, caller impact analysis, and recorded project context for AI coding agents.
Repository knowledge graph MCP server for codebase understanding and debugging.
The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.
An MCP server that gives your AI access to the source code and docs of all public github repos
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with a structured, token-efficient map of a codebase's symbols, dependencies, and relationships via MCP tools like overview, query, and impact analysis.8MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that exposes Python function- and module-level call graphs for agentic coding clients, enabling tools like callers_of, callees_of, and neighborhood queries.MIT
- AlicenseAqualityDmaintenanceUniversal MCP server that analyzes any codebase and provides structured context to AI assistants. Dynamic, accurate, and token-efficient.187 npmMIT
- AlicenseNot gradedqualityDmaintenanceServes structured code context via MCP, enabling AI agents to understand codebases with dependency graphs and significantly reduce token usage.13 npmMIT