XRAY is a powerful code intelligence tool for AI assistants that enables them to understand, navigate, and analyze codebases. By providing structure-aware code navigation capabilities, XRAY helps AI assistants move beyond simple text searches to understand symbol relationships and code dependencies.
curl -fsSL https://raw.githubusercontent.com/srijanshukla18/xray/main/install.sh | bash
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and install XRAY
git clone https://github.com/srijanshukla18/xray.git
cd xray
uv tool install .
# Clone the repository
git clone https://github.com/srijanshukla18/xray.git
cd xray
# Run XRAY directly with uvx
uvx --from . xray-mcp
Use the provided configuration generator script:
# Generate config for your specific tool
python mcp-config-generator.py cursor local_python
python mcp-config-generator.py claude docker
python mcp-config-generator.py vscode source
claude mcp add xray xray-mcp -s local
claude mcp list | grep xray
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"xray": {
"command": "xray-mcp"
}
}
}
Settings → Cursor Settings → MCP → Add new global MCP server:
{
"mcpServers": {
"xray": {
"command": "xray-mcp"
}
}
}
XRAY provides three main tools that follow a progressive discovery workflow:
# Get directory structure overview
tree = explore_repo("/path/to/project")
# Zoom into specific directories with symbol details
tree = explore_repo("/path/to/project", focus_dirs=["src"], include_symbols=True)
# Limit depth for large codebases
tree = explore_repo("/path/to/project", max_depth=2, include_symbols=True)
# Find symbols matching "authenticate" (fuzzy search)
symbols = find_symbol("/path/to/project", "authenticate")
# Returns list of exact symbol objects with name, type, path, line numbers
# Find where a symbol is used
symbol = symbols[0] # From find_symbol
result = what_breaks(symbol)
# Returns information about references to the symbol
Use XRAY by adding "use XRAY tools" to your prompts:
"Index the src/ directory for analysis. use XRAY tools"
"Find all classes that contain 'User' in their name. use XRAY tools"
"What breaks if I change the authenticate method in UserService? use XRAY tools"
"What does the PaymentProcessor class depend on? use XRAY tools"
XRAY uses ast-grep for structural code analysis and supports:
# If installed as tool
xray-mcp --version
# If using uvx
uvx --from /path/to/xray xray-mcp --version
export PATH="$HOME/.cargo/bin:$PATH" to your shell profilechmod +x ~/.local/bin/xray-mcppython --versionxray-mcp --test and verify your configuration# Custom database location
export XRAY_DB_PATH="$HOME/.xray/databases"
# Enable debug logging
export XRAY_DEBUG=1
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "xray" '{"command":"xray-mcp"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"xray": {
"command": "xray-mcp"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"xray": {
"command": "xray-mcp"
}
}
}
3. Restart Claude Desktop for the changes to take effect