Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

simctl-list

Generate concise summaries of available iOS simulators to prevent token overflow, offering smart recommendations, recently used devices, and structured JSON output. Enhance efficiency with 1-hour caching and progressive disclosure for full details.

Instructions

🚨 CRITICAL: Use this instead of 'xcrun simctl list' - Prevents token overflow with intelligent progressive disclosure!

Why this is essential over direct CLI: • šŸ”„ Prevents token overflow - Raw simctl output can be 10,000+ tokens, breaking conversations • šŸŽÆ Progressive disclosure - Returns concise summaries, full details available via cache IDs • 🧠 Smart recommendations - Shows recently used and optimal simulators first • ⚔ 1-hour caching - Dramatically faster than repeated expensive simctl calls • šŸ“Š Usage tracking - Learns which simulators you prefer for better suggestions • šŸ›”ļø Structured output - Clean JSON vs parsing massive CLI text blocks

NEW: Now returns concise summaries by default to avoid token overflow! Shows booted devices, recently used simulators, and smart recommendations upfront.

Results are cached for 1 hour for faster performance. Use simctl-get-details with the returned cacheId for full device lists.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
availabilityNoFilter by device availabilityavailable
conciseNoReturn concise summary (true) or full list (false)
deviceTypeNoFilter by device type (iPhone, iPad, Apple Watch, Apple TV)
outputFormatNoOutput format preferencejson
runtimeNoFilter by iOS runtime version (e.g., "17", "iOS 17.0", "16.4")

