Skip to main content
Glama

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
NameRequiredDescriptionDefault
directionYes
durationNo

Implementation Reference

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

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/vs4vijay/espresso-mcp'

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