Skip to main content
Glama

mobile_key_press

Press physical or virtual buttons on Android devices to navigate interfaces, return to home screens, access recent apps, or confirm actions during mobile automation tasks.

Instructions

Press a physical or virtual button on the Android device.

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

Input Schema

NameRequiredDescriptionDefault
buttonYes

Input Schema (JSON Schema)

{ "properties": { "button": { "type": "string" } }, "required": [ "button" ], "type": "object" }

Implementation Reference

  • main.py:164-186 (handler)
    Implementation of the mobile_key_press tool handler. Maps button names to keys and presses them using the uiautomator2 device.press method. Includes error handling and device check.
    @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