get_booted_sim_id
Retrieve the ID of the currently running iOS simulator to identify active devices for testing and debugging.
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:157-189 (registration)Registration of the 'get_booted_sim_id' tool using server.tool(), including the inline handler function that calls getBootedDevice() to retrieve and return the booted simulator ID.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 executes 'xcrun simctl list devices', parses the output to find the booted simulator, extracts its name and UUID (ID), and returns them.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"); }