MCPcopy Create free account
hub / github.com/getsentry/XcodeBuildMCP / listSimulators

Function listSimulators

src/mcp/tools/simulator/list_sims.ts:75–112  ·  view source on GitHub ↗
(
  executor: CommandExecutor,
  options: { enabled?: boolean } = {},
)

Source from the content-addressed store, hash-verified

73}
74
75export async function listSimulators(
76 executor: CommandExecutor,
77 options: { enabled?: boolean } = {},
78): Promise<ListedSimulator[]> {
79 const result = await executor(
80 ['xcrun', 'simctl', 'list', 'devices', '--json'],
81 'List Simulators',
82 false,
83 );
84
85 if (!result.success) {
86 throw new Error(`Failed to list simulators: ${result.error}`);
87 }
88
89 const parsedData: unknown = JSON.parse(result.output);
90 if (!isSimulatorData(parsedData)) {
91 throw new Error('Unexpected simctl output format');
92 }
93
94 const listed: ListedSimulator[] = [];
95 for (const runtime in parsedData.devices) {
96 for (const device of parsedData.devices[runtime]) {
97 if (options.enabled === true && !device.isAvailable) {
98 continue;
99 }
100
101 listed.push({
102 runtime,
103 name: device.name,
104 udid: device.udid,
105 state: device.state,
106 isAvailable: device.isAvailable,
107 });
108 }
109 }
110
111 return listed;
112}
113
114function formatRuntimeName(runtime: string): string {
115 const match = runtime.match(/SimRuntime\.(.+)$/);

Callers 3

selectSimulatorFunction · 0.90
list_sims.test.tsFile · 0.90
createListSimsExecutorFunction · 0.85

Calls 3

isSimulatorDataFunction · 0.85
pushMethod · 0.80
executorFunction · 0.50

Tested by

no test coverage detected