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)."""

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