Skip to main content
Glama

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

Related MCP server: xcode-mcp-server (drewster99)

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

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

# Make the script executable
chmod +x setup.sh

# Run the setup script
./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.

Option 2: Manual Setup

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:

    # Option A: Start with the example configuration
    cp .env.example .env
    
    # Option B: Create a minimal configuration
    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"]
        }
      }
    }

Setup Troubleshooting

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

Usage

Starting the Server

npm start

For development mode with automatic restarts:

npm run dev

Configuration Options

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

Key Configuration Parameters

  • 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)

Connecting to AI Assistants

The server implements the Model Context Protocol (MCP), making it compatible with various AI assistants that support this protocol. To connect:

  1. Start the Xcode MCP server

  2. Configure your AI assistant to use the server URL (typically http://localhost:3000)

  3. The AI assistant will now have access to all the Xcode tools provided by the server

Tool Documentation

For a comprehensive overview of all available tools and their usage, see Tools Overview.

For detailed usage examples and best practices, see User Guide.

Common Workflows

Setting Up a New Project

// Create a new iOS app project
await tools.create_xcode_project({
  name: "MyAwesomeApp",
  template: "ios-app",
  outputDirectory: "~/Projects",
  organizationName: "My Organization",
  organizationIdentifier: "com.myorganization",
  language: "swift",
  includeTests: true,
  setAsActive: true
});

// Add a Swift Package dependency
await tools.add_swift_package({
  url: "https://github.com/Alamofire/Alamofire.git",
  version: "from: 5.0.0"
});

Working with Files

// Read a file with specific encoding
const fileContent = await tools.read_file({
  filePath: "MyAwesomeApp/AppDelegate.swift",
  encoding: "utf-8"
});

// Write to a file
await tools.write_file({
  path: "MyAwesomeApp/NewFile.swift",
  content: "import Foundation\n\nclass NewClass {}\n",
  createIfMissing: true
});

// Search for text in files
const searchResults = await tools.search_in_files({
  directory: "MyAwesomeApp",
  pattern: "*.swift",
  searchText: "class",
  isRegex: false
});

Building and Testing

// Build the project
await tools.build_project({
  scheme: "MyAwesomeApp",
  configuration: "Debug"
});

// Run tests
await tools.test_project({
  scheme: "MyAwesomeApp",
  testPlan: "MyAwesomeAppTests"
});

Project Structure

xcode-mcp-server/
├── src/
│   ├── index.ts                 # Entry point
│   ├── server.ts                # MCP server implementation
│   ├── types/                   # Type definitions
│   │   └── index.ts             # Core type definitions
│   ├── utils/                   # Utility functions
│   │   ├── errors.js            # Error handling classes
│   │   ├── pathManager.ts       # Path validation and management
│   │   ├── project.js           # Project utilities
│   │   └── simulator.js         # Simulator utilities
│   └── tools/                   # Tool implementations
│       ├── project/             # Project management tools
│       │   └── index.ts         # Project creation, detection, file adding
│       ├── file/                # File operation tools
│       │   └── index.ts         # File reading, writing, searching
│       ├── build/               # Build and testing tools
│       │   └── index.ts         # Building, testing, analyzing
│       ├── cocoapods/           # CocoaPods integration
│       │   └── index.ts         # Pod installation and management
│       ├── spm/                 # Swift Package Manager tools
│       │   └── index.ts         # Package management and documentation
│       ├── simulator/           # iOS simulator tools
│       │   └── index.ts         # Simulator control and interaction
│       └── xcode/               # Xcode utilities
│           └── index.ts         # Xcode version management, asset tools
├── docs/                        # Documentation
│   ├── tools-overview.md        # Comprehensive tool documentation
│   └── user-guide.md            # Usage examples and best practices
├── tests/                       # Tests
└── dist/                        # Compiled code (generated)

How It Works

The Xcode MCP server uses the Model Context Protocol to provide a standardized interface for AI models to interact with Xcode projects. The server architecture is designed with several key components:

Core Components

  1. Server Implementation: The main MCP server that handles tool registration and request processing.

  2. Path Management: Ensures secure file access by validating all paths against allowed directories.

  3. Project Management: Detects, loads, and manages different types of Xcode projects:

    • Standard Xcode projects (.xcodeproj)

    • Xcode workspaces (.xcworkspace)

    • Swift Package Manager projects (Package.swift)

  4. Directory State: Maintains the active directory context for relative path resolution.

  5. Tool Registry: Organizes tools into logical categories for different Xcode operations.

Request Flow

  1. An AI assistant sends a tool execution request to the MCP server.

  2. The server validates the request parameters and permissions.

  3. The appropriate tool handler is invoked with the validated parameters.

  4. The tool executes the requested operation, often using native Xcode commands.

  5. Results are formatted and returned to the AI assistant.

  6. Comprehensive error handling provides meaningful feedback for troubleshooting.

Safety Features

  • 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.

Project Type Support

The server intelligently handles different project types:

  • Standard Projects: Direct .xcodeproj manipulation

  • Workspaces: Manages multiple projects within a workspace

  • SPM Projects: Handles Swift Package Manager specific operations

This architecture allows AI assistants to seamlessly work with any type of Xcode project while maintaining security and providing detailed feedback.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/amazing-feature)

  3. Commit your changes (git commit -m 'Add some amazing feature')

  4. Push to the branch (git push origin feature/amazing-feature)

  5. Open a Pull Request

