swipe
Execute swipe gestures on Android devices to navigate interfaces or scroll content using directional inputs and customizable timing.
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 main handler function for the 'swipe' tool, decorated with @mcp.tool() for automatic registration. It performs swipe gestures on an Android device using ADB's input swipe command based on direction (up, down, left, right) and duration.@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."