Xcode MCP Server

by R.Huijts

157 stars
1 downloads
Not rated
GitHub

About

Bridges Claude AI with Xcode, enabling AI-powered code assistance, project management, and automated development tasks securely on your local machine.

Details

Author
R.Huijts
Repository
r-huijts/xcode-mcp-server
GitHub stars
157
Downloads
1
License
MIT License
Categories
Developer Tools, AI, Other

- Path Validation: All file operations are restricted to allowed directories.
- Error Handling: Detailed error messages help diagnose issues.
- Parameter Validation: Input parameters are validated using Zod schemas.
- Process Management: External processes are executed safely with proper error handling.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Xcode MCP Server
    Command (node, npx, python, etc.) node
    Arguments
    • Argument 1 /path/to/xcode-mcp-server/dist/index.js

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Use the included setup script which automates the installation and configuration process:


./setup.sh

What the Setup Script Does:

1. Environment Verification:
- Checks that you're running on macOS
- Verifies Xcode is installed and accessible
- Confirms Node.js (v16+) and npm are available
- Checks for Ruby installation
- Verifies CocoaPods installation (offers to install if missing)

2. Dependency Installation:
- Runs npm install to install all required Node.js packages
- Executes npm run build to compile the TypeScript code

3. Configuration Setup:
- Creates a .env file if one doesn't exist
- Prompts for your projects base directory
- Asks if you want to enable debug logging
- Saves your configuration preferences

4. Claude Desktop Integration (Optional):
- Offers to configure the server for Claude Desktop
- Creates or updates the Claude Desktop configuration file
- Sets up the proper command and arguments to launch the server

When to Use the Setup Script:

- First-time installation to ensure all prerequisites are met
- When you want guided configuration with interactive prompts
- If you want to quickly set up Claude Desktop integration
- To verify your environment has all necessary components

The script will guide you through the configuration process with clear prompts and helpful feedback.

When to Use Manual Setup:

- You prefer explicit control over each installation step
- You have a custom environment or non-standard configuration
- You're setting up in a CI/CD pipeline or automated environment
- You want to customize specific aspects of the installation process
- You're an experienced developer familiar with Node.js projects

Follow these steps for manual installation:

1. Clone the repository:

   git clone https://github.com/r-huijts/xcode-mcp-server.git
cd xcode-mcp-server

2. Verify prerequisites (these must be installed):
- Xcode and Xcode Command Line Tools
- Node.js v16 or higher
- npm
- Ruby (for CocoaPods support)
- CocoaPods (optional, for pod-related features)

3. Install dependencies:

   npm install

4. Build the project:

   npm run build

5. Create a configuration file:


cp .env.example .env

echo "PROJECTS_BASE_DIR=/path/to/your/projects" > .env
echo "DEBUG=false" >> .env

Edit the .env file to set your preferred configuration.

6. For Claude Desktop integration (optional):
- Edit or create ~/Library/Application Support/Claude/claude_desktop_config.json
- Add the following configuration (adjust paths as needed):

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

Common Setup Issues:

1. Build Errors:
- Ensure you have the correct Node.js version (v16+)
- Try deleting node_modules and running npm install again
- Check for TypeScript errors with npx tsc --noEmit
- Make sure all imports in the code are properly resolved

2. Missing Dependencies:
- If you see errors about missing modules, run npm install again
- For native dependencies, you may need Xcode Command Line Tools: xcode-select --install

3. Permission Issues:
- Ensure you have write permissions to the installation directory
- For CocoaPods installation, you may need to use sudo gem install cocoapods

4. Configuration Problems:
- Verify your .env file has the correct format and valid paths
- Make sure PROJECTS_BASE_DIR points to an existing directory
- Check that the path doesn't contain special characters that need escaping

5. Claude Desktop Integration:
- Ensure the path in the Claude configuration points to the correct location of index.js
- Restart Claude Desktop after making configuration changes
- Check that the server is running before attempting to use it with Claude

You can configure the server in two ways:

1. Environment variables in .env file:

   PROJECTS_BASE_DIR=/path/to/your/projects
DEBUG=true
ALLOWED_PATHS=/path/to/additional/allowed/directory
PORT=8080

2. Command line arguments:

   npm start -- --projects-dir=/path/to/your/projects --port=8080

- PROJECTS_BASE_DIR / --projects-dir: Base directory for projects (required)
- ALLOWED_PATHS / --allowed-paths: Additional directories to allow access to (comma-separated)
- PORT / --port: Port to run the server on (default: 3000)
- DEBUG / --debug: Enable debug logging (default: false)
- LOG_LEVEL / --log-level: Set logging level (default: info)

set_active_project

Set the active project for the server. Parameters: projectPath (string)

get_project_info

Retrieve detailed information about the specified project. Parameters: projectPath (string)

create_xcode_project

Create a new Xcode project from a template. Parameters: name (string), template (string), outputDirectory (string), organizationName (string), organizationIdentifier (string), language (string), includeTests (boolean), setAsActive (boolean)

add_file_to_project