Development Guidelines

  • Follow the existing code style and organization

  • Add comprehensive error handling with specific error messages

  • Write tests for new functionality

  • Update documentation to reflect your changes

  • Ensure compatibility with different project types (standard, workspace, SPM)

Adding New Tools

To add a new tool to the server:

  1. Identify the appropriate category in the src/tools/ directory

  2. Implement the tool using the existing patterns with Zod schema validation

  3. Register the tool in the category's index.ts file

  4. Add error handling with specific error messages

  5. Document the tool in the appropriate documentation files

Troubleshooting

Common Issues

  • Path Access Errors: Ensure the paths you're trying to access are within the allowed directories

  • Build Failures: Check that Xcode command line tools are installed and up to date

  • Tool Not Found: Verify that the tool name is correct and properly registered

  • Parameter Validation Errors: Check the parameter types and requirements in the tool documentation

Debugging

  1. Start the server with debug logging enabled: npm start -- --debug

  2. Check the console output for detailed error messages

  3. Examine the server logs for request and response details

  4. For tool-specific issues, try running the equivalent Xcode command directly in the terminal

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the Model Context Protocol team for the MCP SDK

  • Built with TypeScript and Node.js

  • Uses Xcode command line tools and Swift Package Manager

  • Special thanks to all contributors who have helped improve the server's functionality and robustness

Available Tools

76 tools
add_file_to_projectC

Adds a file to the active Xcode project.

Inputs: filePath (required), group, targetName, createGroups.

add_project_to_workspaceB

Adds an existing project to the active workspace.

Inputs: projectPath (required), workspacePath.

add_swift_packageA

Adds a Swift Package dependency to the active project. Note: Your project must already be set up for Swift Package Manager (must have a Package.swift file). If you haven't initialized SPM yet, use the init_swift_package tool first.

Inputs: url (required), version, skipUpdate, productName.

analyze_fileB

Analyzes a source file for potential issues using Xcode's static analyzer.

Inputs: filePath (required), sdk, scheme.

archive_projectB

Archives the active Xcode project for distribution.

Inputs: scheme (required), archivePath (required), configuration (required), destination, +1 more.

boot_simulatorA

Boot an iOS simulator by UDID or name

Inputs: name, udid, runtime.

build_projectA

Builds the active Xcode project using the specified configuration and scheme.

Inputs: scheme (required), configuration (required), sdk, jobs, +2 more.

build_spm_packageA

Builds a Swift Package Manager package directly using 'swift build' instead of Xcode.

Inputs: target, verbose, packagePath, configuration.

build_swift_packageC

Builds a Swift Package using Swift Package Manager.

Inputs: jobs, target, product, verbose, +3 more.

change_directoryA

Changes the active directory for relative path operations.

Inputs: directoryPath (required).

check_cocoapodsA

Checks if the active project uses CocoaPods and returns setup information.

Inputs: includeOutdated.

check_file_existsA

Checks if a file or directory exists at the specified path.

Inputs: path (required).

clean_projectA

Cleans the build directory for the active Xcode project.

Inputs: scheme, configuration, derivedDataPath.

clean_swift_packageA

Cleans the build artifacts of a Swift Package.

Inputs: reset, purgeCache.

compile_asset_catalogB

Compiles an asset catalog (.xcassets) using actool

Inputs: outputDir (required), catalogPath (required), appIcon, platform, +2 more.

copy_fileB

Copies a file or directory to a new location within allowed directories.

Inputs: source (required), destination (required), recursive.

create_directoryC

Creates a new directory within allowed directories.

Inputs: path (required).

create_workspaceA

Creates a new Xcode workspace and optionally adds existing projects to it.

Inputs: name (required), outputDirectory (required), projects, setAsActive.

create_xcode_projectB

Creates a new Xcode project using a template.

Inputs: name (required), template (required), outputDirectory (required), language, +5 more.

delete_fileA

Deletes a file or directory within allowed directories.

Inputs: path (required), recursive.

detect_active_projectB

Attempts to automatically detect the active Xcode project.

Inputs: forceRedetect.

dump_swift_packageA

Dumps the Package.swift manifest as JSON.

Inputs: no named parameters.

edit_package_swiftA

Directly edit the Package.swift file of the active SPM project. This is useful for making changes that aren't supported by the other SPM tools.

Inputs: content (required), packagePath, createBackup.

export_archiveB

Export an Xcode archive for distribution (App Store, Ad Hoc, Enterprise, Development)

Inputs: method (required), exportPath (required), archivePath (required), teamId, +4 more.

find_filesB

Searches for files matching a pattern in a directory.

Inputs: path (required), pattern (required), maxDepth, showHidden.

find_projectsB

Finds Xcode projects in the specified directory.

Inputs: directory, includeSPM, includeWorkspaces.

generate_icon_setA

Generate an app icon set from a source image

Inputs: outputPath (required), sourceImage (required), platform.

generate_swift_docsB

Generates documentation for a Swift Package using DocC.

Inputs: outputPath (required), openInBrowser, hostingBasePath, transformForStaticHosting.

get_active_projectB

Retrieves detailed information about the currently active Xcode project.

Inputs: detailed.

get_current_directoryB

Returns the current active directory.

Inputs: no named parameters.

get_file_infoC

Gets detailed information about a file or directory.

Inputs: path (required).

get_package_infoC

Gets detailed information about a Swift Package Manager package.

Inputs: packagePath.

get_project_configurationA

Retrieves configuration details for the active project, including schemes and targets.

Inputs: no named parameters.

get_xcode_infoA

Get information about Xcode installations on the system

Inputs: no named parameters.

init_swift_packageA

Initializes a new Swift Package Manager project in the current directory. Use this tool first if your project doesn't have a Package.swift file yet and you want to start using Swift packages.

Inputs: name, type, enableTests, testingFramework.

install_appB

Install an app on a simulator

Inputs: udid (required), appPath (required).

launch_appB

Launch an installed app on a simulator

Inputs: udid (required), bundleId (required), args, waitForDebugger.

list_available_destinationsA

Lists available build destinations for the active Xcode project or workspace.

Inputs: scheme.

list_available_schemesA

Lists all available schemes in the active Xcode project or workspace.

Inputs: no named parameters.

list_booted_simulatorsA

List all currently booted iOS simulators

Inputs: no named parameters.

list_directoryB

Lists the contents of a directory, showing both files and subdirectories.

Inputs: path (required), format, showHidden.

list_installed_appsA

List all installed applications on a simulator

Inputs: udid (required).

list_project_filesC

Lists all files within an Xcode project.

Inputs: projectPath (required), fileType.

list_simulatorsA

List all available iOS simulators with filtering options

Inputs: format, filterName, filterState, filterRuntime.

move_fileB

Moves a file or directory to a new location within allowed directories.

Inputs: source (required), destination (required).

open_urlB

Open a URL in a simulator

Inputs: url (required), udid (required).

pod_deintegrateA

Deintegrate CocoaPods from the active project, removing all traces of CocoaPods.

Inputs: no named parameters.

pod_initB

Generate a Podfile for the current project directory.

Inputs: no named parameters.

pod_installA

Runs 'pod install' in the active project directory to install CocoaPods dependencies.

Inputs: verbose, repoUpdate, cleanInstall.

pod_outdatedA

Shows outdated pods in the current project and their available updates.

Inputs: repoUpdate, ignorePrerelease.

pod_repo_updateB

Updates the local clone of the CocoaPods spec repositories.

Inputs: silent, verbose.

pod_updateC

Runs 'pod update' in the active project directory to update CocoaPods dependencies.

Inputs: pods, sources, repoUpdate, excludePods, +1 more.

pop_directoryA

Pops a directory from the stack and changes to it.

Inputs: no named parameters.

push_directoryA

