🚀 XRAY MCP - Progressive Code Intelligence for AI Assistants
XRAY MCP offers progressive code intelligence for AI assistants, enabling them to better understand codebases and provide more accurate analysis and suggestions.

❌ Without XRAY
AI assistants face difficulties in understanding codebases. You may encounter the following issues:
- ❌ "I can't see your code structure"
- ❌ "I don't know what depends on this function"
- ❌ Generic refactoring advice without impact analysis
- ❌ No understanding of symbol relationships
✅ With XRAY
XRAY equips AI assistants with code navigation capabilities. Simply add use XRAY tools to your prompt:
Analyze the UserService class and show me what would break if I change the authenticate method. use XRAY tools
Find all functions that call validate_user and show their dependencies. use XRAY tools
XRAY provides three focused tools:
- 🗺️ Map (
explore_repo) - Visualize the project structure with symbol skeletons
- 🔍 Find (
find_symbol) - Locate functions and classes using fuzzy search
- 💥 Impact (
what_breaks) - Identify where a symbol is referenced
🚀 Quick Start
📦 Installation
Modern Install with uv (Recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/srijanshukla18/xray.git
cd xray
uv tool install .
Automated Install with uv
For the quickest setup, use this script to automate the uv installation process:
curl -fsSL https://raw.githubusercontent.com/srijanshukla18/xray/main/install.sh | bash
Generate Config
python mcp-config-generator.py cursor local_python
python mcp-config-generator.py claude docker
python mcp-config-generator.py vscode source
💻 Usage Examples
1. Map - Start Simple, Then Zoom In
tree = explore_repo("/path/to/project")
tree = explore_repo("/path/to/project", focus_dirs=["src"], include_symbols=True)
tree = explore_repo("/path/to/project", max_depth=2, include_symbols=True)
2. Find - Locate Specific Symbols
symbols = find_symbol("/path/to/project", "authenticate")
3. Impact - See What Would Break
symbol = symbols[0]
result = what_breaks(symbol)
📚 Documentation
Language Support
XRAY uses ast-grep, a tree-sitter powered structural search tool, providing accurate parsing for:
- Python - Functions, classes, methods, async functions
- JavaScript - Functions, classes, arrow functions, imports
- TypeScript - All JavaScript features plus interfaces, type aliases
- Go - Functions, structs, interfaces, methods
ast-grep ensures structural accuracy - it understands code syntax, not just text patterns.
Architecture
FastMCP Server (mcp_server.py)
↓
Core Engine (src/xray/core/)
└── indexer.py # Orchestrates ast-grep for structural analysis
↓
ast-grep (external binary)
└── Tree-sitter powered structural search
Stateless design - No database, no persistent index. Each operation runs fresh ast-grep queries for real-time accuracy.
Why ast-grep?
Traditional grep searches text, while ast-grep searches code structure:
- grep: Finds "authenticate" in function names, variables, comments, strings
- ast-grep: Finds only
def authenticate() or function authenticate() definitions
This structural approach provides clean, accurate results essential for reliable code intelligence.
Performance Characteristics
- Startup: Fast - launches ast-grep subprocess
- File tree: Python directory traversal
- Symbol search: Runs multiple ast-grep patterns, speed depends on codebase size
- Impact analysis: Name-based search across all files
- Memory: Minimal - no persistent state
What Makes This Practical
- Progressive Discovery - Start with directories, add symbols only where needed
- Smart Caching - Symbol extraction cached per git commit for instant re-runs
- Flexible Focus - Use
focus_dirs to zoom into specific parts of large codebases
- Enhanced Symbols - See function signatures and docstrings, not just names
- Based on tree-sitter - ast-grep provides accurate structural analysis
Getting Started with XRAY - Modern Installation with uv
XRAY is a minimal-dependency code intelligence system that enhances AI assistants' understanding of codebases. This guide shows how to install and use XRAY with the modern uv package manager.
Prerequisites
- Python 3.10 or later
- uv - Fast Python package manager
Installing uv
curl -LsSf https://astral.sh/uv/install.sh | sh
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
pip install uv
Installation Options
Option 1: Automated Install (Easiest)
curl -fsSL https://raw.githubusercontent.com/srijanshukla18/xray/main/install.sh | bash
Option 2: Quick Try with uvx (Recommended for Testing)
git clone https://github.com/srijanshukla18/xray.git
cd xray
uvx --from . xray-mcp
Option 3: Install as a Tool (Recommended for Regular Use)
git clone https://github.com/srijanshukla18/xray.git
cd xray
uv tool install .
xray-mcp
Option 4: Development Installation
git clone https://github.com/srijanshukla18/xray.git
cd xray
uv venv
source .venv/bin/activate
uv pip install -e .
python -m xray.mcp_server
Configure Your AI Assistant
Using the MCP Config Generator (Recommended)
cd /path/to/xray
python mcp-config-generator.py claude installed_script
python mcp-config-generator.py vscode local_python
Available tools: cursor, claude, vscode
Available methods: local_python, docker, source, installed_script (method availability varies by tool)
Manual Configuration (Advanced)
Claude CLI (Claude Code)
claude mcp add xray xray-mcp -s local
claude mcp list | grep xray
Claude Desktop
{
"mcpServers": {
"xray": {
"command": "uvx",
"args": ["--from", "/path/to/xray", "xray-mcp"]
}
}
}
Or if installed as a tool:
{
"mcpServers": {
"xray": {
"command": "xray-mcp"
}
}
}
Cursor
Settings → Cursor Settings → MCP → Add new global MCP server:
{
"mcpServers": {
"xray": {
"command": "xray-mcp"
}
}
}
Minimal Dependencies
XRAY uses:
- ast-grep: A single, fast binary for structural code analysis.
- Python: For the server and core logic.
Verify Installation
1. Check XRAY is accessible
xray-mcp --version
uvx --from /path/to/xray xray-mcp --version
2. Test basic functionality
def hello_world():
print("Hello from XRAY test!")
def calculate_sum(a, b):
return a + b
class Calculator:
def multiply(self, x, y):
return x * y
3. In your AI assistant, test these commands
Build the index for the current directory. use XRAY tools
Find all functions containing "hello". use XRAY tools
What would break if I change the multiply method? use XRAY tools
Usage Examples
# Index a codebase
"Index the src/ directory for analysis. use XRAY tools"
# Find symbols
"Find all classes that contain 'User' in their name. use XRAY tools"
# Impact analysis
"What breaks if I change the authenticate method in UserService? use XRAY tools"
# Dependency tracking
"What does the PaymentProcessor class depend on? use XRAY tools"
# Location queries
"What function is defined at line 125 in main.py? use XRAY tools"
Troubleshooting
uv not found
export PATH="$HOME/.cargo/bin:$PATH"
Permission denied
chmod +x ~/.local/bin/xray-mcp
Python version issues
python --version
uv python install 3.10
MCP connection issues
- Check XRAY is running:
xray-mcp --test
- Verify your MCP config JSON is valid
- Restart your AI assistant after config changes
Advanced Configuration
Custom Database Location
export XRAY_DB_PATH="$HOME/.xray/databases"
Debug Mode
export XRAY_DEBUG=1
What's Next?
- Index your first repository: "Build the index for my project. use XRAY tools"
- Explore the tools:
build_index - Visual file tree of your repository
find_symbol - Fuzzy search for functions, classes, and methods
what_breaks - Find what code depends on a symbol (reverse dependencies)
what_depends - Find what a symbol depends on (calls and imports)
- Read the documentation: README
Why XRAY Uses a Minimal Dependency Approach
XRAY relies on:
- ast-grep: A powerful and fast single-binary tool for code analysis.
- Python: For its robust standard library and ease of scripting.
Benefits of Using uv
- 10-100x faster than pip for installations
- No virtual environment hassles - uv manages everything
- Reproducible installs - uv.lock ensures consistency
- Built-in Python management - install any Python version
- Global tool management - like pipx but faster
Happy coding with XRAY! 🚀