list_sims
Retrieve a list of available iOS simulators along with their UUIDs to streamline testing and development workflows. Enable the tool to access simulator details efficiently.
Instructions
Lists available iOS simulators with their UUIDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| enabled | Yes |
Implementation Reference
- src/tools/simulator.ts:102-179 (handler)The core handler function that implements the logic for the 'list_sims' tool. It runs 'xcrun simctl list devices available --json', parses the JSON to extract available simulators' names and UUIDs, formats a human-readable list, and suggests next steps.async (): Promise<ToolResponse> => { log('info', 'Starting xcrun simctl list devices request'); try { const command = ['xcrun', 'simctl', 'list', 'devices', 'available', '--json']; const result = await executeCommand(command, 'List Simulators'); if (!result.success) { return { content: [ { type: 'text', text: `Failed to list simulators: ${result.error}`, }, ], }; } try { const simulatorsData = JSON.parse(result.output); let responseText = 'Available iOS Simulators:\n\n'; for (const runtime in simulatorsData.devices) { const devices = simulatorsData.devices[runtime]; if (devices.length === 0) continue; responseText += `${runtime}:\n`; for (const device of devices) { if (device.isAvailable) { responseText += `- ${device.name} (${device.udid})${device.state === 'Booted' ? ' [Booted]' : ''}\n`; } } responseText += '\n'; } responseText += 'Next Steps:\n'; responseText += "1. Boot a simulator: boot_sim({ simulatorUuid: 'UUID_FROM_ABOVE' })\n"; responseText += '2. Open the simulator UI: open_sim({ enabled: true })\n'; responseText += "3. Build for simulator: build_ios_sim_id_proj({ scheme: 'YOUR_SCHEME', simulatorId: 'UUID_FROM_ABOVE' })\n"; // Example using project variant responseText += "4. Get app path: get_sim_app_path_id_proj({ scheme: 'YOUR_SCHEME', platform: 'iOS Simulator', simulatorId: 'UUID_FROM_ABOVE' })"; // Example using project variant return { content: [ { type: 'text', text: responseText, }, ], }; } catch { return { content: [ { type: 'text', text: result.output, }, ], }; } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log('error', `Error listing simulators: ${errorMessage}`); return { content: [ { type: 'text', text: `Failed to list simulators: ${errorMessage}`, }, ], }; } }, );
- src/tools/simulator.ts:99-101 (schema)Zod schema for the input parameters of the 'list_sims' tool. Defines an optional 'enabled' boolean parameter.{ enabled: z.boolean(), },
- src/tools/simulator.ts:95-180 (registration)The registration function for the 'list_sims' tool, called by the main registerTools to add the tool to the MCP server.export function registerListSimulatorsTool(server: McpServer): void { server.tool( 'list_sims', 'Lists available iOS simulators with their UUIDs. ', { enabled: z.boolean(), }, async (): Promise<ToolResponse> => { log('info', 'Starting xcrun simctl list devices request'); try { const command = ['xcrun', 'simctl', 'list', 'devices', 'available', '--json']; const result = await executeCommand(command, 'List Simulators'); if (!result.success) { return { content: [ { type: 'text', text: `Failed to list simulators: ${result.error}`, }, ], }; } try { const simulatorsData = JSON.parse(result.output); let responseText = 'Available iOS Simulators:\n\n'; for (const runtime in simulatorsData.devices) { const devices = simulatorsData.devices[runtime]; if (devices.length === 0) continue; responseText += `${runtime}:\n`; for (const device of devices) { if (device.isAvailable) { responseText += `- ${device.name} (${device.udid})${device.state === 'Booted' ? ' [Booted]' : ''}\n`; } } responseText += '\n'; } responseText += 'Next Steps:\n'; responseText += "1. Boot a simulator: boot_sim({ simulatorUuid: 'UUID_FROM_ABOVE' })\n"; responseText += '2. Open the simulator UI: open_sim({ enabled: true })\n'; responseText += "3. Build for simulator: build_ios_sim_id_proj({ scheme: 'YOUR_SCHEME', simulatorId: 'UUID_FROM_ABOVE' })\n"; // Example using project variant responseText += "4. Get app path: get_sim_app_path_id_proj({ scheme: 'YOUR_SCHEME', platform: 'iOS Simulator', simulatorId: 'UUID_FROM_ABOVE' })"; // Example using project variant return { content: [ { type: 'text', text: responseText, }, ], }; } catch { return { content: [ { type: 'text', text: result.output, }, ], }; } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log('error', `Error listing simulators: ${errorMessage}`); return { content: [ { type: 'text', text: `Failed to list simulators: ${errorMessage}`, }, ], }; } }, ); }
- src/utils/register-tools.ts:124-127 (registration)Configuration entry in the toolRegistrations array that conditionally registers the list_sims tool via registerListSimulatorsTool based on environment variable.register: registerListSimulatorsTool, groups: [ToolGroup.SIMULATOR_MANAGEMENT, ToolGroup.PROJECT_DISCOVERY], envVar: 'XCODEBUILDMCP_TOOL_LIST_SIMULATORS', },