Sponsored by Deepsite.site

Xcode Instruments CLI

Created By
nzrsky7 months ago
Content

XCTools MCP Server

A Model Context Protocol (MCP) server that provides structured access to Xcode development tools including xcrun, xcodebuild, and xctrace.

Installation

Method 1: Using uvx

  1. Prerequisites:

    • Python 3.13+
    • Xcode with Command Line Tools installed
    • uvx: curl -LsSf https://astral.sh/uv/install.sh | sh
  2. Run directly with uvx:

    uvx xctools-mcp-server
    

Method 2: Local Development Installation

  1. Prerequisites:

    • Python 3.13+
    • Xcode with Command Line Tools installed
  2. Clone and install:

    git clone https://github.com/nzrsky/xctools-mcp-server
    cd xctools-mcp-server
    pip install .
    
  3. Run the server:

    xctools-mcp-server
    

Method 3: Build from Source

  1. Build the wheel:
    python -m build --wheel
    pip install dist/xctools_mcp_server-0.1.0-py3-none-any.whl
    

Configuration

For Claude Desktop

Add to your ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "xctools": {
      "command": "xctools-mcp-server",
      "args": [],
      "env": {}
    }
  }
}

Or if using uvx:

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

For VS Code with MCP Extension

  1. Install the MCP Extension from the VS Code marketplace
  2. Add server configuration to your VS Code settings (settings.json):
{
  "mcp.servers": {
    "xctools": {
      "command": "xctools-mcp-server",
      "args": [],
      "env": {}
    }
  }
}

Or if using uvx:

{
  "mcp.servers": {
    "xctools": {
      "command": "uvx",
      "args": ["xctools-mcp-server"],
      "env": {}
    }
  }
}
  1. Restart VS Code to load the MCP server
  2. Use the Command Palette (Cmd+Shift+P) and search for "MCP" commands to interact with the Xcode development tools

For Other MCP Clients

The server runs on stdio, so you can invoke it directly:

With installed package:

xctools-mcp-server

With uvx:

uvx xctools-mcp-server

Features

  • Complete Xcode toolchain access through xcrun
  • Project building and testing with xcodebuild
  • Performance analysis using xctrace (Instruments)
  • SDK and destination management
  • Comprehensive error handling with detailed messages
  • Cross-platform compatibility (macOS with Xcode installed)

Available Tools

XCRUN Tools

  • xcrun_find_tool - Find the path to development tools (clang, swift, etc.)
  • xcrun_show_sdk_path - Show the path to SDKs
  • xcrun_show_sdk_version - Show SDK versions
  • xcrun_run_tool - Run any development tool via xcrun

XCODEBUILD Tools

  • xcodebuild_build - Build Xcode projects or workspaces
  • xcodebuild_test - Run tests for projects/workspaces
  • xcodebuild_archive - Archive projects for distribution
  • xcodebuild_list - List targets, schemes, and configurations
  • xcodebuild_show_sdks - List all available SDKs
  • xcodebuild_show_destinations - Show valid build destinations

XCTRACE Tools (Instruments)

  • xctrace_record - Record new Instruments traces
  • xctrace_import - Import supported files into trace format
  • xctrace_export - Export data from trace files
  • xctrace_list - List available devices, templates, or instruments
  • xctrace_symbolicate - Symbolicate traces with debug symbols

Usage Examples

Finding Development Tools

# Find the path to a specific tool
"Find the path to clang compiler"

# Show SDK path for iOS
"Show the path to the iOS SDK"

# Get SDK version information
"Show the version of the iOS SDK"

Building Projects

# Build an Xcode project
"Build the project MyApp.xcodeproj for iOS simulator"

# Run tests for a workspace
"Run tests for MyApp.xcworkspace on iPhone 15 Pro simulator"

# Archive for distribution
"Archive MyApp.xcworkspace for release"

# List project information
"List all schemes and targets in MyApp.xcodeproj"

Performance Analysis with Instruments

# Record a trace for Time Profiler
"Record a Time Profiler trace for MyApp on iPhone 15 Pro for 30 seconds"

# List available instruments
"List all available Instruments templates"

# Export trace data
"Export data from trace file to XML format"

# Import a file for analysis
"Import a .dtps file into Instruments trace format"

SDK and Destination Management

# List all available SDKs
"Show all available SDKs for building"

# Show build destinations
"List all available destinations for iOS builds"

# Run a tool via xcrun
"Run swift command with version flag via xcrun"

Error Handling

The server includes comprehensive error handling:

  • Command failures: Returns detailed error messages from xcrun, xcodebuild, and xctrace
  • Missing Xcode: Detects when Xcode Command Line Tools are not available
  • Invalid parameters: Validates tool arguments and provides helpful error messages
  • Tool availability: Checks for required tools before execution

Troubleshooting

Common Issues

  1. "xcrun: error: unable to find utility"

    • Ensure Xcode Command Line Tools are installed: xcode-select --install
    • Verify Xcode is properly configured: xcode-select -p
  2. "No developer directory found"

    • Install Xcode from the Mac App Store
    • Accept Xcode license: sudo xcodebuild -license accept
  3. Permission errors

    • Ensure the user has necessary permissions to access Xcode tools
    • Try running with proper macOS development permissions
  4. Tool not found errors

    • Verify the specific tool is available in your Xcode installation
    • Some tools may require specific Xcode versions or additional components

Requirements

  • macOS: Required (Xcode development tools are macOS-only)
  • Xcode: Xcode Command Line Tools or full Xcode installation
  • Python: 3.13 or higher
  • MCP Client: Claude Desktop, VS Code with MCP extension, or any MCP-compatible client

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

  • Invalid parameters: Validates input parameters before execution
  • File operations: Handles temporary files for push notifications safely

Security Considerations

  • The server only exposes read and simulator management operations
  • No access to host file system beyond specified app paths
  • Push notification payloads are validated for structure
  • Privacy permission changes are explicit and logged

Development Notes

  • Built specifically for iOS development workflows
  • Optimized for common simulator management tasks
  • Structured output parsing for JSON responses
  • Support for both individual and batch operations
  • Compatible with Xcode 15+ simulator features

Server Config

{
  "mcpServers": {
    "xcinstruments": {
      "command": "uvx",
      "args": [
        "xctools-mcp-server"
      ],
      "env": {}
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
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.
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Tavily Mcp
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"
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.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
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.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server
Playwright McpPlaywright MCP server