Skip to main content
Glama
rahulkr
by rahulkr

press_back

Simulate pressing the back button on an Android device to navigate within apps or return to previous screens during development and testing.

Instructions

Press the back button

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function for the press_back tool. Registered via @mcp.tool() decorator. Executes by calling press_key helper with BACK key.
    @mcp.tool()
    def press_back(device_serial: str | None = None) -> str:
        """Press the back button"""
        return press_key("BACK", device_serial)
  • Core helper function that maps key names to Android keycodes and executes the input keyevent ADB command. Directly used by press_back to simulate the BACK button press.
    @mcp.tool()
    def press_key(keycode: str, device_serial: str | None = None) -> str:
        """
        Press a key by keycode name or number.
        
        Common keycodes:
        - HOME (3), BACK (4), CALL (5), ENDCALL (6)
        - VOLUME_UP (24), VOLUME_DOWN (25), POWER (26)
        - CAMERA (27), ENTER (66), DEL/BACKSPACE (67)
        - TAB (61), SPACE (62), MENU (82)
        - SEARCH (84), MEDIA_PLAY_PAUSE (85)
        - PAGE_UP (92), PAGE_DOWN (93)
        """
        # Handle common names
        key_map = {
            'HOME': '3', 'BACK': '4', 'ENTER': '66', 'DELETE': '67', 'DEL': '67',
            'TAB': '61', 'SPACE': '62', 'MENU': '82', 'SEARCH': '84',
            'VOLUME_UP': '24', 'VOLUME_DOWN': '25', 'POWER': '26',
            'PAGE_UP': '92', 'PAGE_DOWN': '93', 'ESCAPE': '111', 'ESC': '111'
        }
        
        key = key_map.get(keycode.upper(), keycode)
        return run_adb(["shell", "input", "keyevent", key], device_serial)
  • The @mcp.tool() decorator registers the press_back function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Press the back button' implies a UI interaction that may affect app state or navigation, but it doesn't describe what happens (e.g., navigates to previous screen, closes dialogs), whether it requires specific device states, or potential side effects. For a tool with zero annotation coverage, this is inadequate.

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

Conciseness5/5

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

The description is extremely concise at just three words, with zero wasted language. It's front-loaded with the core action and target. Every word earns its place, making it easy to parse quickly.

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

Completeness2/5

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

Given the tool's simplicity (single optional parameter) and the presence of an output schema (which means return values are documented elsewhere), the description could be adequate. However, with no annotations and 0% schema description coverage, the description fails to provide essential context about behavior, usage, or parameter meaning. It's incomplete for effective agent use.

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

Parameters4/5

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

The tool has only one parameter (device_serial), and schema description coverage is 0%, meaning the schema provides no description of this parameter. The description doesn't mention parameters at all, which is acceptable for a tool with zero parameters but problematic here. However, since there's only one parameter and its purpose (identifying target device) is somewhat inferable from context, the description gets a baseline 4 rather than lower.

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

Purpose3/5

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

The description 'Press the back button' clearly states the action (press) and target (back button), which is a specific verb+resource combination. However, it doesn't differentiate from sibling tools like press_home, press_recent_apps, or press_key, which all perform similar 'press' actions on different targets. The purpose is understandable but lacks sibling differentiation.

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?

The description provides no guidance about when to use this tool versus alternatives. There's no mention of context (e.g., navigating back in an app vs. using other navigation methods), prerequisites, or exclusions. Given the sibling tools include various navigation and interaction methods, this lack of guidance is a significant gap.

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/rahulkr/r_adb_mcp_server'

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