Cover image
Try Now
2025-03-31

XCode集成的MCP服务器实现

3 years

Works with Finder

4

Github Watches

14

Github Forks

153

Github Stars

Xcode MCP Server

Xcode MCP Server Icon

A Model Context Protocol (MCP) server that brings the power of AI to your Xcode projects. This server acts as a bridge between Claude and your local Xcode development environment, enabling intelligent code assistance, project management, and automated development tasks.

Xcode Server MCP server

What is Xcode MCP Server?

At its core, this server follows a client-server architecture where Claude can securely interact with your local Xcode projects:

flowchart LR
    subgraph "Your Computer"
        Claude["Claude Desktop"]
        MCP["Xcode MCP Server"]
        XP[("Xcode Projects")]

        Claude <-->|"MCP Protocol\n(Commands & Results)"| MCP
        MCP <-->|"Local Access\n(File & Build Operations)"| XP
    end

The communication between the Xcode MCP server and your local projects happens entirely on your machine—your code is not exposed to the internet. The Model Context Protocol ensures that Claude can only perform approved operations through well-defined interfaces, giving you a secure way to let AI assist with your development while maintaining complete control.

MCP Client Compatibility

This server implements the Model Context Protocol (MCP) specification, making it compatible with any MCP-compliant client or host. While the installation instructions focus on Claude Desktop, you can use this server with:

  • Self-built MCP clients
  • Cursor AI
  • Other MCP-compatible IDEs and tools
  • Any application that implements the MCP client specification

The standardized protocol ensures consistent functionality across different clients while maintaining the same level of security and local-only operation.

Key Features

🔍 Intelligent Project Detection

  • Automatically finds and connects to your active Xcode project
  • Supports manual project selection for precise control
  • Maintains workspace context across interactions

📁 Smart File Operations

  • Read and analyze Swift, Objective-C, and project configuration files
  • Create and modify source files with proper syntax and imports
  • Intelligent file listing with type filtering and search

🛠 Project Management

  • Access project targets, configurations, and schemes
  • Analyze source files for potential issues
  • Execute builds with specific configurations
  • Run and manage test suites

Installation

You can install this server in three ways:

1. Using Claude Desktop with NPM Package

Update your Claude configuration file (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "xcode": {
      "command": "npx",
      "args": [
        "-y",
        "xcode-mcp-server"
      ],
      "env": {
        "PROJECTS_BASE_DIR": "/path/to/your/xcode/projects"
      }
    }
  }
}

2. Global NPM Installation

Install the package globally:

npm install -g @modelcontextprotocol/xcode-server

Then update your Claude configuration:

{
  "mcpServers": {
    "xcode": {
      "command": "xcode-server",
      "env": {
        "PROJECTS_BASE_DIR": "/path/to/your/xcode/projects"
      }
    }
  }
}

3. From Source

  1. Clone this repository:

    git clone https://github.com/r-huijts/xcode-mcp-server.git
    cd xcode-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Set up environment variables:

    cp .env.example .env
    

    Edit .env and set PROJECTS_BASE_DIR to your Xcode projects directory.

  4. Build the project:

    npm run build
    

Then update your Claude configuration:

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

Note: Replace /path/to/your/xcode/projects with the actual path to your Xcode projects directory.

After updating the configuration, restart Claude Desktop for the changes to take effect.

Working with the Server

The server provides a natural interface for Claude to assist with your Xcode development. Here are some ways you can interact:

Project Navigation

Ask Claude to:

  • "Set my Xcode projects directory to /Users/username/Documents/XcodeProjects"
  • "What's my current active project?"
  • "Switch to the MyApp.xcodeproj project"
  • "Show me all Swift files in the project"

Code Creation & Modification

Get help with:

  • "Create a new view called ProfileView with a preview provider"
  • "Add a @Published email property to UserModel.swift"
  • "Set up a modern async/await networking layer"
  • "Implement Core Data models with SwiftUI bindings"

Project Analysis & Building

Let Claude assist with:

  • "Analyze NetworkManager.swift for potential issues"
  • "Build the project in Debug configuration"
  • "Run the unit tests for the UserModel module"
  • "What build schemes are available?"

Development and Debugging

Building the Project

npm run build

Running Tests

npm test

Troubleshooting

The server provides detailed logging through stderr. Common issues and their solutions:

  1. Project Detection Issues

    • Verify your projects directory path
    • Ensure Xcode Command Line Tools are installed
    • Check file permissions
  2. Build Problems

    • Validate Xcode installation
    • Check project configurations
    • Review build settings

Contributing

We welcome contributions! Whether it's:

  • 🐛 Bug fixes
  • ✨ New features
  • 📚 Documentation improvements
  • 🧪 Additional tests

Feel free to submit a Pull Request.

License

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

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

    Reviews

    2 (1)
    Avatar
    user_opLJrYv6
    2025-04-17

    As a devoted user of the xcode-mcp-server, I can confidently say it's a game-changer for our projects. The seamless integration and efficient handling of multiple coding platforms have significantly boosted our productivity. Kudos to r-huijts for developing this robust and user-friendly tool. Highly recommended for any development team! Check it out at https://github.com/r-huijts/xcode-mcp-server.