Pushes the current directory onto a stack and changes to a new directory.

Inputs: directoryPath (required).

read_fileA

Reads the contents of a file within the active project or allowed directories.

Inputs: filePath (required), asBinary, encoding.

remove_swift_packageA

Removes a Swift Package dependency from the active project.

Inputs: url (required), confirm (required).

reset_simulatorA

Reset a simulator by erasing all content and settings

Inputs: udid (required), confirm (required).

resolve_pathB

Resolves a path, taking into account the active directory and current project.

Inputs: path (required).

run_lldbC

Launches the LLDB debugger with optional arguments

Inputs: args, command.

run_testsB

Executes tests for the active Xcode project.

Inputs: scheme, testPlan, destination, onlyTesting, +3 more.

run_xcrunC

Executes a specified Xcode tool via xcrun

Inputs: tool (required), args, workingDir.

search_in_filesB

Searches for text content within files in a directory.

Inputs: pattern (required), directory (required), searchText (required), isRegex, +3 more.

set_project_pathA

Sets the active Xcode project by specifying the path to its .xcodeproj directory.

Inputs: projectPath (required), openInXcode, setActiveDirectory.

set_projects_base_dirC

Sets the base directory where your Xcode projects are stored.

Inputs: baseDir (required).

show_swift_dependenciesB

Shows the resolved dependencies of a Swift Package.

Inputs: format, verbose, outputPath.

shutdown_simulatorA

Shutdown a simulator by UDID, or shutdown all running simulators

Inputs: all, udid.

swift_package_commandC

Executes Swift Package Manager commands in the active project directory.

Inputs: command (required), extraArgs, configuration.

switch_xcodeB

Switch the active Xcode version

Inputs: version, xcodePath.

take_screenshotB

Take a screenshot of a simulator

Inputs: udid (required), outputPath (required).

terminate_appB

Terminate a running app on a simulator

Inputs: udid (required), bundleId (required).

test_spm_packageB

Runs tests for a Swift Package Manager package directly using 'swift test' instead of Xcode.

Inputs: filter, verbose, parallel, packagePath.

test_swift_packageC

Tests a Swift Package using Swift Package Manager.

Inputs: skip, filter, parallel, listTests, +4 more.

trace_appB

Captures a performance trace of an application using xctrace

Inputs: appPath (required), duration, template, outputPath, +1 more.

update_swift_packageB

Updates the dependencies of your Swift project using Swift Package Manager.

Inputs: branch, version, revision, specificPackage.

validate_appA

Validate an app for App Store submission using altool

Inputs: ipaPath (required), password (required), username (required), apiKey, +2 more.

write_fileA

Writes or updates the content of a file within the active project or allowed directories.

Inputs: path (required), content (required), encoding, filePath, +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 76 tools

    Disambiguation2/5

    With 76 tools, many overlap in purpose: three different build tools (build_project, build_spm_package, build_swift_package), multiple test tools, and several project-detection tools (detect_active_project, get_active_project, get_project_configuration). Agents would struggle to choose the right tool.

    Naming Consistency3/5

    Most tools follow verb_noun (build_project, list_simulators), but a substantial subset uses noun_verb (pod_install, swift_package_command, pod_repo_update). This inconsistency creates ambiguity about whether the verb comes first.

    Tool Count1/5

    76 tools is far beyond any reasonable scope, even for a broad Xcode server. Many tools could be consolidated (e.g., a single SPM build tool, a single test tool).

    Completeness4/5

    Despite the bloat, the surface covers core Xcode workflows: project creation, file operations, building, testing, archiving, simulator control, and dependency management. Minor gaps exist (no scheme editing, no provisioning profile management).

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A server that acts as a bridge between Claude and local Xcode projects, enabling AI-powered code assistance, project management, and automated development tasks without exposing your code to the internet.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enable Claude Code, Cursor, or your favorite LLM to interact with Xcode, building your projects the same way you do, and seeing the same errors. Greatly increases productivity when working on iOS, iPadOS, macOS, visionOS, tvOS projects & Swift packages - or any time you might use Xcode.
      29
      225 PyPI
      5
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to build, test, run, and manage Apple platform projects (iOS, macOS, tvOS, watchOS, visionOS) directly through Xcode. Provides comprehensive control over Xcode projects, Swift packages, simulators, and development workflows without leaving your editor.
      5
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Bridges AI assistants with Xcode to control projects, builds, simulators, testing, and debugging without manual interaction.
      1
      MIT