Implementation Reference

  • The main handler function `simctlListTool` that implements the core logic for the 'simctl-list' tool, including caching, filtering, progressive disclosure, and device limiting.
    export async function simctlListTool(args: any) {
      const {
        deviceType,
        runtime,
        availability = 'available',
        outputFormat = 'json',
        concise = true,
        max = 5,
      } = args as SimctlListArgs;
    
      try {
        // Use the new caching system
        const cachedList = await simulatorCache.getSimulatorList();
    
        let responseData: Record<string, unknown> | string;
    
        // Use progressive disclosure by default (concise=true)
        if (concise && outputFormat === 'json') {
          // Generate concise summary
          const summary = extractSimulatorSummary(cachedList);
    
          // Store full output in response cache
          const cacheId = responseCache.store({
            tool: 'simctl-list',
            fullOutput: JSON.stringify(cachedList, null, 2),
            stderr: '',
            exitCode: 0,
            command: 'simctl list -j',
            metadata: {
              totalDevices: summary.totalDevices,
              availableDevices: summary.availableDevices,
              hasFilters: !!(deviceType || runtime || availability !== 'available'),
            },
          });
    
          // Return progressive disclosure response
          responseData = createProgressiveSimulatorResponse(summary, cacheId, {
            deviceType,
            runtime,
            availability,
          });
        } else {
          // Legacy mode: return full filtered list with device limiting
          if (outputFormat === 'json') {
            // Apply filters if specified
            const filteredList = filterCachedSimulatorList(cachedList, {
              deviceType,
              runtime,
              availability,
            });
    
            // Limit devices to max count, sorted by lastUsed date
            const allDevices: Array<{ runtime: string; device: SimulatorInfo }> = [];
            for (const [runtimeKey, devices] of Object.entries(filteredList.devices)) {
              devices.forEach(device => {
                allDevices.push({ runtime: runtimeKey, device });
              });
            }
    
            // Sort by lastUsed date descending (most recent first), nulls at end
            allDevices.sort((a, b) => {
              if (!a.device.lastUsed && !b.device.lastUsed) return 0;
              if (!a.device.lastUsed) return 1;
              if (!b.device.lastUsed) return -1;
              return b.device.lastUsed.getTime() - a.device.lastUsed.getTime();
            });
    
            // Take first max devices
            const limitedDevices = allDevices.slice(0, max);
    
            // Reconstruct grouped structure with limited devices
            const limitedDevicesByRuntime: { [runtime: string]: SimulatorInfo[] } = {};
            for (const { runtime: runtimeKey, device } of limitedDevices) {
              if (!limitedDevicesByRuntime[runtimeKey]) {
                limitedDevicesByRuntime[runtimeKey] = [];
              }
              limitedDevicesByRuntime[runtimeKey].push(device);
            }
    
            responseData = {
              devices: limitedDevicesByRuntime,
              runtimes: filteredList.runtimes,
              devicetypes: filteredList.devicetypes,
              lastUpdated: filteredList.lastUpdated.toISOString(),
              metadata: {
                totalDevicesInCache: Object.values(filteredList.devices).flat().length,
                devicesReturned: limitedDevices.length,
                limitApplied: max,
              },
            };
          } else {
            // For text format, we need to convert back to original format
            responseData =
              `Simulator List (cached at ${cachedList.lastUpdated.toISOString()}):\n` +
              JSON.stringify(cachedList, null, 2);
          }
        }
    
        const responseText =
          outputFormat === 'json'
            ? JSON.stringify(responseData, null, 2)
            : typeof responseData === 'string'
              ? responseData
              : JSON.stringify(responseData, null, 2);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: responseText,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `simctl-list failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • The `registerSimctlListTool` function that registers the 'simctl-list' tool with the MCP server, including the handler wrapper and input schema.
    export function registerSimctlListTool(server: McpServer): void {
      server.registerTool(
        'simctl-list',
        {
          description: getDescription(SIMCTL_LIST_DOCS, SIMCTL_LIST_DOCS_MINI),
          inputSchema: {
            deviceType: z.string().optional(),
            runtime: z.string().optional(),
            availability: z.enum(['available', 'unavailable', 'all']).default('available'),
            outputFormat: z.enum(['json', 'text']).default('json'),
            concise: z.boolean().default(true),
            max: z.number().default(5),
          },
          ...DEFER_LOADING_CONFIG,
        },
        async args => {
          try {
            await validateXcodeInstallation();
            return await simctlListTool(args);
          } catch (error) {
            if (error instanceof McpError) throw error;
            throw new McpError(
              ErrorCode.InternalError,
              `Tool execution failed: ${error instanceof Error ? error.message : String(error)}`
            );
          }
        }
      );
    }
  • TypeScript interface `SimctlListArgs` defining the input parameters for the tool, matching the Zod schema in registration.
    interface SimctlListArgs {
      deviceType?: string;
      runtime?: string;
      availability?: 'available' | 'unavailable' | 'all';
      outputFormat?: OutputFormat;
      concise?: boolean;
      max?: number;
    }
    
    /**
     * List iOS simulators with intelligent progressive disclosure and caching
     *
     * **What it does:**
     * Retrieves comprehensive simulator information including devices, runtimes, and device types.
     * Returns concise summaries by default with cache IDs for progressive access to full details,
     * preventing token overflow while maintaining complete functionality.
     *
     * **Why you'd use it:**
     * - Prevents token overflow with 10k+ device lists via progressive disclosure
     * - Shows booted devices and recently used simulators first for faster workflows
     * - 1-hour intelligent caching eliminates redundant queries
     * - Provides smart filtering by device type, runtime, and availability
     * - Limits full output to most recently used devices for efficient browsing
     *
     * **Parameters:**
     * - `deviceType` (string, optional): Filter by device type (e.g., "iPhone", "iPad")
     * - `runtime` (string, optional): Filter by iOS runtime version (e.g., "17", "iOS 17.0")
     * - `availability` (string, optional): Filter by availability ("available", "unavailable", "all")
     * - `outputFormat` (string, optional): Output format ("json" or "text")
     * - `concise` (boolean, optional): Return concise summary with cache ID (default: true)
     * - `max` (number, optional): Maximum devices to return in full mode (default: 5, sorted by lastUsed)
     *
     * **Returns:**
     * - Concise mode: Summary with cacheId for detailed retrieval via simctl-get-details
     * - Full mode: Limited device list (default 5 most recently used) with metadata about limiting
     *
     * **Example:**
     * ```typescript
     * // Get concise summary (default - prevents token overflow)
     * await simctlListTool({})
     *
     * // Get full list for iPhone devices (limited to 5 most recent)
     * await simctlListTool({ deviceType: "iPhone", concise: false })
     *
     * // Get full list with custom limit
     * await simctlListTool({ concise: false, max: 10 })
     *
     * // Filter by iOS version
     * await simctlListTool({ runtime: "17.0" })
     * ```
     *
     * **Full documentation:** See simctl/list.md for detailed parameters and progressive disclosure
     *
     * @param args Tool arguments including optional filters, format, and max device limit
     * @returns Tool result with simulator list or summary with cache ID
     */
    export async function simctlListTool(args: any) {
      const {
        deviceType,
        runtime,
        availability = 'available',
        outputFormat = 'json',
        concise = true,
        max = 5,
      } = args as SimctlListArgs;
    
      try {
        // Use the new caching system
        const cachedList = await simulatorCache.getSimulatorList();
    
        let responseData: Record<string, unknown> | string;
    
        // Use progressive disclosure by default (concise=true)
        if (concise && outputFormat === 'json') {
          // Generate concise summary
          const summary = extractSimulatorSummary(cachedList);
    
          // Store full output in response cache
          const cacheId = responseCache.store({
            tool: 'simctl-list',
            fullOutput: JSON.stringify(cachedList, null, 2),
            stderr: '',
            exitCode: 0,
            command: 'simctl list -j',
            metadata: {
              totalDevices: summary.totalDevices,
              availableDevices: summary.availableDevices,
              hasFilters: !!(deviceType || runtime || availability !== 'available'),
            },
          });
    
          // Return progressive disclosure response
          responseData = createProgressiveSimulatorResponse(summary, cacheId, {
            deviceType,
            runtime,
            availability,
          });
        } else {
          // Legacy mode: return full filtered list with device limiting
          if (outputFormat === 'json') {
            // Apply filters if specified
            const filteredList = filterCachedSimulatorList(cachedList, {
              deviceType,
              runtime,
              availability,
            });
    
            // Limit devices to max count, sorted by lastUsed date
            const allDevices: Array<{ runtime: string; device: SimulatorInfo }> = [];
            for (const [runtimeKey, devices] of Object.entries(filteredList.devices)) {
              devices.forEach(device => {
                allDevices.push({ runtime: runtimeKey, device });
              });
            }
    
            // Sort by lastUsed date descending (most recent first), nulls at end
            allDevices.sort((a, b) => {
              if (!a.device.lastUsed && !b.device.lastUsed) return 0;
              if (!a.device.lastUsed) return 1;
              if (!b.device.lastUsed) return -1;
              return b.device.lastUsed.getTime() - a.device.lastUsed.getTime();
            });
    
            // Take first max devices
            const limitedDevices = allDevices.slice(0, max);
    
            // Reconstruct grouped structure with limited devices
            const limitedDevicesByRuntime: { [runtime: string]: SimulatorInfo[] } = {};
            for (const { runtime: runtimeKey, device } of limitedDevices) {
              if (!limitedDevicesByRuntime[runtimeKey]) {
                limitedDevicesByRuntime[runtimeKey] = [];
              }
              limitedDevicesByRuntime[runtimeKey].push(device);
            }
    
            responseData = {
              devices: limitedDevicesByRuntime,
              runtimes: filteredList.runtimes,
              devicetypes: filteredList.devicetypes,
              lastUpdated: filteredList.lastUpdated.toISOString(),
              metadata: {
                totalDevicesInCache: Object.values(filteredList.devices).flat().length,
                devicesReturned: limitedDevices.length,
                limitApplied: max,
              },
            };
          } else {
            // For text format, we need to convert back to original format
            responseData =
              `Simulator List (cached at ${cachedList.lastUpdated.toISOString()}):\n` +
              JSON.stringify(cachedList, null, 2);
          }
        }
    
        const responseText =
          outputFormat === 'json'
            ? JSON.stringify(responseData, null, 2)
            : typeof responseData === 'string'
              ? responseData
              : JSON.stringify(responseData, null, 2);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: responseText,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `simctl-list failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Zod inputSchema used for MCP tool validation of arguments.
    inputSchema: {
      deviceType: z.string().optional(),
      runtime: z.string().optional(),
      availability: z.enum(['available', 'unavailable', 'all']).default('available'),
      outputFormat: z.enum(['json', 'text']).default('json'),
      concise: z.boolean().default(true),
      max: z.number().default(5),
    },
    ...DEFER_LOADING_CONFIG,
  • The `registerAllTools` function that invokes `registerSimctlListTool` as part of the main tool registration process.
    export function registerAllTools(server: McpServer): void {
      // Always register build-related tools
      registerXcodebuildTools(server);
      registerSimctlListTool(server);
      registerCacheTools(server);
      registerSystemTools(server);
    
      // Only register full toolset when NOT in build-only mode
      if (!config.buildOnly) {
        registerSimctlTools(server);
        registerIdbTools(server);
        registerWorkflowTools(server);
      }
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: token overflow prevention, progressive disclosure, caching (1-hour duration), usage tracking, structured JSON output, and performance optimizations. It doesn't mention error handling or authentication needs, but covers most critical operational aspects for this type of tool.

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

Conciseness3/5

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

The description is appropriately front-loaded with the critical usage instruction, but contains excessive emojis and formatting that don't add semantic value. While information-dense, some bullet points could be more concise (e.g., combining related benefits). The structure guides the reader effectively from problem to solution to implementation details.

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

Completeness4/5

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

Given the tool's complexity (progressive disclosure, caching, filtering) and lack of output schema, the description provides substantial context about return values (concise summaries, cache IDs for details), performance characteristics, and integration with sibling tools. It adequately explains what the tool returns and how to use the results, though doesn't specify exact output structure.

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?

The input schema has 100% description coverage, so the baseline is 3. The description doesn't add specific parameter semantics beyond what's in the schema, though it mentions the 'concise' parameter's default behavior and implies filtering capabilities. No additional syntax or format details are provided for parameters beyond the schema's documentation.

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

Purpose5/5

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

The description clearly states the tool's purpose: it lists iOS simulators with intelligent progressive disclosure to prevent token overflow, distinguishing it from the direct CLI command 'xcrun simctl list'. It specifies the verb 'list' and resource 'iOS simulators' while differentiating from sibling tools like 'simctl-get-details' for full device lists.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: it states to use this tool 'instead of' the direct CLI command to prevent token overflow, mentions when to use the sibling tool 'simctl-get-details' for full details, and explains the default behavior (concise summaries) versus alternatives (full list via parameter). It also clarifies the caching mechanism and performance benefits.

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/conorluddy/xc-mcp'

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