Skip to content

[Feature]: Add tools to toggle iOS Simulator software keyboard and hardware keyboard connection #346

@yjmeqt

Description

@yjmeqt

Feature Description

Expose the iOS Simulator's two keyboard menu actions as MCP tools:

  • toggle_software_keyboard — equivalent to Simulator → I/O → Keyboard → Toggle Software Keyboard (⌘K). Shows/hides the on-screen software keyboard.
  • toggle_connect_hardware_keyboard — equivalent to Simulator → I/O → Keyboard → Connect Hardware Keyboard (⇧⌘K). Toggles whether the simulator receives input from the Mac's hardware keyboard.

Neither action is currently available through XcodeBuildMCP. Both are menu-level Simulator.app operations with no direct xcrun simctl equivalent, so an agent cannot reach them without driving Simulator.app via AppleScript/accessibility — which is exactly the kind of glue MCP should provide.

Use Cases

  • UI automation / UI tests where the software keyboard must be visible for tap-based text entry. With "Connect Hardware Keyboard" on (default), tapping a text field does not bring up the software keyboard, which breaks scripted flows that rely on tapping individual keys.
  • Reproducing layout bugs that only occur when the software keyboard is visible (e.g. keyboardWillShow adjustments, safe-area insets, scroll-to-input behavior).
  • Recording screenshots/videos that must include the software keyboard.
  • Switching a simulator between "developer typing on Mac keyboard" and "end-user typing on touch keyboard" without manually navigating menus.

Example Interactions

You:  Open the notes app in the booted simulator, make the software keyboard appear, and take a screenshot showing it.
AI:   (boots/focuses sim) → toggle_connect_hardware_keyboard(simulatorUuid)
                          → tap on the note text field
                          → screenshot()

You:  I'm testing keyboardWillShow adjustments. Make sure the hardware keyboard is disconnected so the software keyboard actually appears.
AI:   toggle_connect_hardware_keyboard(simulatorUuid) if currently connected.

You:  Hide the software keyboard so I can see the full view.
AI:   toggle_software_keyboard(simulatorUuid)

Notes / open design questions

  • Both actions are global to the Simulator.app front window rather than per-device; the tool would focus the requested simulator first, then send the keystroke via AppleScript.
  • Alternative implementation for hardware-keyboard: defaults write com.apple.iphonesimulator ConnectHardwareKeyboard — persistent but requires a simulator restart. Leaning toward the AppleScript menu/keystroke approach to match manual user behavior and avoid restart. Happy to go the other way if maintainers prefer.
  • Proposed placement: src/mcp/tools/simulator-management/ alongside sim_statusbar and set_sim_appearance, since these are Simulator.app settings rather than in-app UI automation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions