Xcode Index MCP allows AI assistants like Goose or Cursor to access your iOS/macOS project index through the Model Control Protocol. This powerful integration provides comprehensive listings of function call sites, making it invaluable for refactoring tasks and navigating through your codebase.
Follow these steps to set up the Xcode Index MCP server:
uv
)uv
(Python package manager) and synchronize dependencies:brew install uv
cd /path/to/this/repo
uv sync
cd swift-service
swift build
This step is essential as it builds the interface that communicates with Xcode's index.
uv run /Users/<USERNAME>/Development/xcode-index-mcp/.venv/bin/xcode-index-mcp
Replace <USERNAME>
with your actual system username.
Settings > MCP > Add new global MCP server
{
"mcpServers": {
"Xcode Index MCP": {
"command": "uv",
"args": ["run", "/Users/<USERNAME>/Development/xcode-index-mcp/.venv/bin/xcode-index-mcp"]
}
}
}
Replace <USERNAME>
with your actual system username.
Add instructions to your project's configuration file to tell your AI assistant how to use the plugin:
Add to your .gooseHints
file:
Use tool `xcode-index-mcp` if available. Use project name <Your project name here>. The tool can locate call sites of functions, and function definitions from call sites. If you need a filepath to make a request, use `rg` to find the file and `rg -n` to find the line number. Use the absolute path when requesting symbols from a file.
Add similar instructions to your cursorRules
file, specifying your project name as it appears in the derived data folder.
You can ask your AI assistant to perform tasks like:
"Remove myParameter
from the initializer on line 48 of MyViewController.swift
. Use the Xcode Index MCP to ensure all references are updated."
The plugin will help identify all call sites that need to be updated when making such changes.
The tool operates through two main components:
When you request to load an index, the Swift service searches Xcode's derived data directory for your project and loads its index. This allows queries to be passed from the MCP server to the index through methods provided by IndexStoreDB.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "Xcode-Index-MCP" '{"command":"uv","args":["run","/Users/<USERNAME>/Development/xcode-index-mcp/.venv/bin/xcode-index-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": {
"Xcode Index MCP": {
"command": "uv",
"args": [
"run",
"/Users/<USERNAME>/Development/xcode-index-mcp/.venv/bin/xcode-index-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.json
2. Add this to your configuration file:
{
"mcpServers": {
"Xcode Index MCP": {
"command": "uv",
"args": [
"run",
"/Users/<USERNAME>/Development/xcode-index-mcp/.venv/bin/xcode-index-mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect