Integrates with Xcode to streamline iOS development workflows, automate build processes, and facilitate code generation...
Created byApr 22, 2025
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:
What the Setup Script Does:
Environment Verification:
Dependency Installation:
Configuration Setup:
Claude Desktop Integration (Optional):
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:
Clone the repository:
Verify prerequisites (these must be installed):
Install dependencies:
Build the project:
Create a configuration file:Edit the .env file to set your preferred configuration.
For Claude Desktop integration (optional):
Setup Troubleshooting
Common Setup Issues:
Build Errors:
Missing Dependencies:
Permission Issues:
Configuration Problems:
Claude Desktop Integration:
Usage
Starting the Server
For development mode with automatic restarts:
Configuration Options
You can configure the server in two ways:
Environment variables in .env file:
Command line arguments:
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)
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:
Start the Xcode MCP server
Configure your AI assistant to use the server URL (typically http://localhost:3000)
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
Working with Files
Building and Testing
Project Structure
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
Server Implementation: The main MCP server that handles tool registration and request processing.
Path Management: Ensures secure file access by validating all paths against allowed directories.
Project Management: Detects, loads, and manages different types of Xcode projects:
Directory State: Maintains the active directory context for relative path resolution.
Tool Registry: Organizes tools into logical categories for different Xcode operations.
Request Flow
An AI assistant sends a tool execution request to the MCP server.
The server validates the request parameters and permissions.
The appropriate tool handler is invoked with the validated parameters.
The tool executes the requested operation, often using native Xcode commands.
Results are formatted and returned to the AI assistant.
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.
Fork the repository
Create your feature branch (git checkout -b feature/amazing-feature)
Commit your changes (git commit -m 'Add some amazing feature')
Push to the branch (git push origin feature/amazing-feature)
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:
Identify the appropriate category in the src/tools/ directory
Implement the tool using the existing patterns with Zod schema validation
Register the tool in the category's index.ts file
Add error handling with specific error messages
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
Start the server with debug logging enabled: npm start -- --debug
Check the console output for detailed error messages
Examine the server logs for request and response details
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
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:
What the Setup Script Does:
Environment Verification:
Dependency Installation:
Configuration Setup:
Claude Desktop Integration (Optional):
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:
Clone the repository:
Verify prerequisites (these must be installed):
Install dependencies:
Build the project:
Create a configuration file:Edit the .env file to set your preferred configuration.
For Claude Desktop integration (optional):
Setup Troubleshooting
Common Setup Issues:
Build Errors:
Missing Dependencies:
Permission Issues:
Configuration Problems:
Claude Desktop Integration:
Usage
Starting the Server
For development mode with automatic restarts:
Configuration Options
You can configure the server in two ways:
Environment variables in .env file:
Command line arguments:
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)
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:
Start the Xcode MCP server
Configure your AI assistant to use the server URL (typically http://localhost:3000)
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
Working with Files
Building and Testing
Project Structure
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
Server Implementation: The main MCP server that handles tool registration and request processing.
Path Management: Ensures secure file access by validating all paths against allowed directories.
Project Management: Detects, loads, and manages different types of Xcode projects:
Directory State: Maintains the active directory context for relative path resolution.
Tool Registry: Organizes tools into logical categories for different Xcode operations.
Request Flow
An AI assistant sends a tool execution request to the MCP server.
The server validates the request parameters and permissions.
The appropriate tool handler is invoked with the validated parameters.
The tool executes the requested operation, often using native Xcode commands.
Results are formatted and returned to the AI assistant.
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.
Fork the repository
Create your feature branch (git checkout -b feature/amazing-feature)
Commit your changes (git commit -m 'Add some amazing feature')
Push to the branch (git push origin feature/amazing-feature)
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:
Identify the appropriate category in the src/tools/ directory
Implement the tool using the existing patterns with Zod schema validation
Register the tool in the category's index.ts file
Add error handling with specific error messages
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
Start the server with debug logging enabled: npm start -- --debug
Check the console output for detailed error messages
Examine the server logs for request and response details
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