get_booted_sim_id
Retrieve the ID of the currently active iOS simulator for streamlined simulator management and testing workflows.
Instructions
Get the ID of the currently booted iOS simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:161-187 (handler)Inline anonymous async handler function for the 'get_booted_sim_id' tool. Retrieves the booted simulator details using getBootedDevice() and returns the name and UUID, or an error message.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:157-189 (registration)Registers the 'get_booted_sim_id' tool on the MCP server using server.tool(), including name, description, and handler function, conditionally if not filtered.if (!isToolFiltered("get_booted_sim_id")) { server.tool( "get_booted_sim_id", "Get the ID of the currently booted iOS simulator", 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:116-139 (helper)Helper function getBootedDevice() that runs 'xcrun simctl list devices', parses the output to find the booted simulator, and returns its name and ID (UUID).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"); }