Add files to Xcode projects with specified target and group. Parameters: projectPath (string), filePath (string), target (string), group (string)

parse_workspace

Parse workspace documents to find associated projects. Parameters: workspacePath (string)

list_schemes

List available schemes in the specified project or workspace. Parameters: projectPath (string)

read_file

Read a file with a specific encoding. Parameters: filePath (string), encoding (string)

write_file

Write content to a file, creating it if it does not exist. Parameters: path (string), content (string), createIfMissing (boolean)

search_in_files

Search for text content within files using a specific pattern. Parameters: directory (string), pattern (string), searchText (string), isRegex (boolean)

check_file_exists

Check if a file exists at the specified path. Parameters: filePath (string)

get_file_metadata

Get metadata about a specified file. Parameters: filePath (string)

clean_build_directories

Clean up build directories to free space. Parameters: projectPath (string)

archive_project

Archive the specified project for distribution. Parameters: projectPath (string)

install_cocoapods

Initialize CocoaPods in the specified project. Parameters: projectPath (string)

update_cocoapods

Update installed CocoaPods for the specified project. Parameters: projectPath (string)

add_pod_dependency

Add a new pod dependency to the project. Parameters: projectPath (string), podName (string), version (string)

initialize_swift_package

Initialize a new Swift package. Parameters: packageName (string), outputDirectory (string)

add_swift_package_dependency

Add a Swift package dependency with specific version requirements. Parameters: url (string), version (string)

boot_simulator

Boot the specified iOS simulator. Parameters: simulatorId (string)

shut_down_simulator

Shut down the specified iOS simulator. Parameters: simulatorId (string)

install_app_on_simulator

Install an app on the specified iOS simulator. Parameters: simulatorId (string), appPath (string)

take_screenshot

Take a screenshot of the specified simulator's screen. Parameters: simulatorId (string), outputPath (string)

record_video

Record a video of the specified simulator's activity. Parameters: simulatorId (string), outputPath (string)

execute_xcode_command

Execute a command via xcrun. Parameters: command (string), args (array)

generate_app_icon_set

Generate app icon sets from source images. Parameters: sourceImagesPath (string), outputPath (string)

export_archive

Export and validate archives for App Store submission. Parameters: archivePath (string), outputPath (string)

switch_xcode_version

Switch between different installed versions of Xcode. Parameters: version (string)

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "xcode mcp server": {
            "cwd": "optional",
            "env": {},
            "args": [
                "/path/to/xcode-mcp-server/dist/index.js"
            ],
            "shell": false,
            "command": "node"
        }
    }
}

Linux

{
    "cwd": "optional",
    "env": [],
    "args": [
        "/path/to/xcode-mcp-server/dist/index.js"
    ],
    "shell": false,
    "command": "node"
}

Macos

{
    "cwd": "optional",
    "env": [],
    "args": [
        "/path/to/xcode-mcp-server/dist/index.js"
    ],
    "shell": false,
    "command": "node"
}

Windows

{
    "cwd": "optional",
    "env": [],
    "args": [
        "/c",
        "node",
        "/path/to/xcode-mcp-server/dist/index.js"
    ],
    "shell": false,
    "command": "cmd"
}

Xcode MCP Server

An MCP (Model Context Protocol) server providing comprehensive Xcode integration for AI assistants. This server enables AI agents to interact with Xcode projects, manage iOS simulators, and perform various Xcode-related tasks with enhanced error handling and support for multiple project types.

Features

Project Management

- Set active projects and get detailed project information - Create new Xcode projects from templates (iOS, macOS, watchOS, tvOS) - Add files to Xcode projects with target and group specification - Parse workspace documents to find associated projects - List available schemes in projects and workspaces

File Operations

- Read/write files with support for different encodings - Handle binary files with base64 encoding/decoding - Search for text content within files using patterns and regex - Check file existence and get file metadata - Create directory structures automatically

Build & Testing

- Build projects with customizable options - Run tests with detailed failure reporting - Analyze code for potential issues - Clean build directories - Archive projects for distribution

CocoaPods Integration

- Initialize CocoaPods in projects - Install and update pods - Add and remove pod dependencies - Execute arbitrary pod commands

Swift Package Manager

- Initialize new Swift packages - Add and remove package dependencies with various version requirements - Update packages and resolve dependencies - Generate documentation for Swift packages using DocC - Run tests and build Swift packages

iOS Simulator Tools

- List available simulators with detailed information - Boot and shut down simulators - Install and launch apps on simulators - Take screenshots and record videos - Manage simulator settings and state

Xcode Utilities

- Execute Xcode commands via xcrun - Compile asset catalogs - Generate app icon sets from source images - Trace app performance - Export and validate archives for App Store submission - Switch between different Xcode versions

Installation

Prerequisites

- macOS with Xcode 14.0 or higher installed
- Node.js 16 or higher
- npm or yarn
- Swift 5.5+ for Swift Package Manager features
- CocoaPods (optional, for CocoaPods integration)

Setup

Option 1: Automated Setup (Recommended)

Use the included setup script which automates the installation and configuration process:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.