Sponsored by Deepsite.site

Xcode Mcp Server (drewster99)

Created By
drewster994 months ago
An MCP (Model Context Protocol) server for controlling and interacting with Xcode from AI assistants and LLMs like Claude Code, Cursor, Claude Desktop, LM Studio, etc. This server significantly improves the build cycle. Now Claude (or your favorite tool) can directly command Xcode to build your project. Because Xcode is building it directly (rather than xcodebuild command-line or similar), the build happens exactly the same way as when you build it in Xcode. Xcode-mcp-server returns relevant build errors or warnings back to your coding tool (like Cursor or Claude Code), so the LLM sees exactly the same errors you do. Included tool functions here - you don't really need to know this info because your coding LLM will get this info (and more details) automatically, but I've included it here for the curious: - version - Returns xcode-mcp-server's version string - get_xcode_projects - Finds all .xcodeproj and .xcworkspace projects in the given search_path. If search_path is empty, all paths to which the tool has been granted access are searched - get_project_hierarchy - Returns the path hierarchy of the project or workspace - get_project_schemes - Returns a list of build schemes for the specified project - build_project - Commands Xcode to build. This is the workhorse that builds your project again and again, returning success or build errors - run_project - Commands Xcode to run your project - get_build_errors - Returns most recent build errors from the given project - clean_project - Cleans build
Content

Xcode MCP Server

An MCP (Model Context Protocol) server for controlling and interacting with Xcode from AI assistants like Claude.

Features

  • Get project hierarchy
  • Build and run projects
  • Retrieve build errors
  • Get runtime output (placeholder)
  • Clean projects

Security

The server implements path-based security to prevent unauthorized access to files outside of allowed directories:

  • You must specify allowed folders using the environment variable:
    • XCODEMCP_ALLOWED_FOLDERS=/path1:/path2:/path3
  • Otherwise, all files and subfolders from your home directory ($HOME) will be allowed.

Security requirements:

  • All paths must be absolute (starting with /)
  • No path components with .. are allowed
  • All paths must exist and be directories

Example:

# Set the environment variable
export XCODEMCP_ALLOWED_FOLDERS=/Users/username/Projects:/Users/username/checkouts
python3 xcode_mcp.py

# Or inline with the MCP command
XCODEMCP_ALLOWED_FOLDERS=/Users/username/Projects mcp dev xcode_mcp.py

If no allowed folders are specified, access will be restricted and tools will return error messages.

Setup

  1. Configure Claude for Desktop:

First, using homebrew, install 'uv'. You might already have this on your system, but installing it via Homebrew usually ensures that uvx (part of uv) is in the $PATH that Claude Desktop vends to on-device local MCP servers:

brew install uv

Open/create your Claude for Desktop configuration file

  • Open Claude Desktop --> Settings --> Developer --> Edit Config (to find the file in finder)
  • It should be at ~/Library/Application Support/Claude/claude_desktop_config.json
  • Add the following:
{
    "mcpServers": {
        "xcode-mcp-server": {
            "command": "uvx",
            "args": [
                "xcode-mcp-server"
            ]
        }
    }
}

If you'd like to allow only certain projects or folders to be accessible by xcode-mcp-server, add the env option, with a colon-separated list of absolute folder paths, like this:

{
    "mcpServers": {
        "xcode-mcp-server": {
            "command": "uvx",
            "args": [
                "xcode-mcp-server"
            ],
            "env": {
                "XCODEMCP_ALLOWED_FOLDERS": "/Users/andrew/my_project:/Users/andrew/Documents/source"
            }
        }
    }
}

If you omit the env section, access will default to your $HOME directory.

  1. Add xcode-mcp-server to Claude Code (Anthropic's CLI-based agent)
  • Install claude code

  • Add xcode-mcp-server:

    claude mcp add --scope user --transport stdio which uvx xcode-mcp-server

  1. Add xcode-mcp-server to Cursor AI
  • Install Cursor, of course
  • In Cursor, navigate to: Cursor --> Settings --> Cursor Settings
  • Then choose 'Tools & Integrations'
  • Tap the + button for 'New MCP Server'

The steps above will get you editing the file ~/.cursor/mcp.json, which you could also edit directly, if you prefer. Add a section for 'xcode-mcp-server' in the 'mcpServers' section - like this:

{
    "mcpServers": {
        "xcode-mcp-server": {
            "command": "uvx",
            "args": [
                "xcode-mcp-server"
            ]
        }
    }
}

If you'd like to allow only certain projects or folders to be accessible by xcode-mcp-server, add the env option, with a colon-separated list of absolute folder paths, like this:

{
    "mcpServers": {
        "xcode-mcp-server": {
            "command": "uvx",
            "args": [
                "xcode-mcp-server"
            ],
            "env": {
                "XCODEMCP_ALLOWED_FOLDERS": "/Users/andrew/my_project:/Users/andrew/Documents/source"
            }
        }
    }
}

Be sure to hit Command-S to save the file.

If you omit the env section, access will default to your $HOME directory.

Test it out

  • Open cursor to your favorite xcode project (just open the root folder of the project or git repo), and tell Cursor something like:

    build this project using xcode-mcp-server

You'll get a permission prompt from Cursor and then one from macOS, and after that you should be off and running.

Usage

  1. Open Xcode with a project
  2. Start Claude for Desktop
    • If xcode-mcp-server failed to initialize properly, you'll see errors
  3. Look for the hammer icon to find available Xcode tools
  4. Use natural language to interact with Xcode, for example:
    • "Build the project at /path/to/MyProject.xcodeproj"
    • "Run the app in /path/to/MyProject"
    • "What build errors are there in /path/to/MyProject.xcodeproj?"
    • "Clean the project at /path/to/MyProject"

Parameter Format

All tools require a project_path parameter pointing to an Xcode project/workspace directory:

"/path/to/your/project.xcodeproj"

or

"/path/to/your/project"

Development

The server is built with the MCP Python SDK and uses AppleScript to communicate with Xcode.

To test the server locally without Claude, use:

# Set the environment variable first
export XCODEMCP_ALLOWED_FOLDERS=/Users/username/Projects
mcp dev xcode_mcp.py

# Or inline with the command
XCODEMCP_ALLOWED_FOLDERS=/Users/username/Projects mcp dev xcode_mcp.py

This will open the MCP Inspector interface where you can test the tools directly.

Testing in MCP Inspector

When testing in the MCP Inspector, provide input values as quoted strings:

"/Users/username/Projects/MyApp"

Limitations

  • Project hierarchy is a simple file listing implementation
  • AppleScript syntax may need adjustments for specific Xcode versions # xcode-mcp-server

Server Config

{
  "mcpServers": {
    "xcode-mcp-server": {
      "command": "uvx",
      "args": [
        "xcode-mcp-server"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
ChatWiseThe second fastest AI chatbot™
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Serper MCP ServerA Serper MCP Server
Playwright McpPlaywright MCP server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code