swipe
Perform swipe gestures on Android screens to scroll content, navigate between pages, or execute drag actions by specifying start and end coordinates.
Instructions
Swipe from one point to another on the Android screen. Useful for scrolling, swiping between pages, or drag gestures.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x1 | Yes | Start X coordinate | |
| y1 | Yes | Start Y coordinate | |
| x2 | Yes | End X coordinate | |
| y2 | Yes | End Y coordinate | |
| duration | No | Swipe duration in milliseconds (default: 300) | |
| device_id | No | Device serial number |
Implementation Reference
- src/adb/input-controller.ts:52-79 (handler)The actual implementation of the swipe logic using ADB commands.
export async function swipe( x1: number, y1: number, x2: number, y2: number, durationMs: number = 300, deviceId?: string ): Promise<{ from: { x: number; y: number }; to: { x: number; y: number } }> { const resolved = await deviceManager.resolveDeviceId(deviceId); deviceManager.checkRateLimit(resolved); const from = await normalizeCoordinates(x1, y1, resolved); const to = await normalizeCoordinates(x2, y2, resolved); validateCoordinate(from.x, 'x1'); validateCoordinate(from.y, 'y1'); validateCoordinate(to.x, 'x2'); validateCoordinate(to.y, 'y2'); await adbShell([ 'input', 'swipe', String(from.x), String(from.y), String(to.x), String(to.y), String(Math.round(durationMs)), ], resolved); deviceManager.touchSession(resolved); log.info('Swipe performed', { from, to, durationMs, deviceId: resolved }); return { from, to }; } - src/controllers/input-tools.ts:85-125 (registration)The registration of the 'swipe' tool in the MCP server, including the handler wrapper and input schema.
server.registerTool( 'swipe', { description: 'Swipe from one point to another on the Android screen. Useful for scrolling, swiping between pages, or drag gestures.', inputSchema: { x1: z.number().describe('Start X coordinate'), y1: z.number().describe('Start Y coordinate'), x2: z.number().describe('End X coordinate'), y2: z.number().describe('End Y coordinate'), duration: z.number().optional().default(300).describe('Swipe duration in milliseconds (default: 300)'), device_id: z.string().optional().describe('Device serial number'), }, }, async ({ x1, y1, x2, y2, duration, device_id }) => { return await metrics.measure('swipe', device_id || 'default', async () => { const resolved = await deviceManager.resolveDeviceId(device_id); const execCtx = executionEngine.preExecutionCheck('swipe', { x1, y1, x2, y2, duration }, resolved); if (!execCtx.allowed) { return { content: [{ type: 'text' as const, text: JSON.stringify({ success: false, blocked: true, reason: execCtx.blockReason, _context: execCtx.recentContext, }, null, 2), }], }; } const preHash = await capturePreActionState(resolved); const result = await swipe(x1, y1, x2, y2, duration, device_id); invalidateCaches(resolved); const verification = await verifyAction('swipe', resolved, preHash); return buildVerifiedResponse({ swipe: result }, execCtx, verification); }); } );