Skip to main content
Glama

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
NameRequiredDescriptionDefault
buttonYes

Implementation Reference

  • 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."
  • 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"

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/vs4vijay/espresso-mcp'

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