ui_type
Input text into the iOS Simulator to automate typing in test scenarios.
Instructions
Input text into the iOS Simulator
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| udid | No | Udid of target, can also be set with the IDB_UDID env var | |
| text | Yes | Text to input |
Implementation Reference
- src/index.ts:405-443 (handler)The handler function for the 'ui_type' tool. It accepts `udid` (optional) and `text` parameters, resolves the device ID via `getBootedDeviceId`, invokes `idb ui text --udid <udid> -- <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:392-403 (schema)Zod schema definition for the 'ui_type' tool. Defines two inputs: `udid` (optional, matches UDID_REGEX) and `text` (required, max 500 chars, ASCII printable only via regex).
{ 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:388-444 (registration)Registration of the 'ui_type' tool on the MCP server. Wrapped in a filter guard (`isToolFiltered`). Calls `server.tool("ui_type", ...)` with description, schema, metadata (title, readOnlyHint, openWorldHint), and the 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"), }, { title: "UI Type", readOnlyHint: false, openWorldHint: true }, 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 }` ), }, ], }; } } ); }