Xcode MCP server

Integrates with Xcode to automate iOS development workflows including building projects, running tests, and analyzing results.
Back to servers
Setup instructions
Provider
PolarVista
Release date
Dec 03, 2024
Language
TypeScript
Stats
41 stars

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.

Requirements

  • Node.js 16+
  • Xcode Command Line Tools
  • TypeScript
  • MCP-compatible client (e.g., Claude Desktop)

Installation

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

Setting Up

Starting the Server

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.

Configuring Claude Desktop

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.

Available Tools

Building Projects

The build_project tool allows you to build Xcode projects with customized parameters.

Parameters:

  • projectPath (required): Path to the .xcodeproj or .xcworkspace
  • scheme (required): Build scheme name
  • configuration (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"
})

Running Tests

The run_tests tool executes unit tests with options for filtering specific tests.

Parameters:

  • projectPath (required): Path to the .xcodeproj or .xcworkspace
  • scheme (required): Test scheme name
  • testIdentifier (optional): Specific test to run (e.g., 'MyTests/testExample')
  • skipTests (optional): Array of test identifiers to skip
  • configuration (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"
})

Accessing Logs

All logs are automatically stored in the directory you specified when starting the server. The system organizes logs as follows:

Build Logs

  • Plain text log: build-[timestamp].log
  • JSON-formatted log: build-[timestamp].log.json
  • Xcode report: report-[timestamp].txt

Test Logs

  • Test log: test-[timestamp].log
  • JSON-formatted log: test-[timestamp].log.json
  • Test report: test-report-[timestamp].txt
  • Code coverage report: 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.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later