Skip to main content
Glama

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
NameRequiredDescriptionDefault
buttonYesButton to press
udidNoSimulator UDID (optional, defaults to booted simulator)

Implementation Reference

  • 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}`);
      }
    }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xmuweili/app-screen-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server