Skip to main content
Glama

press

Tap or long press on specific screen coordinates to interact with Android UI elements during automated testing and device control.

Instructions

Tap on specific coordinates on the Android screen. Use duration for long press (in milliseconds).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNo
durationNo
xYes
yYes

Implementation Reference

  • The handler function for the MCP tool 'press'. It performs a tap at the specified coordinates (x, y) on an Android device/emulator. If a duration is provided, it executes a long press using a swipe gesture from the point to itself. Uses ADB shell input commands via subprocess.
    @mcp.tool()
    async def press(x: int, y: int, device_id: str = None, duration: int = None) -> dict:
        """Tap on specific coordinates on the Android screen. Use duration for long press (in milliseconds)."""
        try:
            # Validate coordinates
            if x < 0 or y < 0:
                return {
                    "success": False,
                    "error": "Coordinates must be positive integers",
                    "x": x,
                    "y": y
                }
    
            # Build adb command
            cmd = ['adb']
            if device_id:
                cmd.extend(['-s', device_id])
    
            if duration and duration > 0:
                # Long press using swipe command (swipe from point to same point with duration)
                cmd.extend(['shell', 'input', 'swipe', str(x), str(y), str(x), str(y), str(duration)])
                action_type = f"long press ({duration}ms)"
            else:
                # Regular tap
                cmd.extend(['shell', 'input', 'tap', str(x), str(y)])
                action_type = "tap"
    
            # Execute tap command
            subprocess.run(cmd, capture_output=True, text=True, check=True)
    
            return {
                "success": True,
                "message": f"Successfully executed {action_type} at coordinates ({x}, {y})",
                "x": x,
                "y": y,
                "action_type": action_type,
                "device_id": device_id or "default"
            }
    
        except subprocess.CalledProcessError as e:
            return {
                "success": False,
                "error": f"Failed to execute tap: {e}",
                "stderr": e.stderr if e.stderr else "",
                "x": x,
                "y": y
            }
        except FileNotFoundError:
            return {
                "success": False,
                "error": "ADB not found. Please ensure Android SDK is installed and adb is in PATH.",
                "x": x,
                "y": y
            }
        except Exception as e:
            return {
                "success": False,
                "error": f"Unexpected error: {e}",
                "x": x,
                "y": y
            }
  • puppeteer.py:448-448 (registration)
    The @mcp.tool() decorator registers the 'press' function as an MCP tool, using FastMCP. The tool name is derived from the function name 'press'.
    @mcp.tool()
  • Input schema defined by function parameters: x (int, required), y (int, required), device_id (str, optional), duration (int, optional). Returns dict with success status, message, coordinates, etc. Docstring provides description.
    async def press(x: int, y: int, device_id: str = None, duration: int = None) -> dict:
        """Tap on specific coordinates on the Android screen. Use duration for long press (in milliseconds)."""
Behavior2/5

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

With no annotations provided, the description carries full burden but only partially discloses behavior. It mentions the duration parameter for long press but doesn't cover critical aspects like whether this requires device connection, what happens if coordinates are invalid, or if there are side effects. More behavioral context is needed for a mutation tool.

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 with two sentences that directly address the tool's function and key parameter usage. Every word serves a purpose, and it's front-loaded with the core action, making it efficient and easy to parse.

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 complexity of a screen interaction tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks information about error conditions, required device state, return values, or how it differs from similar tools like 'long_press'. More context is needed for safe and effective 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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful context for the 'duration' parameter (explaining it's for long press in milliseconds), which isn't evident from the schema alone. However, it doesn't explain 'x' and 'y' coordinates or 'device_id', leaving some parameters under-specified.

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 ('Tap on specific coordinates') and the resource ('Android screen'), making the purpose immediately understandable. It distinguishes from siblings like 'long_press' by mentioning duration for long press, though it doesn't explicitly contrast with all alternatives like 'swipe' or 'scroll_element'.

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

Usage Guidelines3/5

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

The description implies when to use this tool ('Use duration for long press') but doesn't provide explicit guidance on when to choose 'press' versus 'long_press' or other interaction tools like 'swipe'. No exclusions or prerequisites are mentioned, leaving usage context somewhat vague.

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/pedro-rivas/android-puppeteer-mcp'

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