Skip to main content
Glama
ebowwa

Xcode MCP Server

by ebowwa

xcode_list_simulators_json

Retrieve available iOS and macOS simulators in JSON format to parse and integrate with development workflows.

Instructions

List simulators in JSON format for parsing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP CallToolRequestSchema handler that processes tool calls. For 'xcode_*' tools like 'xcode_list_simulators_json', strips 'xcode_' prefix and calls CommandExecutor.executeCommand with the remaining command name and arguments.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        // Handle web monitor tools
        if (name === 'start_web_monitor') {
          const result = await this.webMonitorManager.start();
          return {
            content: [
              {
                type: 'text',
                text: `${result.message}\n\nWeb interface available at: ${result.url}`
              }
            ]
          };
        }
        
        if (name === 'stop_web_monitor') {
          const result = this.webMonitorManager.stop();
          return {
            content: [
              {
                type: 'text',
                text: result.message
              }
            ]
          };
        }
        
        if (name === 'web_monitor_status') {
          const status = this.webMonitorManager.getStatus();
          let text = status.running 
            ? `Web monitor is running at ${status.url} (port ${status.port})`
            : 'Web monitor is not running';
          return {
            content: [
              {
                type: 'text',
                text: text
              }
            ]
          };
        }
        
        // Handle Xcode commands
        // Remove 'xcode_' prefix if present
        const commandName = name.startsWith('xcode_') ? name.slice(6) : name;
        const result = await this.commandExecutor.executeCommand(commandName, args);
        
        let responseText = result.output;
        if (result.error) {
          responseText += `\n\nWarnings/Errors:\n${result.error}`;
        }
        if (!result.success) {
          responseText = `Command failed: ${result.error}\n\nCommand executed: ${result.command}`;
        }
        
        return {
          content: [
            {
              type: 'text',
              text: responseText,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${errorMessage}`,
            },
          ],
        };
      }
    });
  • Core execution handler for individual commands (e.g., 'list_simulators_json'). Builds shell command from template, validates params, executes via child_process.exec, returns output/error.
    async executeCommand(name: string, args: Record<string, any> = {}): Promise<{
      success: boolean;
      output: string;
      error?: string;
      command: string;
    }> {
      const command = this.getCommand(name);
      if (!command) {
        throw new Error(`Command '${name}' not found`);
      }
    
      this.validateParameters(command, args);
    
      // Handle internal commands
      if (command.command.startsWith('internal:')) {
        return await this.executeInternalCommand(command, args);
      }
    
      // Handle external commands
      const builtCommand = this.buildCommand(command, args);
    
      try {
        const { stdout, stderr } = await execAsync(builtCommand);
        
        return {
          success: true,
          output: stdout,
          error: stderr || undefined,
          command: builtCommand
        };
      } catch (error) {
        return {
          success: false,
          output: '',
          error: error instanceof Error ? error.message : String(error),
          command: builtCommand
        };
      }
    }
  • Generates input schema and tool metadata for MCP registration. Creates tool names like 'xcode_list_simulators_json' from loaded command definitions with corresponding input schemas.
    generateMCPToolDefinitions(): Array<{
      name: string;
      description: string;
      inputSchema: any;
    }> {
      return Object.entries(this.commands).map(([name, command]) => ({
        name: `xcode_${name}`,
        description: command.description,
        inputSchema: {
          type: 'object',
          properties: command.parameters ? Object.fromEntries(
            Object.entries(command.parameters).map(([paramName, paramDef]) => [
              paramName,
              {
                type: paramDef.type,
                description: paramDef.description,
                ...(paramDef.default !== undefined && { default: paramDef.default })
              }
            ])
          ) : {},
          required: command.parameters ? Object.entries(command.parameters)
            .filter(([_, paramDef]) => paramDef.required)
            .map(([paramName]) => paramName) : []
        }
      }));
    }
  • src/index.ts:87-89 (registration)
    Registers all dynamically generated Xcode tools (including 'xcode_list_simulators_json') with MCP ListToolsRequestSchema handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [...tools, ...webMonitorTools],
    }));
  • Helper that constructs the actual shell command string by replacing placeholders {param} in command templates with argument values, handling optionals, booleans, and cleanup.
    buildCommand(command: XcodeCommand, args: Record<string, any>): string {
      let builtCommand = command.command;
    
      // Replace required parameters
      if (command.parameters) {
        for (const [paramName, paramDef] of Object.entries(command.parameters)) {
          const value = args[paramName] !== undefined ? args[paramName] : paramDef.default;
          
          if (paramDef.type === 'boolean') {
            // Handle boolean parameters
            if (value === true) {
              // Replace placeholder with the template if true
              builtCommand = builtCommand.replace(`{${paramName}}`, paramDef.template || '');
            } else {
              // Remove placeholder if false
              builtCommand = builtCommand.replace(`{${paramName}}`, '');
            }
          } else if (value !== undefined && value !== null && value !== '') {
            if (paramDef.template) {
              // Use custom template for parameter
              const paramValue = paramDef.template.replace(`{${paramName}}`, value);
              builtCommand = builtCommand.replace(`{${paramName}}`, paramValue);
            } else {
              // Direct replacement
              builtCommand = builtCommand.replace(`{${paramName}}`, value);
            }
          } else {
            // Remove optional parameter placeholders
            builtCommand = builtCommand.replace(new RegExp(`\\s*\\{${paramName}\\}`, 'g'), '');
          }
        }
      }
    
      // Clean up any remaining placeholder patterns
      builtCommand = builtCommand.replace(/\s+/g, ' ').trim();
      
      return builtCommand;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the output format (JSON) but fails to describe other key behaviors such as whether this is a read-only operation, if it requires specific permissions, what the JSON structure includes, or any error conditions. This leaves significant gaps for a tool with no annotation coverage.

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 front-loads the core purpose ('List simulators') and adds necessary detail about the output format. There is no wasted verbiage, making it appropriately sized and easy to parse quickly.

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?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally adequate by stating the action and output format. However, it lacks details on behavioral aspects like read/write nature, error handling, or JSON structure, which could be helpful despite the low complexity. It meets the baseline for a basic listing tool but doesn't excel in completeness.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description adds no parameter information, which is appropriate here. Baseline is 4 for zero parameters, as no additional semantics are needed beyond the schema's completeness.

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 ('List simulators') and specifies the output format ('in JSON format for parsing'), which distinguishes it from the sibling tool 'xcode_list_simulators' that likely outputs differently. However, it doesn't explicitly differentiate from 'xcode_list_available_simulators' or 'xcode_list_physical_devices', which may list different types of devices.

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 'xcode_list_simulators' (presumably non-JSON output), 'xcode_list_available_simulators', or 'xcode_list_physical_devices'. It lacks explicit when/when-not instructions or context for selection among similar listing tools.

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

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/ebowwa/xcode-mcp'

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