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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions pressing buttons but doesn't cover critical aspects like required device state, permissions, side effects, or error handling. This is a significant gap for a tool that likely interacts with an Android device.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with a clear purpose statement, followed by parameter examples in a structured Args section. It's efficient with minimal waste, though it could be slightly more concise by integrating the Args into the main text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (interacting with an Android device), no annotations, and an output schema present, the description is somewhat complete but lacks details on behavioral context and usage guidelines. The output schema reduces the need to explain return values, but more device-specific info would help.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, but the description adds value by listing example button names (BACK, HOME, RECENT, ENTER) in the Args section. However, it doesn't fully compensate for the lack of schema details, such as whether other buttons are allowed or the format constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Press') and target ('physical or virtual button on the Android device'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'mobile_click' or 'mobile_type', which might involve similar interactions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'mobile_click' or 'mobile_type'. The description implies button-pressing scenarios but lacks explicit context or exclusions, leaving usage unclear relative to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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