press_button
Simulate specific button presses on Android devices via the espresso-mcp server. Configure actions using the provided Enum button values for precise control.
Instructions
Simulate a button press on the connected Android device using an Enum button
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| button | Yes |
Implementation Reference
- src/espresso_mcp/server.py:238-248 (handler)The main handler function for the 'press_button' tool. It is registered via @mcp.tool() decorator and uses adb to simulate key events based on the Button enum input.@mcp.tool() def press_button(button: Button) -> str: """Simulate a button press on the connected Android device using an Enum button""" result = subprocess.run( ["adb", "shell", "input", "keyevent", button.value], capture_output=True, text=True, ) if result.returncode != 0: raise RuntimeError(f"Error pressing button '{button.name}': {result.stderr}") return f"Button '{button.name}' has been pressed."
- src/espresso_mcp/server.py:227-236 (schema)Enum defining the input parameter 'button' types with their corresponding Android keyevent codes.class Button(Enum): HOME = "3" BACK = "4" MENU = "82" POWER = "26" VOLUME_UP = "24" VOLUME_DOWN = "25" CAMERA = "27" ENTER = "66"