ui_tap
Tap on screen coordinates in iOS Simulator to simulate user interactions for testing and automation purposes.
Instructions
Tap on the screen in the iOS Simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| duration | No | Press duration | |
| udid | No | Udid of target, can also be set with the IDB_UDID env var | |
| x | Yes | The x-coordinate | |
| y | Yes | The x-coordinate |
Implementation Reference
- src/index.ts:288-326 (handler)The asynchronous handler function for the 'ui_tap' tool. It resolves the device UDID if not provided, executes the 'idb ui tap' command with the given coordinates and optional duration, checks for errors, and returns success or error content.async ({ duration, udid, x, y }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "tap", "--udid", actualUdid, ...(duration ? ["--duration", duration] : []), "--json", // When passing user-provided values to a command, it's crucial to use `--` // to separate the command's options from positional arguments. // This prevents the shell from misinterpreting the arguments as options. "--", String(x), String(y) ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Tapped successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error tapping on the screen: ${toError(error).message}` ), }, ], }; } }
- src/index.ts:274-287 (schema)Zod schema defining the input parameters for the 'ui_tap' tool: optional duration (string matching number regex), optional udid (UUID regex), required x and y coordinates (numbers).{ duration: z .string() .regex(/^\d+(\.\d+)?$/) .optional() .describe("Press duration"), udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), x: z.number().describe("The x-coordinate"), y: z.number().describe("The x-coordinate"), },
- src/index.ts:270-328 (registration)Registration of the 'ui_tap' tool on the McpServer instance, conditional on not being filtered by environment variable IOS_SIMULATOR_MCP_FILTERED_TOOLS. Includes tool name, description, input schema, and handler function.if (!isToolFiltered("ui_tap")) { server.tool( "ui_tap", "Tap on the screen in the iOS Simulator", { duration: z .string() .regex(/^\d+(\.\d+)?$/) .optional() .describe("Press duration"), udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), x: z.number().describe("The x-coordinate"), y: z.number().describe("The x-coordinate"), }, async ({ duration, udid, x, y }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "tap", "--udid", actualUdid, ...(duration ? ["--duration", duration] : []), "--json", // When passing user-provided values to a command, it's crucial to use `--` // to separate the command's options from positional arguments. // This prevents the shell from misinterpreting the arguments as options. "--", String(x), String(y) ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Tapped successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error tapping on the screen: ${toError(error).message}` ), }, ], }; } } ); }