Skip to main content
Glama

list_sims

Retrieve a list of available iOS simulators and their UUIDs using the XcodeBuildMCP server for efficient testing and development workflows.

Instructions

Lists available iOS simulators with their UUIDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enabledNoOptional flag to enable the listing operation.

Implementation Reference

  • Tool registration: exports the default object with name 'list_sims', description, schema, and handler function.
    export default {
      name: 'list_sims',
      description: 'Lists available iOS simulators with their UUIDs. ',
      schema: listSimsSchema.shape, // MCP SDK compatibility
      handler: createTypedTool(listSimsSchema, list_simsLogic, getDefaultCommandExecutor),
    };
  • The handler function list_simsLogic that runs xcrun simctl list devices (JSON and text fallback), parses output, merges results handling Apple bugs, and formats available simulators with next steps.
    export async function list_simsLogic(
      params: ListSimsParams,
      executor: CommandExecutor,
    ): Promise<ToolResponse> {
      log('info', 'Starting xcrun simctl list devices request');
    
      try {
        // Try JSON first for structured data
        const jsonCommand = ['xcrun', 'simctl', 'list', 'devices', '--json'];
        const jsonResult = await executor(jsonCommand, 'List Simulators (JSON)', true);
    
        if (!jsonResult.success) {
          return {
            content: [
              {
                type: 'text',
                text: `Failed to list simulators: ${jsonResult.error}`,
              },
            ],
          };
        }
    
        // Parse JSON output
        let jsonDevices: Record<string, SimulatorDevice[]> = {};
        try {
          const parsedData: unknown = JSON.parse(jsonResult.output);
          if (isSimulatorData(parsedData)) {
            jsonDevices = parsedData.devices;
          }
        } catch {
          log('warn', 'Failed to parse JSON output, falling back to text parsing');
        }
    
        // Fallback to text parsing for Apple simctl bugs (duplicate runtime IDs in iOS 26.0 beta)
        const textCommand = ['xcrun', 'simctl', 'list', 'devices'];
        const textResult = await executor(textCommand, 'List Simulators (Text)', true);
    
        const textDevices = textResult.success ? parseTextOutput(textResult.output) : [];
    
        // Merge JSON and text devices, preferring JSON but adding any missing from text
        const allDevices: Record<string, SimulatorDevice[]> = { ...jsonDevices };
        const jsonUUIDs = new Set<string>();
    
        // Collect all UUIDs from JSON
        for (const runtime in jsonDevices) {
          for (const device of jsonDevices[runtime]) {
            if (device.isAvailable) {
              jsonUUIDs.add(device.udid);
            }
          }
        }
    
        // Add devices from text that aren't in JSON (handles Apple's duplicate runtime ID bug)
        for (const textDevice of textDevices) {
          if (!jsonUUIDs.has(textDevice.udid)) {
            const runtime = textDevice.runtime ?? 'Unknown Runtime';
            if (!allDevices[runtime]) {
              allDevices[runtime] = [];
            }
            allDevices[runtime].push(textDevice);
            log(
              'info',
              `Added missing device from text parsing: ${textDevice.name} (${textDevice.udid})`,
            );
          }
        }
    
        // Format output
        let responseText = 'Available iOS Simulators:\n\n';
    
        for (const runtime in allDevices) {
          const devices = allDevices[runtime].filter((d) => d.isAvailable);
    
          if (devices.length === 0) continue;
    
          responseText += `${runtime}:\n`;
    
          for (const device of devices) {
            responseText += `- ${device.name} (${device.udid})${device.state === 'Booted' ? ' [Booted]' : ''}\n`;
          }
    
          responseText += '\n';
        }
    
        responseText += 'Next Steps:\n';
        responseText += "1. Boot a simulator: boot_sim({ simulatorId: 'UUID_FROM_ABOVE' })\n";
        responseText += '2. Open the simulator UI: open_sim({})\n';
        responseText +=
          "3. Build for simulator: build_sim({ scheme: 'YOUR_SCHEME', simulatorId: 'UUID_FROM_ABOVE' })\n";
        responseText +=
          "4. Get app path: get_sim_app_path({ scheme: 'YOUR_SCHEME', platform: 'iOS Simulator', simulatorId: 'UUID_FROM_ABOVE' })";
    
        return {
          content: [
            {
              type: 'text',
              text: responseText,
            },
          ],
        };
      } 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}`,
            },
          ],
        };
      }
    }
  • Input schema for list_sims tool: optional boolean 'enabled' flag.
    const listSimsSchema = z.object({
      enabled: z.boolean().optional().describe('Optional flag to enable the listing operation.'),
    });
  • Helper function to parse text output from 'xcrun simctl list devices' as fallback for JSON parsing issues.
    function parseTextOutput(textOutput: string): SimulatorDevice[] {
      const devices: SimulatorDevice[] = [];
      const lines = textOutput.split('\n');
      let currentRuntime = '';
    
      for (const line of lines) {
        // Match runtime headers like "-- iOS 26.0 --" or "-- iOS 18.6 --"
        const runtimeMatch = line.match(/^-- ([\w\s.]+) --$/);
        if (runtimeMatch) {
          currentRuntime = runtimeMatch[1];
          continue;
        }
    
        // Match device lines like "    iPhone 17 Pro (UUID) (Booted)"
        // UUID pattern is flexible to handle test UUIDs like "test-uuid-123"
        const deviceMatch = line.match(
          /^\s+(.+?)\s+\(([^)]+)\)\s+\((Booted|Shutdown|Booting|Shutting Down)\)(\s+\(unavailable.*\))?$/i,
        );
        if (deviceMatch && currentRuntime) {
          const [, name, udid, state, unavailableSuffix] = deviceMatch;
          const isUnavailable = Boolean(unavailableSuffix);
          if (!isUnavailable) {
            devices.push({
              name: name.trim(),
              udid,
              state,
              isAvailable: true,
              runtime: currentRuntime,
            });
          }
        }
      }
    
      return devices;
    }
  • Type guard helper to validate parsed JSON data from simctl list devices output.
    function isSimulatorData(value: unknown): value is SimulatorData {
      if (!value || typeof value !== 'object') {
        return false;
      }
    
      const obj = value as Record<string, unknown>;
      if (!obj.devices || typeof obj.devices !== 'object') {
        return false;
      }
    
      const devices = obj.devices as Record<string, unknown>;
      for (const runtime in devices) {
        const deviceList = devices[runtime];
        if (!Array.isArray(deviceList)) {
          return false;
        }
    
        for (const device of deviceList) {
          if (!device || typeof device !== 'object') {
            return false;
          }
    
          const deviceObj = device as Record<string, unknown>;
          if (
            typeof deviceObj.name !== 'string' ||
            typeof deviceObj.udid !== 'string' ||
            typeof deviceObj.state !== 'string' ||
            typeof deviceObj.isAvailable !== 'boolean'
          ) {
            return false;
          }
        }
      }
    
      return true;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool lists simulators but doesn't describe return format, pagination, error conditions, or whether this is a read-only operation. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states exactly what the tool does without any wasted words. It's appropriately sized for a simple listing tool and gets straight to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple listing tool with 100% schema coverage but no annotations or output schema, the description adequately covers the basic purpose. However, it lacks information about return values, error handling, and differentiation from sibling tools, which would be helpful given the context of many similar tools in this server.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'enabled' with its type and description. The description doesn't add any parameter-specific information beyond what's in the schema, which meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Lists') and resource ('available iOS simulators with their UUIDs'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_devices' or 'open_sim', which could cause confusion about when to use this specific tool versus alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_devices' or 'open_sim'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to guess based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/getsentry/XcodeBuildMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server