The Xcode MCP Server provides a Model Context Protocol interface that allows AI assistants to directly interact with Xcode projects. With this tool, you can trigger builds, run tests, view logs, and access detailed reports without leaving your LLM application.
Start by cloning the repository and installing the necessary dependencies:
# Clone the repository
git clone https://github.com/PolarVista/Xcode-mcp-server.git
cd xcode-mcp-server
# Install dependencies
npm install
# Build the server
npm run build
To start the server, use the following command:
npm run start /path/to/build/logs/directory
Replace /path/to/build/logs/directory
with the directory where you want build and test logs to be stored.
To connect Claude Desktop to the Xcode MCP Server, add the following configuration to your Claude Desktop settings:
"xcode-build": {
"command": "node",
"args": ["/path/to/the/xcode-mcp-server/build/index.js",
"/path/to/your/project/folder"],
"env": {
"PATH": "/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin"
}
}
Make sure to replace the paths with the actual locations on your system.
The build_project
tool allows you to build Xcode projects with customized parameters.
Parameters:
projectPath
(required): Path to the .xcodeproj or .xcworkspacescheme
(required): Build scheme nameconfiguration
(optional): Build configuration (Debug/Release, defaults to Debug)destination
(optional): Build destination (defaults to "platform=iOS Simulator,name=iPhone 15 Pro")Example:
build_project({
projectPath: "/path/to/Project.xcodeproj",
scheme: "MyApp",
configuration: "Debug"
})
The run_tests
tool executes unit tests with options for filtering specific tests.
Parameters:
projectPath
(required): Path to the .xcodeproj or .xcworkspacescheme
(required): Test scheme nametestIdentifier
(optional): Specific test to run (e.g., 'MyTests/testExample')skipTests
(optional): Array of test identifiers to skipconfiguration
(optional): Build configuration (Debug/Release, defaults to Debug)destination
(optional): Test destination (defaults to "platform=iOS Simulator,name=iPhone 15 Pro")Example:
run_tests({
projectPath: "/path/to/Project.xcodeproj",
scheme: "MyAppTests",
testIdentifier: "LoginTests/testSuccessfulLogin",
skipTests: ["PerformanceTests/testLargeDataLoad"],
configuration: "Debug"
})
All logs are automatically stored in the directory you specified when starting the server. The system organizes logs as follows:
build-[timestamp].log
build-[timestamp].log.json
report-[timestamp].txt
test-[timestamp].log
test-[timestamp].log.json
test-report-[timestamp].txt
coverage-[timestamp].txt
You can access the latest log (whether build or test) through the special resource identifier:
xcode-build://latest-log
This allows you to quickly check the most recent operation without knowing the exact timestamp.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "xcode-build" '{"command":"node","args":["/path/to/the/xcode-mcp-server/build/index.js","/path/to/your/project/folder"],"env":{"PATH":"/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin"}}'
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-build": {
"command": "node",
"args": [
"/path/to/the/xcode-mcp-server/build/index.js",
"/path/to/your/project/folder"
],
"env": {
"PATH": "/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin"
}
}
}
}
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-build": {
"command": "node",
"args": [
"/path/to/the/xcode-mcp-server/build/index.js",
"/path/to/your/project/folder"
],
"env": {
"PATH": "/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect