swipe
Perform swipe gestures on Android device screens for navigation and interaction automation by specifying start and end coordinates.
Instructions
Perform a swipe gesture on the screen
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_x | Yes | Start X coordinate | |
| start_y | Yes | Start Y coordinate | |
| end_x | Yes | End X coordinate | |
| end_y | Yes | End Y coordinate | |
| duration_ms | No | Swipe duration in ms (default 300) | |
| device_id | No | Device ID (optional if only one device) |
Implementation Reference
- src/adb.ts:299-310 (handler)The actual implementation of the swipe logic using adb shell commands.
async swipe( x1: number, y1: number, x2: number, y2: number, durationMs?: number, deviceId?: string, ): Promise<void> { const args = ["shell", "input", "swipe", String(x1), String(y1), String(x2), String(y2)]; if (durationMs !== undefined) args.push(String(durationMs)); await this.exec(args, deviceId); } - src/index.ts:336-358 (registration)The MCP tool registration and handler definition for the "swipe" tool.
server.tool( "swipe", "Perform a swipe gesture on the screen", { start_x: z.number().describe("Start X coordinate"), start_y: z.number().describe("Start Y coordinate"), end_x: z.number().describe("End X coordinate"), end_y: z.number().describe("End Y coordinate"), duration_ms: z.number().optional().default(300).describe("Swipe duration in ms (default 300)"), device_id: z.string().optional().describe("Device ID (optional if only one device)"), }, async ({ start_x, start_y, end_x, end_y, duration_ms, device_id }) => { await adb.swipe(start_x, start_y, end_x, end_y, duration_ms, device_id); return { content: [ { type: "text", text: `Swiped from (${start_x},${start_y}) to (${end_x},${end_y}) over ${duration_ms}ms`, }, ], }; }, );