by r-huijts
Provides AI assistants with full Xcode integration, enabling project creation, file manipulation, building, testing, CocoaPods and Swift Package Manager handling, and iOS simulator control.
Enables AI models to interact directly with Xcode projects, manage iOS simulators, and perform typical Xcode tasks such as building, testing, and packaging without manual command‑line work.
chmod +x setup.sh && ./setup.sh
) or follow the manual steps to clone the repo, run npm install
, and npm run build
.npm start
(or npm run dev
for hot‑reload). The server listens on the configured port (default 3000).http://localhost:<PORT>
; the assistant can now call the registered tools via the Model Context Protocol.xcrun
commands, compile asset catalogs, generate app icons, performance tracing, archive validation, switch Xcode versions.Q: Do I need a paid Apple developer account? A: No. The server works with any local Xcode installation; a developer account is only required for distribution or App Store validation.
Q: Can I run the server on Linux? A: The server relies on macOS‑only tools (Xcode, simctl), so it must run on macOS.
Q: How do I enable debugging logs?
A: Set DEBUG=true
in the .env
file or start the server with the --debug
flag.
Q: What ports are available?
A: Configure the PORT
variable in .env
or via --port
. The default is 3000
.
Q: Is there support for multiple simultaneous projects?
A: Yes. The server can switch active projects using the set_active_project
tool and respects ALLOWED_PATHS
for safe multi‑project access.
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.
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:
Environment Verification:
Dependency Installation:
npm install
to install all required Node.js packagesnpm run build
to compile the TypeScript codeConfiguration Setup:
.env
file if one doesn't existClaude Desktop Integration (Optional):
When to Use the Setup Script:
The script will guide you through the configuration process with clear prompts and helpful feedback.
When to Use Manual Setup:
Follow these steps for manual installation:
Clone the repository:
git clone https://github.com/r-huijts/xcode-mcp-server.git
cd xcode-mcp-server
Verify prerequisites (these must be installed):
Install dependencies:
npm install
Build the project:
npm run build
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.
For Claude Desktop integration (optional):
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"xcode": {
"command": "node",
"args": ["/path/to/xcode-mcp-server/dist/index.js"]
}
}
}
Common Setup Issues:
Build Errors:
node_modules
and running npm install
againnpx tsc --noEmit
Missing Dependencies:
npm install
againxcode-select --install
Permission Issues:
sudo gem install cocoapods
Configuration Problems:
.env
file has the correct format and valid pathsPROJECTS_BASE_DIR
points to an existing directoryClaude Desktop Integration:
index.js
npm start
For development mode with automatic restarts:
npm run dev
You can configure the server in two ways:
Environment variables in .env
file:
PROJECTS_BASE_DIR=/path/to/your/projects
DEBUG=true
ALLOWED_PATHS=/path/to/additional/allowed/directory
PORT=8080
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)The server implements the Model Context Protocol (MCP), making it compatible with various AI assistants that support this protocol. To connect:
http://localhost:3000
)For a comprehensive overview of all available tools and their usage, see Tools Overview.
For detailed usage examples and best practices, see User Guide.
// 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"
});
// 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
});
// Build the project
await tools.build_project({
scheme: "MyAwesomeApp",
configuration: "Debug"
});
// Run tests
await tools.test_project({
scheme: "MyAwesomeApp",
testPlan: "MyAwesomeAppTests"
});
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)
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:
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.
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.
The server intelligently handles different project types:
This architecture allows AI assistants to seamlessly work with any type of Xcode project while maintaining security and providing detailed feedback.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)To add a new tool to the server:
src/tools/
directoryindex.ts
filenpm start -- --debug
This project is licensed under the MIT License - see the LICENSE file for details.
Please log in to share your review and rating for this MCP.
{ "mcpServers": { "xcode": { "command": "npx", "args": [ "-y", "xcode-mcp-server" ], "env": {} } } }
Explore related MCPs that share similar capabilities and solve comparable challenges
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.