press_button
Press hardware buttons on iOS simulators to simulate device interactions like home, lock, side button, and Siri actions for automated testing and control.
Instructions
Press a hardware button on the simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| button | Yes | Button to press | |
| udid | No | Simulator UDID (optional, defaults to booted simulator) |
Implementation Reference
- src/index.ts:821-831 (handler)The pressButton handler method, which executes the 'idb ui button' command to trigger hardware button presses on the iOS simulator.
private async pressButton(button: string, udid?: string) { const target = await resolveUdid(udid); try { await execAsync(`idb ui button --udid ${target} ${button}`); return { content: [{ type: 'text', text: `Pressed ${button} on ${target}` }], }; } catch (error: any) { throw new McpError(ErrorCode.InternalError, `Failed to press button: ${error.message}`); } } - src/index.ts:427-443 (schema)The JSON schema definition for the 'press_button' tool, defining the allowed button enum and optional UDID parameter.
{ name: 'press_button', description: 'Press a hardware button on the simulator', inputSchema: { type: 'object', properties: { button: { type: 'string', enum: ['HOME', 'LOCK', 'SIDE_BUTTON', 'SIRI'], description: 'Button to press', }, udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' }, }, required: ['button'], additionalProperties: false, }, }, - src/index.ts:528-529 (registration)The registration/dispatch logic inside the CallToolRequestSchema handler that routes 'press_button' requests to the class method.
case 'press_button': return this.pressButton(args.button as string, args.udid);