Skip to main content
Glama

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
NameRequiredDescriptionDefault
durationNoPress duration
udidNoUdid of target, can also be set with the IDB_UDID env var
xYesThe x-coordinate
yYesThe x-coordinate

Implementation Reference

  • 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}` ), }, ], }; } }
  • 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}` ), }, ], }; } } ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/joshuayoes/ios-simulator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server