adb_swipe
Perform screen swipes on Android devices by defining start and end coordinates. Specify swipe duration and device ID to automate touch interactions via ADB MCP Server.
Instructions
Swipe from one point to another on the device screen
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | No | Device ID (optional) | |
| duration | No | Swipe duration in milliseconds (default: 300) | |
| x1 | Yes | Start X coordinate | |
| x2 | Yes | End X coordinate | |
| y1 | Yes | Start Y coordinate | |
| y2 | Yes | End Y coordinate |
Implementation Reference
- src/tools/screen.ts:139-188 (handler)The main handler function for the adb_swipe tool, which executes the ADB 'input swipe' command with the provided coordinates and duration.async swipe(options: SwipeOptions) { try { const { x1, y1, x2, y2, deviceId, duration = 300 } = options; if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) { return { success: false, error: 'Invalid coordinates', message: 'All coordinates must be positive numbers' }; } const connected = await this.adbClient.isDeviceConnected(deviceId); if (!connected) { return { success: false, error: 'Device not connected', message: 'Cannot perform swipe - device is not connected' }; } const command = `shell input swipe ${x1} ${y1} ${x2} ${y2} ${duration}`; const result = await this.adbClient.executeCommand(command, deviceId); if (!result.success) { return { success: false, error: result.error, message: 'Failed to perform swipe' }; } return { success: true, data: { from: { x: x1, y: y1 }, to: { x: x2, y: y2 }, duration, deviceId: deviceId || this.adbClient.getDefaultDevice() }, message: `Swiped from (${x1}, ${y1}) to (${x2}, ${y2})` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to perform swipe' }; } }
- src/index.ts:130-163 (schema)The input schema definition for the adb_swipe tool as registered in the MCP listTools response.{ name: 'adb_swipe', description: 'Swipe from one point to another on the device screen', inputSchema: { type: 'object', properties: { x1: { type: 'number', description: 'Start X coordinate', }, y1: { type: 'number', description: 'Start Y coordinate', }, x2: { type: 'number', description: 'End X coordinate', }, y2: { type: 'number', description: 'End Y coordinate', }, duration: { type: 'number', description: 'Swipe duration in milliseconds (default: 300)', }, deviceId: { type: 'string', description: 'Device ID (optional)', }, }, required: ['x1', 'y1', 'x2', 'y2'], }, },
- src/index.ts:445-446 (registration)The switch case registration that dispatches calls to the adb_swipe tool to the ScreenTools.swipe handler.case 'adb_swipe': return await this.handleToolCall(this.screenTools.swipe(args as any));
- src/types/index.ts:22-29 (schema)TypeScript interface defining the SwipeOptions used by the handler, matching the input schema.export interface SwipeOptions { deviceId?: string; x1: number; y1: number; x2: number; y2: number; duration?: number; }