XRAY MCP
XRAY MCP is a code-navigation MCP server that lets an agent see a codebase's shape — structure, definitions, signatures and references — without reading whole files.
Map a repo with
explore_repo(root_path, max_depth, include_symbols, focus_dirs, max_symbols_per_file): a.gitignore-aware directory tree, optionally annotated with each file's signatures and doc lines, for progressive drill-down from structure to detail.Find definitions with
find_symbol(root_path, query): fuzzy, case/separator-insensitive search over functions, methods, classes and types, returning name, type, parent, path and line range.Read a file's API with
read_interface(root_path, file_path): every class/function/method signature plus one-line doc and line number, nested by scope, skipping function bodies and nested inner functions.Trace references with
what_breaks(exact_symbol): structural lookup of a symbol object returned byfind_symbol, returning code references with surrounding context while excluding comments and string literals (name-based, not type-aware).Work across languages — Python, JavaScript, TypeScript and Go — with zero per-language setup, caching parsed results per file (mtime/size) and parallelising large repos.
Run anywhere MCP is supported (Claude Code, Claude Desktop, Cursor, VS Code) via the
xray-mcpcommand.
Note: the schema's what_breaks takes a whole symbol object (exact_symbol) rather than the README's name/path/line arguments, and find_symbol in the schema exposes no limit parameter.
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., "@XRAY MCP show me all functions that call validate_user in the current project"
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.
XRAY
An MCP server that lets coding agents see a codebase's shape — layout, signatures, definitions, references — without reading whole files.
Why
Coding agents already have grep, glob and file reads. Where they burn context is:
Reading a 1,500-line file to learn three function signatures.
read_interfacereturns the file's API — every class, method, function and type with its signature, one-line doc and line number — so the agent reads only the lines it needs.Grepping a name and wading through comments, strings and partial matches.
find_symbolreturns definitions only, ranked, fuzzy.what_breaksreturns identifier references with comments and string literals excluded.
grep / rg | XRAY | LSP | |
Setup | none |
| a server per language |
Finds definitions only | ✗ | ✓ | ✓ |
Skips comments & strings | ✗ | ✓ | ✓ |
File API without the bodies | ✗ | ✓ | partial (document symbols) |
Type-aware references | ✗ | ✗ (name-based) | ✓ |
XRAY sits between the two: syntax-aware via tree-sitter, zero per-language setup, and honest about not resolving types.
Related MCP server: mcp-codebase-intelligence
Install
uv tool install git+https://github.com/srijanshukla18/xrayThen register the xray-mcp command with your client.
Claude Code
claude mcp add xray -s user -- xray-mcpClaude Desktop, Cursor, VS Code, others — add to the client's MCP config:
{ "mcpServers": { "xray": { "command": "xray-mcp" } } }To run without installing: uvx --from git+https://github.com/srijanshukla18/xray xray-mcp.
There is also install.sh, which installs uv if needed and then runs the command above.
Tools
All paths in results are absolute. root_path is the project directory.
explore_repo(root_path, max_depth=None, include_symbols=False, focus_dirs=None, max_symbols_per_file=5)
Directory tree honouring .gitignore (via git ls-files, or a .gitignore parser outside git). Directories cut off by max_depth show their file count. Output is capped at 1,000 lines.
explore_repo("/home/me/xray", max_depth=2)
/home/me/xray/
├── src/
│ └── xray/ (6 files)
├── tests/
│ ├── __init__.py
│ └── test_xray.py
├── pyproject.toml
└── README.mdfocus_dirs takes paths relative to the root; with include_symbols=True each file lists its signatures:
explore_repo("/home/me/xray", focus_dirs=["src/xray/core"], include_symbols=True, max_symbols_per_file=3)
/home/me/xray/
└── src/
└── xray/
└── core/
├── files.py
│ ├── def list_files(root: Path) -> List[str] # Return POSIX paths, relative to root, of every non-ignored…
│ ├── def _in_excluded_dir(rel: str) -> bool
│ ├── def _git_files(root: Path) # Tracked + untracked-but-not-ignored files, or None if root isn't in…
│ └── ... and 1 more
...find_symbol(root_path, query, limit=10)
Fuzzy search over definitions. Case and separators are ignored ("user service" finds UserService), a Class.method query matches methods by their class, and an exact spelling wins ties.
find_symbol("/home/me/xray", "symbols for")
[{
"name": "symbols_for", "type": "method", "parent": "SymbolIndex",
"path": "/home/me/xray/src/xray/core/symbols.py", "start_line": 357, "end_line": 385,
"signature": "def symbols_for(self, rel_paths: List[str], prune: bool = False) -> Dict[str, List[dict]]"
}]read_interface(root_path, file_path)
A file's API, nested by scope, with line numbers. Functions defined inside other functions are left out — they're not part of the interface. Paths outside root_path are refused.
read_interface("/home/me/xray", "src/xray/core/indexer.py")
src/xray/core/indexer.py (13 symbols; left column is the line number)
17 def _norm(text: str) -> str
21 class XRayIndexer
22 def __init__(self, root_path: str)
28 def _rel(self, path: str) -> str # Resolve a user-supplied path to a POSIX path relative to root, refusing…
105 def find_symbol(self, query: str, limit: int = 10) -> List[Dict[str, Any]]
134 def read_interface(self, file_path: str) -> str
...what_breaks(root_path, name, path=None, line=None, limit=50)
Every identifier spelled exactly name, excluding comments, string literals and the definitions themselves (which are listed separately). Pass the path and line of the definition you mean, and XRAY warns when other definitions share the name.
what_breaks("/home/me/xray", "list_files", path="src/xray/core/files.py", line=18, limit=2)
{
"symbol": "list_files",
"total_references": 7,
"files": 2,
"references": [
{"file": "/home/me/xray/src/xray/core/indexer.py", "line": 9,
"text": "from xray.core.files import list_files\nfrom xray.core.symbols import ..."},
{"file": "/home/me/xray/src/xray/core/indexer.py", "line": 50,
"text": ") -> str:\n files = list_files(self.root_path)\n if focus_dirs:"}
],
"definitions": [{"path": "/home/me/xray/src/xray/core/files.py", "line": 18}],
"note": "Name-based: every identifier spelled exactly like this, excluding comments and strings. ...",
"truncated": "showing first 2 of 7; raise limit to see more"
}It is name-based, not type-aware. what_breaks("save") finds every .save in the repo, not just the one on your class. Use it as a precise grep, not as a compiler.
Languages
Language | Extensions | Extracted |
Python |
| functions, async functions, classes, methods; first line of docstrings |
JavaScript |
| functions, generators, classes, methods, |
TypeScript |
| JavaScript's set plus interfaces, type aliases, enums, namespaces, abstract classes |
Go |
| functions, methods, structs, interfaces, other type declarations |
For non-Python languages the doc is the first line of the // or /** */ comment directly above the definition.
How it works
Files:
git ls-files --cached --others --exclude-standard, so nested.gitignores, negations and global excludes all behave exactly as in git. Dependency and build directories (node_modules,vendor,.venv,dist, …) are always skipped.Parsing: ast-grep's Python binding (tree-sitter grammars). One pass per file extracts every definition;
explore_repo,find_symbolandread_interfaceall read that same data.Cache:
~/.cache/xray/<hash-of-root>.sqlite(honoursXDG_CACHE_HOME), one row per file keyed on mtime and size. Only changed files are re-parsed; the cache survives server restarts.Large repos: batches of 200+ files are spread over up to 8 worker processes.
Measured on a 21,000-file Go/TS repo (Apple M-series, 10 cores): first find_symbol 8 s (builds the cache), later calls ~1 s, what_breaks ~2 s.
Development
git clone https://github.com/srijanshukla18/xray && cd xray
uv sync
uv run pytesttest_samples/ holds one file per language; the tests assert exact names and line numbers against them, and drive the tools through a real MCP client.
Uninstall
uv tool uninstall xray && rm -rf ~/.cache/xrayor run uninstall.sh.
Design notes
Approaches tried before settling on this one:
grep — can't tell a definition from a comment or a string.
Raw tree-sitter bindings — grammar and binding build problems across platforms.
LSP — precise, but asks users to install and run a language server per language.
Comby — unstable for this workload.
ast-grep CLI — correct, but its JSON repeats each matched node's full text; on a 20k-file repo that was ~1 GB of output per index. The in-process binding gives the same parser without the serialisation.
Available Tools
4 toolsexplore_repoA
🗺️ STEP 1: Map the codebase structure - start simple, then zoom in!
PROGRESSIVE DISCOVERY WORKFLOW:
First call: explore_repo("/path/to/project") - See directory structure only
Zoom in: explore_repo("/path/to/project", focus_dirs=["src"], include_symbols=True)
Go deeper: explore_repo("/path/to/project", max_depth=3, include_symbols=True)
INPUTS:
root_path: The ABSOLUTE path to the project (e.g., "/Users/john/myproject") NOT relative paths like "./myproject" or "~/myproject"
max_depth: How deep to traverse directories (None = unlimited, accepts int or string)
include_symbols: Show function/class signatures with docs (False = dirs only, accepts bool or string)
focus_dirs: List of top-level directories to focus on (e.g., ["src", "lib"])
max_symbols_per_file: Max symbols to show per file when include_symbols=True (accepts int or string)
EXAMPLE 1 - Initial exploration (directory only): explore_repo("/Users/john/project")
Returns:
/Users/john/project/
├── src/
├── tests/
├── docs/
└── README.md
EXAMPLE 2 - Zoom into src/ with symbols: explore_repo("/Users/john/project", focus_dirs=["src"], include_symbols=True)
Returns:
/Users/john/project/
└── src/
├── auth.py
│ ├── class AuthService: # Handles user authentication
│ ├── def authenticate(username, password): # Validates credentials
│ └── def logout(session_id): # Ends user session
└── models.py
├── class User(BaseModel): # User account model
└── ... and 3 more
EXAMPLE 3 - Limited depth exploration: explore_repo("/Users/john/project", max_depth=1, include_symbols=True)
Shows only top-level dirs and files with their symbols
💡 PRO TIP: Start with include_symbols=False to see structure, then set it to True for areas you want to examine in detail. This prevents information overload!
⚡ PERFORMANCE: Symbol extraction is cached per git commit - subsequent calls are instant!
WHAT TO DO NEXT:
If you found interesting directories, zoom in with focus_dirs
If you see relevant files, use find_symbol() to locate specific functions
Inputs: root_path (required), max_depth, include_symbols, focus_dirs, +1 more. Returns: result
find_symbolA
🔍 STEP 2: Find specific functions, classes, or methods in the codebase.
USE THIS AFTER explore_repo() when you need to locate a specific piece of code. Uses fuzzy matching - you don't need the exact name!
INPUTS:
root_path: Same ABSOLUTE path used in explore_repo
query: What you're looking for (fuzzy search works!) Examples: "auth", "user service", "validate", "parseJSON"
EXAMPLE INPUTS: find_symbol("/Users/john/awesome-project", "authenticate") find_symbol("/Users/john/awesome-project", "user model") # Fuzzy matches "UserModel"
EXAMPLE OUTPUT: [ { "name": "authenticate_user", "type": "function", "path": "/Users/john/awesome-project/src/auth.py", "start_line": 45, "end_line": 67 }, { "name": "AuthService", "type": "class", "path": "/Users/john/awesome-project/src/services.py", "start_line": 12, "end_line": 89 } ]
RETURNS: List of symbol objects (dictionaries). Save these objects - you'll pass them to what_breaks()! Empty list if no matches found.
WHAT TO DO NEXT: Pick a symbol from the results and pass THE ENTIRE SYMBOL OBJECT to what_breaks() to see where it's used in the codebase.
Inputs: root_path (required), query (required). Returns: result
read_interfaceA
📖 READ INTERFACE: Get a high-level overview of a file without reading implementation.
Returns function signatures, class definitions, and docstrings. Perfect for understanding how to USE a module without reading the whole thing.
INPUTS:
root_path: The ABSOLUTE path to the project root
file_path: The path to the specific file you want to read (can be relative to root)
EXAMPLE: read_interface("/Users/john/project", "src/auth.py")
Inputs: root_path (required), file_path (required). Returns: result
what_breaksA
💥 STEP 3: See what code might break if you change this symbol.
USE THIS AFTER find_symbol() to understand the impact of changing a function/class.
IMPROVEMENTS:
Uses structural search (ast-grep) to find ACTUAL code references (ignoring comments/strings).
Returns 2 lines of context around each match.
INPUT:
exact_symbol: Pass THE ENTIRE SYMBOL OBJECT from find_symbol(), not just the name! Must be a dictionary with AT LEAST 'name' and 'path' keys.
EXAMPLE INPUT:
First, get a symbol from find_symbol():
symbols = find_symbol("/Users/john/project", "authenticate") symbol = symbols[0] # Pick the first result
Then pass THE WHOLE SYMBOL OBJECT:
what_breaks(symbol)
EXAMPLE OUTPUT: { "references": [ { "file": "/Users/john/project/src/api.py", "line": 23, "text": " # Authenticate the user user = authenticate_user(username, password) if not user:", "type": "code" } ], "total_count": 1, "strategy": "structural", "note": "Found 1 references using structural search." }
Inputs: exact_symbol (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct, non-overlapping purpose in the code exploration workflow: explore_repo maps structure, find_symbol locates specific symbols, read_interface provides file overviews, and what_breaks analyzes dependencies. The tools are clearly sequenced and complementary, with no ambiguity in their roles.
Three tools use snake_case with descriptive verbs (explore_repo, find_symbol, read_interface), while what_breaks uses snake_case but with a less conventional verb phrase. The naming is mostly consistent and readable, with only minor deviation in style for what_breaks.
Four tools is well-scoped for a code exploration server, covering the essential workflow from mapping structure to analyzing impacts. Each tool earns its place without redundancy, and the count aligns with the progressive discovery approach described.
The tool set provides complete coverage for codebase exploration: explore_repo for initial mapping, find_symbol for searching, read_interface for understanding files, and what_breaks for impact analysis. There are no obvious gaps, and the tools support a full workflow from discovery to dependency checking.
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides AI assistants with progressive code intelligence to explore repository structure, find symbols, and assess the impact of changes using ast-grep.3MIT
- AlicenseNot gradedqualityDmaintenanceProvides a semantic understanding of your codebase by parsing with tree-sitter and building a graph of symbols and dependencies. Enables AI assistants to navigate code, analyze changes, and discover architecture using 18 tools with minimal context overhead.16 npm1MIT
- FlicenseNot gradedqualityBmaintenanceProvides efficient code navigation and graph-based analysis for AI agents, enabling symbol resolution, callers, implementations, and type schemas with minimal token usage.-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to semantically navigate codebases via an AST index, supporting symbol search, usage lookup, module exploration, and dependency analysis.MIT