swipe
Execute swipe gestures on iOS simulators by specifying start and end coordinates, enabling precise screen navigation and interaction automation for testing and development workflows.
Instructions
Perform a swipe gesture from one coordinate to another
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_x | Yes | Start X coordinate in points | |
| from_y | Yes | Start Y coordinate in points | |
| to_x | Yes | End X coordinate in points | |
| to_y | Yes | End Y coordinate in points | |
| duration_ms | No | Swipe duration in milliseconds (default: 500) | |
| udid | No | Simulator UDID (optional, defaults to booted simulator) |
Implementation Reference
- src/index.ts:801-818 (handler)The handler method that implements the 'swipe' gesture using 'idb'.
private async swipe( fromX: number, fromY: number, toX: number, toY: number, durationMs?: number, udid?: string ) { const target = await resolveUdid(udid); const durationSec = ((durationMs ?? 500) / 1000).toFixed(3); try { await execAsync(`idb ui swipe --udid ${target} ${fromX} ${fromY} ${toX} ${toY} --duration ${durationSec}`); return { content: [{ type: 'text', text: `Swiped (${fromX},${fromY}) to (${toX},${toY}) over ${durationMs ?? 500}ms on ${target}` }], }; } catch (error: any) { throw new McpError(ErrorCode.InternalError, `Failed to swipe: ${error.message}`); } - src/index.ts:411-425 (schema)The tool definition and schema for 'swipe'.
name: 'swipe', description: 'Perform a swipe gesture from one coordinate to another', inputSchema: { type: 'object', properties: { from_x: { type: 'number', description: 'Start X coordinate in points' }, from_y: { type: 'number', description: 'Start Y coordinate in points' }, to_x: { type: 'number', description: 'End X coordinate in points' }, to_y: { type: 'number', description: 'End Y coordinate in points' }, duration_ms: { type: 'number', description: 'Swipe duration in milliseconds (default: 500)' }, udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' }, }, required: ['from_x', 'from_y', 'to_x', 'to_y'], additionalProperties: false, }, - src/index.ts:526-527 (registration)The tool dispatch logic for 'swipe'.
case 'swipe': return this.swipe(args.from_x, args.from_y, args.to_x, args.to_y, args.duration_ms, args.udid);