mobile_press_button
Press hardware or navigation buttons on mobile devices to control volume, navigate interfaces, or trigger actions during automated testing and interaction workflows.
Instructions
Press a button on device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | The device identifier to use. Use mobile_list_available_devices to find which devices are available to you. | |
| button | Yes | The button to press. Supported buttons: BACK (android only), HOME, VOLUME_UP, VOLUME_DOWN, ENTER, DPAD_CENTER (android tv only), DPAD_UP (android tv only), DPAD_DOWN (android tv only), DPAD_LEFT (android tv only), DPAD_RIGHT (android tv only) |
Implementation Reference
- src/server.ts:426-439 (registration)MCP tool registration for 'mobile_press_button', including Zod input schema (device, button) and execution handler that delegates to Robot.pressButton(button).tool( "mobile_press_button", "Press Button", "Press a button on device", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), button: z.string().describe("The button to press. Supported buttons: BACK (android only), HOME, VOLUME_UP, VOLUME_DOWN, ENTER, DPAD_CENTER (android tv only), DPAD_UP (android tv only), DPAD_DOWN (android tv only), DPAD_LEFT (android tv only), DPAD_RIGHT (android tv only)"), }, async ({ device, button }) => { const robot = getRobotFromDevice(device); await robot.pressButton(button); return `Pressed the button: ${button}`; } );
- src/server.ts:434-438 (handler)Core handler logic for the MCP tool: retrieves Robot instance via getRobotFromDevice and invokes pressButton on it.async ({ device, button }) => { const robot = getRobotFromDevice(device); await robot.pressButton(button); return `Pressed the button: ${button}`; }
- src/android.ts:428-435 (helper)AndroidRobot implementation of pressButton: maps button to ADB keyevent code and executes via adb shell.public async pressButton(button: Button) { if (!BUTTON_MAP[button]) { throw new ActionableError(`Button "${button}" is not supported`); } const mapped = BUTTON_MAP[button]; this.adb("shell", "input", "keyevent", mapped); }
- src/ios.ts:184-187 (helper)IosRobot implementation of pressButton: delegates to WebDriverAgent (WDA).public async pressButton(button: Button): Promise<void> { const wda = await this.wda(); await wda.pressButton(button); }
- src/mobile-device.ts:176-178 (helper)MobileDevice implementation of pressButton: delegates to mobilecli via runCommand.public async pressButton(button: Button): Promise<void> { this.runCommand(["io", "button", button]); }