Skip to main content
Glama
README.md
# xcode-mcp

An MCP (Model Context Protocol) server for Xcode and iOS development automation. Build projects, manage simulators, and add Swift package dependencies programmatically.

## Features

- **Build Xcode Projects** - Build `.xcodeproj` or `.xcworkspace` with custom schemes and configurations
- **Manage Simulators** - List available iOS simulators and run apps on them
- **Add Swift Packages** - Programmatically add Swift Package Manager dependencies to projects
- **List Schemes** - Discover available build schemes in a project

## Requirements

- macOS with Xcode installed
- Node.js 18 or later
- Xcode Command Line Tools (`xcode-select --install`)

## Installation

```bash
git clone https://github.com/jfuginay/xcode-mcp.git
cd xcode-mcp
npm install
```

## Configuration

### Claude Desktop

Add to your `claude_desktop_config.json` (update the path to where you cloned the repo):

```json
{
  "mcpServers": {
    "xcode": {
      "command": "node",
      "args": ["/path/to/xcode-mcp/index.js"]
    }
  }
}
```

### Config file locations

- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

## Tools

### build_project

Build an Xcode project or workspace.

**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectPath` | string | Yes | Path to `.xcodeproj`, `.xcworkspace`, or directory containing one |
| `scheme` | string | No | Build scheme name |
| `configuration` | string | No | Build configuration (`Debug` or `Release`) |
| `destination` | string | No | Build destination (defaults to first available iPhone simulator) |

**Example:**
```json
{
  "projectPath": "/path/to/MyApp",
  "scheme": "MyApp",
  "configuration": "Debug"
}
```

### list_simulators

List all available iOS simulators.

**Parameters:** None

**Returns:**
```json
{
  "devices": [
    {
      "name": "iPhone 15",
      "udid": "...",
      "state": "Shutdown",
      "runtime": "iOS-17-0"
    }
  ]
}
```

### list_schemes

List available schemes in an Xcode project.

**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectPath` | string | Yes | Path to project or directory |

### run_on_simulator

Build and run a project on an iOS simulator.

**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectPath` | string | Yes | Path to project or directory |
| `scheme` | string | No | Build scheme name |
| `simulatorName` | string | No | Simulator name (defaults to first available iPhone) |

### add_swift_package

Add a Swift Package Manager dependency to an Xcode project.

**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectPath` | string | Yes | Path to `.xcodeproj` or directory |
| `packageUrl` | string | Yes | Git URL of the Swift package |
| `packageName` | string | Yes | Name of the package |
| `version` | string | No | Minimum version (default: `2.0.0`) |
| `productNames` | string[] | No | Product names to add (default: `[packageName]`) |

**Example:**
```json
{
  "projectPath": "/path/to/MyApp.xcodeproj",
  "packageUrl": "https://github.com/Alamofire/Alamofire",
  "packageName": "Alamofire",
  "version": "5.0.0"
}
```

## Development

### Running locally

```bash
npm start
```

### Testing with MCP Inspector

```bash
npx @modelcontextprotocol/inspector node index.js
```

## Contributing

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

## License

MIT - see [LICENSE](LICENSE) for details.