swipe
Execute swipe gestures in specified directions on Android devices connected to espresso-mcp. Define direction and duration to simulate precise touch interactions for testing or automation tasks.
Instructions
Perform a swipe gesture in a specific direction on the connected Android device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | Yes | ||
| duration | No |
Implementation Reference
- src/espresso_mcp/server.py:330-362 (handler)The 'swipe' tool handler: defines the function decorated with @mcp.tool(), maps direction to start/end coordinates, executes adb shell input swipe, handles errors, and returns success message.@mcp.tool() def swipe(direction: str, duration: int = 500) -> str: """Perform a swipe gesture in a specific direction on the connected Android device""" directions = { "up": (500, 1500, 500, 500), "down": (500, 500, 500, 1500), "left": (1500, 500, 500, 500), "right": (500, 500, 1500, 500), } if direction not in directions: raise ValueError( f"Invalid direction '{direction}'. Valid directions are: {list(directions.keys())}" ) start_x, start_y, end_x, end_y = directions[direction] result = subprocess.run( [ "adb", "shell", "input", "swipe", str(start_x), str(start_y), str(end_x), str(end_y), str(duration), ], capture_output=True, text=True, ) if result.returncode != 0: raise RuntimeError(f"Error performing swipe: {result.stderr}") return f"Swipe gesture performed in '{direction}' direction over {duration}ms."