A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/r-huijts/xcode-mcp-server below:

r-huijts/xcode-mcp-server: MCP Server implementation for Xcode integration

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.

Option 1: Automated Setup (Recommended)

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:

  2. Dependency Installation:

  3. Configuration Setup:

  4. Claude 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:

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

  3. Install dependencies:

  4. Build the project:

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

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

Common Setup Issues:

  1. Build Errors:

  2. Missing Dependencies:

  3. Permission Issues:

  4. Configuration Problems:

  5. Claude Desktop Integration:

For development mode with automatic restarts:

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

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:

  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:

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

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

  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.

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.

  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

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

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4