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. - Set active projects and get detailed project information - Create new Xcode projects from templates (iO
Add this skill
npx mdskills install r-huijts/xcode-mcp-serverComprehensive Xcode automation with excellent tool coverage, clear documentation, and proper setup guidance
1[](https://mseep.ai/app/r-huijts-xcode-mcp-server)23# Xcode MCP Server45An 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.67## Features89### Project Management10- Set active projects and get detailed project information11- Create new Xcode projects from templates (iOS, macOS, watchOS, tvOS)12- Add files to Xcode projects with target and group specification13- Parse workspace documents to find associated projects14- List available schemes in projects and workspaces1516### File Operations17- Read/write files with support for different encodings18- Handle binary files with base64 encoding/decoding19- Search for text content within files using patterns and regex20- Check file existence and get file metadata21- Create directory structures automatically2223### Build & Testing24- Build projects with customizable options25- Run tests with detailed failure reporting26- Analyze code for potential issues27- Clean build directories28- Archive projects for distribution2930### CocoaPods Integration31- Initialize CocoaPods in projects32- Install and update pods33- Add and remove pod dependencies34- Execute arbitrary pod commands3536### Swift Package Manager37- Initialize new Swift packages38- Add and remove package dependencies with various version requirements39- Update packages and resolve dependencies40- Generate documentation for Swift packages using DocC41- Run tests and build Swift packages4243### iOS Simulator Tools44- List available simulators with detailed information45- Boot and shut down simulators46- Install and launch apps on simulators47- Take screenshots and record videos48- Manage simulator settings and state4950### Xcode Utilities51- Execute Xcode commands via xcrun52- Compile asset catalogs53- Generate app icon sets from source images54- Trace app performance55- Export and validate archives for App Store submission56- Switch between different Xcode versions5758## Installation5960### Prerequisites6162- macOS with Xcode 14.0 or higher installed63- Node.js 16 or higher64- npm or yarn65- Swift 5.5+ for Swift Package Manager features66- CocoaPods (optional, for CocoaPods integration)6768### Setup6970#### Option 1: Automated Setup (Recommended)7172Use the included setup script which automates the installation and configuration process:7374```bash75# Make the script executable76chmod +x setup.sh7778# Run the setup script79./setup.sh80```8182**What the Setup Script Does:**83841. **Environment Verification**:85 - Checks that you're running on macOS86 - Verifies Xcode is installed and accessible87 - Confirms Node.js (v16+) and npm are available88 - Checks for Ruby installation89 - Verifies CocoaPods installation (offers to install if missing)90912. **Dependency Installation**:92 - Runs `npm install` to install all required Node.js packages93 - Executes `npm run build` to compile the TypeScript code94953. **Configuration Setup**:96 - Creates a `.env` file if one doesn't exist97 - Prompts for your projects base directory98 - Asks if you want to enable debug logging99 - Saves your configuration preferences1001014. **Claude Desktop Integration** (Optional):102 - Offers to configure the server for Claude Desktop103 - Creates or updates the Claude Desktop configuration file104 - Sets up the proper command and arguments to launch the server105106**When to Use the Setup Script:**107108- First-time installation to ensure all prerequisites are met109- When you want guided configuration with interactive prompts110- If you want to quickly set up Claude Desktop integration111- To verify your environment has all necessary components112113The script will guide you through the configuration process with clear prompts and helpful feedback.114115#### Option 2: Manual Setup116117**When to Use Manual Setup:**118119- You prefer explicit control over each installation step120- You have a custom environment or non-standard configuration121- You're setting up in a CI/CD pipeline or automated environment122- You want to customize specific aspects of the installation process123- You're an experienced developer familiar with Node.js projects124125Follow these steps for manual installation:1261271. Clone the repository:128 ```bash129 git clone https://github.com/r-huijts/xcode-mcp-server.git130 cd xcode-mcp-server131 ```1321332. Verify prerequisites (these must be installed):134 - Xcode and Xcode Command Line Tools135 - Node.js v16 or higher136 - npm137 - Ruby (for CocoaPods support)138 - CocoaPods (optional, for pod-related features)1391403. Install dependencies:141 ```bash142 npm install143 ```1441454. Build the project:146 ```bash147 npm run build148 ```1491505. Create a configuration file:151 ```bash152 # Option A: Start with the example configuration153 cp .env.example .env154155 # Option B: Create a minimal configuration156 echo "PROJECTS_BASE_DIR=/path/to/your/projects" > .env157 echo "DEBUG=false" >> .env158 ```159160 Edit the `.env` file to set your preferred configuration.1611626. For Claude Desktop integration (optional):163 - Edit or create `~/Library/Application Support/Claude/claude_desktop_config.json`164 - Add the following configuration (adjust paths as needed):165 ```json166 {167 "mcpServers": {168 "xcode": {169 "command": "node",170 "args": ["/path/to/xcode-mcp-server/dist/index.js"]171 }172 }173 }174 ```175176### Setup Troubleshooting177178**Common Setup Issues:**1791801. **Build Errors**:181 - Ensure you have the correct Node.js version (v16+)182 - Try deleting `node_modules` and running `npm install` again183 - Check for TypeScript errors with `npx tsc --noEmit`184 - Make sure all imports in the code are properly resolved1851862. **Missing Dependencies**:187 - If you see errors about missing modules, run `npm install` again188 - For native dependencies, you may need Xcode Command Line Tools: `xcode-select --install`1891903. **Permission Issues**:191 - Ensure you have write permissions to the installation directory192 - For CocoaPods installation, you may need to use `sudo gem install cocoapods`1931944. **Configuration Problems**:195 - Verify your `.env` file has the correct format and valid paths196 - Make sure `PROJECTS_BASE_DIR` points to an existing directory197 - Check that the path doesn't contain special characters that need escaping1981995. **Claude Desktop Integration**:200 - Ensure the path in the Claude configuration points to the correct location of `index.js`201 - Restart Claude Desktop after making configuration changes202 - Check that the server is running before attempting to use it with Claude203204## Usage205206### Starting the Server207208```bash209npm start210```211212For development mode with automatic restarts:213```bash214npm run dev215```216217### Configuration Options218219You can configure the server in two ways:2202211. Environment variables in `.env` file:222 ```223 PROJECTS_BASE_DIR=/path/to/your/projects224 DEBUG=true225 ALLOWED_PATHS=/path/to/additional/allowed/directory226 PORT=8080227 ```2282292. Command line arguments:230 ```bash231 npm start -- --projects-dir=/path/to/your/projects --port=8080232 ```233234### Key Configuration Parameters235236- `PROJECTS_BASE_DIR` / `--projects-dir`: Base directory for projects (required)237- `ALLOWED_PATHS` / `--allowed-paths`: Additional directories to allow access to (comma-separated)238- `PORT` / `--port`: Port to run the server on (default: 3000)239- `DEBUG` / `--debug`: Enable debug logging (default: false)240- `LOG_LEVEL` / `--log-level`: Set logging level (default: info)241242### Connecting to AI Assistants243244The server implements the Model Context Protocol (MCP), making it compatible with various AI assistants that support this protocol. To connect:2452461. Start the Xcode MCP server2472. Configure your AI assistant to use the server URL (typically `http://localhost:3000`)2483. The AI assistant will now have access to all the Xcode tools provided by the server249250### Tool Documentation251252For a comprehensive overview of all available tools and their usage, see [Tools Overview](docs/tools-overview.md).253254For detailed usage examples and best practices, see [User Guide](docs/user-guide.md).255256### Common Workflows257258#### Setting Up a New Project259260```javascript261// Create a new iOS app project262await tools.create_xcode_project({263 name: "MyAwesomeApp",264 template: "ios-app",265 outputDirectory: "~/Projects",266 organizationName: "My Organization",267 organizationIdentifier: "com.myorganization",268 language: "swift",269 includeTests: true,270 setAsActive: true271});272273// Add a Swift Package dependency274await tools.add_swift_package({275 url: "https://github.com/Alamofire/Alamofire.git",276 version: "from: 5.0.0"277});278```279280#### Working with Files281282```javascript283// Read a file with specific encoding284const fileContent = await tools.read_file({285 filePath: "MyAwesomeApp/AppDelegate.swift",286 encoding: "utf-8"287});288289// Write to a file290await tools.write_file({291 path: "MyAwesomeApp/NewFile.swift",292 content: "import Foundation\n\nclass NewClass {}\n",293 createIfMissing: true294});295296// Search for text in files297const searchResults = await tools.search_in_files({298 directory: "MyAwesomeApp",299 pattern: "*.swift",300 searchText: "class",301 isRegex: false302});303```304305#### Building and Testing306307```javascript308// Build the project309await tools.build_project({310 scheme: "MyAwesomeApp",311 configuration: "Debug"312});313314// Run tests315await tools.test_project({316 scheme: "MyAwesomeApp",317 testPlan: "MyAwesomeAppTests"318});319```320321## Project Structure322323```324xcode-mcp-server/325├── src/326│ ├── index.ts # Entry point327│ ├── server.ts # MCP server implementation328│ ├── types/ # Type definitions329│ │ └── index.ts # Core type definitions330│ ├── utils/ # Utility functions331│ │ ├── errors.js # Error handling classes332│ │ ├── pathManager.ts # Path validation and management333│ │ ├── project.js # Project utilities334│ │ └── simulator.js # Simulator utilities335│ └── tools/ # Tool implementations336│ ├── project/ # Project management tools337│ │ └── index.ts # Project creation, detection, file adding338│ ├── file/ # File operation tools339│ │ └── index.ts # File reading, writing, searching340│ ├── build/ # Build and testing tools341│ │ └── index.ts # Building, testing, analyzing342│ ├── cocoapods/ # CocoaPods integration343│ │ └── index.ts # Pod installation and management344│ ├── spm/ # Swift Package Manager tools345│ │ └── index.ts # Package management and documentation346│ ├── simulator/ # iOS simulator tools347│ │ └── index.ts # Simulator control and interaction348│ └── xcode/ # Xcode utilities349│ └── index.ts # Xcode version management, asset tools350├── docs/ # Documentation351│ ├── tools-overview.md # Comprehensive tool documentation352│ └── user-guide.md # Usage examples and best practices353├── tests/ # Tests354└── dist/ # Compiled code (generated)355```356357## How It Works358359The 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:360361### Core Components3623631. **Server Implementation**: The main MCP server that handles tool registration and request processing.3643652. **Path Management**: Ensures secure file access by validating all paths against allowed directories.3663673. **Project Management**: Detects, loads, and manages different types of Xcode projects:368 - Standard Xcode projects (.xcodeproj)369 - Xcode workspaces (.xcworkspace)370 - Swift Package Manager projects (Package.swift)3713724. **Directory State**: Maintains the active directory context for relative path resolution.3733745. **Tool Registry**: Organizes tools into logical categories for different Xcode operations.375376### Request Flow3773781. An AI assistant sends a tool execution request to the MCP server.3793802. The server validates the request parameters and permissions.3813823. The appropriate tool handler is invoked with the validated parameters.3833844. The tool executes the requested operation, often using native Xcode commands.3853865. Results are formatted and returned to the AI assistant.3873886. Comprehensive error handling provides meaningful feedback for troubleshooting.389390### Safety Features391392- **Path Validation**: All file operations are restricted to allowed directories.393- **Error Handling**: Detailed error messages help diagnose issues.394- **Parameter Validation**: Input parameters are validated using Zod schemas.395- **Process Management**: External processes are executed safely with proper error handling.396397### Project Type Support398399The server intelligently handles different project types:400401- **Standard Projects**: Direct .xcodeproj manipulation402- **Workspaces**: Manages multiple projects within a workspace403- **SPM Projects**: Handles Swift Package Manager specific operations404405This architecture allows AI assistants to seamlessly work with any type of Xcode project while maintaining security and providing detailed feedback.406407## Contributing408409Contributions are welcome! Please feel free to submit a Pull Request.4104111. Fork the repository4122. Create your feature branch (`git checkout -b feature/amazing-feature`)4133. Commit your changes (`git commit -m 'Add some amazing feature'`)4144. Push to the branch (`git push origin feature/amazing-feature`)4155. Open a Pull Request416417### Development Guidelines418419- Follow the existing code style and organization420- Add comprehensive error handling with specific error messages421- Write tests for new functionality422- Update documentation to reflect your changes423- Ensure compatibility with different project types (standard, workspace, SPM)424425### Adding New Tools426427To add a new tool to the server:4284291. Identify the appropriate category in the `src/tools/` directory4302. Implement the tool using the existing patterns with Zod schema validation4313. Register the tool in the category's `index.ts` file4324. Add error handling with specific error messages4335. Document the tool in the appropriate documentation files434435## Troubleshooting436437### Common Issues438439- **Path Access Errors**: Ensure the paths you're trying to access are within the allowed directories440- **Build Failures**: Check that Xcode command line tools are installed and up to date441- **Tool Not Found**: Verify that the tool name is correct and properly registered442- **Parameter Validation Errors**: Check the parameter types and requirements in the tool documentation443444### Debugging4454461. Start the server with debug logging enabled: `npm start -- --debug`4472. Check the console output for detailed error messages4483. Examine the server logs for request and response details4494. For tool-specific issues, try running the equivalent Xcode command directly in the terminal450451## License452453This project is licensed under the MIT License - see the LICENSE file for details.454455## Acknowledgments456457- Thanks to the Model Context Protocol team for the MCP SDK458- Built with TypeScript and Node.js459- Uses Xcode command line tools and Swift Package Manager460- Special thanks to all contributors who have helped improve the server's functionality and robustness461
Full transparency — inspect the skill content before installing.