mobile_swipe
Execute swipe gestures on Android screens by specifying start and end coordinates with customizable duration for navigation and interaction.
Instructions
Perform a swipe gesture on the Android screen.
Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate duration: Duration of swipe in seconds (default: 0.5)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| duration | No | ||
| end_x | Yes | ||
| end_y | Yes | ||
| start_x | Yes | ||
| start_y | Yes |
Input Schema (JSON Schema)
{
"properties": {
"duration": {
"default": 0.5,
"type": "number"
},
"end_x": {
"type": "integer"
},
"end_y": {
"type": "integer"
},
"start_x": {
"type": "integer"
},
"start_y": {
"type": "integer"
}
},
"required": [
"start_x",
"start_y",
"end_x",
"end_y"
],
"type": "object"
}
Implementation Reference
- main.py:188-207 (handler)The handler function for the 'mobile_swipe' tool, decorated with @mcp.tool() for registration. It performs a swipe gesture on the Android device screen using shell command.@mcp.tool() def mobile_swipe(start_x: int, start_y: int, end_x: int, end_y: int, duration: float = 0.5) -> str: """Perform a swipe gesture on the Android screen. Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate duration: Duration of swipe in seconds (default: 0.5) """ if device is None: return "Error: Device not initialized. Please call mobile_init() first to establish connection with Android device." try: duration_ms = int(duration * 1000) cmd = f"input swipe {start_x} {start_y} {end_x} {end_y} {duration_ms}" device.shell(cmd) return f"Successfully swiped from ({start_x}, {start_y}) to ({end_x}, {end_y}) in {duration}s" except Exception as e: return f"Error swiping: {str(e)}"