Skip to main content
Glama

mobile_key_press

Press physical or virtual buttons on Android devices to navigate interfaces, trigger actions, or control applications during automation tasks.

Instructions

Press a physical or virtual button on the Android device.

Args: button: Button name (BACK, HOME, RECENT, ENTER)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
buttonYes

Implementation Reference

  • main.py:164-186 (handler)
    The core handler function for the 'mobile_key_press' tool. It is decorated with @mcp.tool() for automatic registration in FastMCP. The function maps button names to uiautomator2 keys and presses the button on the connected Android device, with error handling for uninitialized device.
    @mcp.tool() def mobile_key_press(button: str) -> str: """Press a physical or virtual button on the Android device. Args: button: Button name (BACK, HOME, RECENT, ENTER) """ if device is None: return "Error: Device not initialized. Please call mobile_init() first to establish connection with Android device." button_map = { "BACK": "back", "HOME": "home", "RECENT": "recent", "ENTER": "enter" } key = button_map.get(button.upper(), button.lower()) try: device.press(key) return f"Successfully pressed {button} button" except Exception as e: return f"Error pressing {button} button: {str(e)}"

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/erichung9060/Android-Mobile-MCP'

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