ui_type
Input text directly into the iOS Simulator using a specified UDID. Simplifies interaction by enabling precise text entry for UI testing and automation.
Instructions
Input text into the iOS Simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to input | |
| udid | No | Udid of target, can also be set with the IDB_UDID env var |
Implementation Reference
- src/index.ts:346-384 (handler)The handler function for the 'ui_type' tool. It resolves the simulator UDID if not provided, executes the 'idb ui text' command with the input text, and returns success or error response.async ({ udid, text }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "text", "--udid", actualUdid, // 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. "--", text ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Typed successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error typing text into the iOS Simulator: ${ toError(error).message }` ), }, ], }; } } );
- src/index.ts:334-345 (schema)Zod schema for input validation: optional UDID matching UUID pattern, and text limited to 500 printable ASCII characters.{ udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), text: z .string() .max(500) .regex(/^[\x20-\x7E]+$/) .describe("Text to input"), },
- src/index.ts:330-385 (registration)Conditional registration of the 'ui_type' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.if (!isToolFiltered("ui_type")) { server.tool( "ui_type", "Input text into the iOS Simulator", { udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), text: z .string() .max(500) .regex(/^[\x20-\x7E]+$/) .describe("Text to input"), }, async ({ udid, text }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "text", "--udid", actualUdid, // 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. "--", text ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Typed successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error typing text into the iOS Simulator: ${ toError(error).message }` ), }, ], }; } } ); }