xcode_show_sdk_info
Retrieve available SDKs and their paths programmatically, enabling AI assistants to manage and work with iOS/macOS projects efficiently within Xcode.
Instructions
Show available SDKs and their paths
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:51-172 (registration)Dynamically generates and registers MCP tools including 'xcode_show_sdk_info' by loading command definitions, creating tool list with schemas for ListToolsRequest, and handling CallToolRequest by dispatching to CommandExecutor after stripping 'xcode_' prefix.private async setupToolHandlers(): Promise<void> { // Load commands and dynamically create tool list await this.commandExecutor.loadCommands(); const tools = this.commandExecutor.generateMCPToolDefinitions(); // Add web monitor management tools const webMonitorTools = [ { name: 'start_web_monitor', description: 'Start the web interface for visual command execution and monitoring', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'stop_web_monitor', description: 'Stop the web interface if it is running', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'web_monitor_status', description: 'Get the current status of the web monitor', inputSchema: { type: 'object', properties: {}, required: [] } } ]; this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [...tools, ...webMonitorTools], })); 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}`, }, ], }; } }); }
- src/command-executor.ts:281-306 (schema)Generates the inputSchema, name ('xcode_show_sdk_info'), and description for the MCP tool based on the 'show_sdk_info' XcodeCommand parameters from commands.json.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/command-executor.ts:124-162 (handler)Core handler that executes the 'show_sdk_info' command: validates params, builds shell command from template, runs via execAsync, 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 }; } }
- src/command-executor.ts:85-122 (helper)Helper that constructs the specific shell command for 'show_sdk_info' (likely 'xcodebuild -showsdks') by replacing {param} placeholders with argument values.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; }
- src/command-executor.ts:45-53 (helper)Loads the XcodeCommand definitions (including 'show_sdk_info') from commands.json into memory for tool generation and execution.async loadCommands(): Promise<void> { try { const content = await fs.readFile(this.commandsPath, 'utf-8'); const definitions: CommandDefinitions = JSON.parse(content); this.commands = definitions.xcode_commands; } catch (error) { throw new Error(`Failed to load commands from ${this.commandsPath}: ${error}`); } }