tap_relative
Tap on iOS Simulator screens using relative coordinates to automate testing and control devices. Specify X and Y positions between 0 and 1 for precise interaction.
Instructions
Tap using relative coordinates (rx, ry) in [0,1] where (0.5, 0.5) is center.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rx | Yes | Relative X in [0,1] | |
| ry | Yes | Relative Y in [0,1] | |
| udid | No | Simulator UDID (optional, defaults to booted simulator) |
Implementation Reference
- src/index.ts:761-775 (handler)Implementation of the tap_relative tool logic.
private async tapRelative(rx: number, ry: number, udid?: string) { if (!Number.isFinite(rx) || !Number.isFinite(ry) || rx < 0 || rx > 1 || ry < 0 || ry > 1) { throw new McpError( ErrorCode.InvalidRequest, 'rx and ry must be finite numbers between 0 and 1.' ); } const target = await resolveUdid(udid); try { const size = await this.getScreenSize(target); const x = Math.round(size.width * rx); const y = Math.round(size.height * ry); await execAsync(`idb ui tap --udid ${target} ${x} ${y}`); - src/index.ts:383-395 (schema)Tool registration and schema definition for tap_relative.
{ name: 'tap_relative', description: 'Tap using relative coordinates (rx, ry) in [0,1] where (0.5, 0.5) is center.', inputSchema: { type: 'object', properties: { rx: { type: 'number', description: 'Relative X in [0,1]' }, ry: { type: 'number', description: 'Relative Y in [0,1]' }, udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' }, }, required: ['rx', 'ry'], additionalProperties: false, },