ios-simulator-mcp

repository·main·Indexed 24 days ago

https://github.com/joshuayoes/ios-simulator-mcp

An MCP server (v1.6.0) that enables AI assistants to interact with iOS simulators on macOS. It provides tools for automated UI testing, app installation, and visual inspection, including capabilities to tap, type, swipe, find UI elements via the accessibility tree, capture screenshots, and record videos. Requires Node.js, Xcode, and the Facebook IDB tool.

Tokens
4.5K
Snippets
6
Records
31
Agent score
85%

What's inside ios-simulator-mcp

  1. Configure Target Simulator via UDID or Environment Variables

    main

    Most tools in this MCP server accept an optional udid parameter to specify which simulator to target. The UDID must follow the format: UUID (8-4-4-4-12 hexadecimal characters).

    Alternatively, you can set the IDB_UDID environment variable to define a default target simulator for all tool calls.

  2. Install IDB using asdf (Python version manager)

    main

    If you use asdf to manage Python versions, follow these steps:

    1. Install the asdf tool and the python plugin.
    2. Install and set a global Python version.
    3. Install fb-idb using python -m pip install --user fb-idb.
    4. Add your user base binary directory (typically ~/.local/bin) to your PATH.
    5. Verify the installation by running idb -h.
    # 1. Install asdf and python plugin
    brew install asdf
    asdf plugin add python
    
    # 2. Install and set Python version
    asdf install python latest
    asdf global python latest
    asdf set python <latest-version> -u
    asdf reshim
    
    # 3. Install idb
    python -m pip install --user fb-idb
    
    # 4. Add to PATH (add to ~/.zshrc or ~/.bash_profile for persistence)
    export PATH="$HOME/.local/bin:$PATH"
    
    # 5. Verify
    idb -h
  3. Install the iOS Simulator MCP Server

    main

    The iOS Simulator MCP Server allows AI assistants to interact with iOS simulators.

    Prerequisites

    • Node.js
    • macOS (iOS simulators are only available on macOS)
    • Xcode and iOS simulators installed
    • Facebook IDB tool installed

    Installation via Cursor

    You can install the server directly in Cursor using the following configuration:

    npx -y ios-simulator-mcp
  4. Install the iOS Simulator MCP server with Claude Code

    main

    Integrate the server with Claude Code CLI using the claude mcp command.

    Run the following command to add the server:

    claude mcp add ios-simulator npx ios-simulator-mcp

    Option 2: Local Development

    1. Clone, install, and build the project locally as described in the Cursor guide.
    2. Add the server pointing to your local build path:
    claude mcp add ios-simulator -- node "/full/path/to/your/ios-simulator-mcp/build/index.js"

    Note: Replace /full/path/to/your/ with the absolute path to your cloned repository. Restart any running Claude Code sessions after installation.

  5. Install the iOS Simulator MCP server with Cursor

    main

    You can integrate the iOS Simulator MCP server with Cursor using either npx (recommended) or by pointing to a local development build.

    1. Open your Cursor MCP configuration file at ~/.cursor/mcp.json.
    2. Add the following configuration to the mcpServers section:
    {
      "mcpServers": {
        "ios-simulator": {
          "command": "npx",
          "args": ["-y", "ios-simulator-mcp"]
        }
      }
    }
    1. Restart Cursor.

    Option 2: Local Development

    1. Clone the repository, install dependencies, and build the project:
      git clone https://github.com/joshuayoes/ios-simulator-mcp
      cd ios-simulator-mcp
      npm install
      npm run build
    2. Edit ~/.cursor/mcp.json and add the configuration pointing to your absolute build path:
    {
      "mcpServers": {
        "ios-simulator": {
          "command": "node",
          "args": ["/full/path/to/your/ios-simulator-mcp/build/index.js"]
        }
      }
    }
    1. Replace /full/path/to/your/ with your actual absolute path and restart Cursor.
  6. Verify MCP server functionality with the Photos app test case

    main

    To manually verify that the iOS Simulator MCP server tools are functioning correctly, you can execute a sequence of tool calls within an MCP client (such as Cursor). The following test case uses the native Photos app on iOS 17.2 as a benchmark.

    Note: If you are using a different iOS version or a different app, you may need to adjust the search criteria or element types used in the sequence.

    1. Open the native Photo app in the iOS simulator.
    2. Call `get_booted_sim_id` to get the UDID of the booted simulator.
    3. Call `record_video` to start recording a screen recording of the test.
    4. Call `ui_describe_all` to make sure we are on the All Photos tab.
    5. Call `ui_find_element` with `{ "search": ["Search"], "type": "Button" }` to find the Search tab button by its label.
    6. Call `ui_describe_point` to verify the coordinates returned by `ui_find_element` for the Search tab button.
    7. Call `ui_tap` to tap the Search tab button.
    8. Call `ui_tap` to focus on the Search text input.
    9. Call `ui_type` to type "Photos" into the Search text input.
    10. Call `ui_describe_all` to describe the page and find the first photo result.
    11. Call `ui_describe_point` to find the x and y coordinates for the first photo result touchable area.
    12. Call `ui_tap` to tap the coordinates of the first photo result touchable area.
    13. Call `ui_swipe` to swipe from the center of the screen down to dismiss the photo and go back to the All Photos tab.
    14. Call `ui_describe_all` to describe the page and see we are the All Photos tab.
    15. Call `screenshot` to take a screenshot of the current page.
    16. Call `ui_view` to view the current page.
    17. Call `stop_recording` to stop the screen recording.
  7. Install IDB using Homebrew and pip

    main

    If you prefer using Homebrew, follow these steps to install Python and IDB:

    1. Install Homebrew if not present.
    2. Install Python via Homebrew.
    3. Install fb-idb using pip3 with the --user flag.
    4. Add your user base binary directory (typically ~/.local/bin) to your PATH to ensure the idb command is recognized.
    5. Verify the installation by running idb -h.
  8. Configure iOS Simulator MCP environment variables

    main

    The iOS Simulator MCP server supports the following environment variables for fine-grained control over its behavior. These can be passed via the env key in your MCP client configuration (e.g., mcp.json).

    VariableDescriptionExample
    IOS_SIMULATOR_MCP_FILTERED_TOOLSA comma-separated list of tool names to filter out from being registered.screenshot,record_video,stop_recording
    IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIRSpecifies a default directory for output files like screenshots and video recordings. Defaults to ~/Downloads.~/Code/awesome-project/tmp
    IOS_SIMULATOR_MCP_IDB_PATHSpecifies a custom path to the idb executable. Defaults to idb in your PATH.~/bin/idb
    {
      "mcpServers": {
        "ios-simulator": {
          "command": "npx",
          "args": ["-y", "ios-simulator-mcp"],
          "env": {
            "IOS_SIMULATOR_MCP_FILTERED_TOOLS": "screenshot,record_video,stop_recording",
            "IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR": "~/Code/awesome-project/tmp",
            "IOS_SIMULATOR_MCP_IDB_PATH": "~/bin/idb"
          }
        }
      }
    }
  9. Fix 'idb: command not found' or IDB errors

    main

    If you encounter idb: command not found or general IDB errors:

    1. Re-run the installation steps for either Homebrew/pip or asdf.
    2. Ensure the directory containing the idb binary is included in your system PATH. You can test this by running idb --version in your terminal.