get_booted_sim_id
Identify the booted iOS simulator by retrieving its ID, enabling targeted control and automation.
Instructions
Get the ID of the currently booted iOS simulator
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:216-242 (handler)The handler function for 'get_booted_sim_id'. Calls getBootedDevice() and returns the booted simulator's name and UUID.
async () => { try { const { id, name } = await getBootedDevice(); return { isError: false, content: [ { type: "text", text: `Booted Simulator: "${name}". UUID: "${id}"`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error: ${toError(error).message}` ), }, ], }; } } - src/index.ts:211-243 (registration)Registration of the 'get_booted_sim_id' tool on the MCP server, with conditional filtering and the tool's name and description.
if (!isToolFiltered("get_booted_sim_id")) { server.tool( "get_booted_sim_id", "Get the ID of the currently booted iOS simulator", { title: "Get Booted Simulator ID", readOnlyHint: true, openWorldHint: true }, async () => { try { const { id, name } = await getBootedDevice(); return { isError: false, content: [ { type: "text", text: `Booted Simulator: "${name}". UUID: "${id}"`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error: ${toError(error).message}` ), }, ], }; } } ); - src/index.ts:170-193 (helper)getBootedDevice() helper function that runs 'xcrun simctl list devices' and parses the output to find the booted simulator's UUID and name.
async function getBootedDevice() { const { stdout, stderr } = await run("xcrun", ["simctl", "list", "devices"]); if (stderr) throw new Error(stderr); // Parse the output to find booted device const lines = stdout.split("\n"); for (const line of lines) { if (line.includes("Booted")) { // Extract the UUID - it's inside parentheses const match = line.match(/\(([-0-9A-F]+)\)/); if (match) { const deviceId = match[1]; const deviceName = line.split("(")[0].trim(); return { name: deviceName, id: deviceId, }; } } } throw Error("No booted simulator found"); } - src/index.ts:195-208 (helper)getBootedDeviceId() helper that resolves a device ID; if none provided, calls getBootedDevice() to get the booted simulator.
async function getBootedDeviceId( deviceId: string | undefined ): Promise<string> { // If deviceId not provided, get the currently booted simulator let actualDeviceId = deviceId; if (!actualDeviceId) { const { id } = await getBootedDevice(); actualDeviceId = id; } if (!actualDeviceId) { throw new Error("No booted simulator found and no deviceId provided"); } return actualDeviceId; } - src/index.ts:215-215 (schema)Schema/input definition for the tool: no user-input parameters, only metadata fields title, readOnlyHint, openWorldHint.
{ title: "Get Booted Simulator ID", readOnlyHint: true, openWorldHint: true },