Skip to main content
Glama

xcode_get_run_destinations

Retrieve available run destinations for Xcode projects to streamline testing and deployment. Provide the project file path to generate a list of compatible devices and simulators.

Instructions

Get list of available run destinations for a specific project

Input Schema

NameRequiredDescriptionDefault
xcodeprojYesPath to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths

Input Schema (JSON Schema)

{ "properties": { "xcodeproj": { "description": "Path to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths", "type": "string" } }, "required": [ "xcodeproj" ], "type": "object" }

Implementation Reference

  • Core handler function that validates the project path, ensures the project is open in Xcode, executes JXA script to retrieve run destinations (simulators/devices) from the workspace, formats them as JSON, and handles empty results.
    public static async getRunDestinations(projectPath: string, openProject: OpenProjectCallback): Promise<McpResult> { const validationError = PathValidator.validateProjectPath(projectPath); if (validationError) return validationError; await openProject(projectPath); const script = ` (function() { ${getWorkspaceByPathScript(projectPath)} const destinations = workspace.runDestinations(); const activeDestination = workspace.activeRunDestination(); const destInfo = destinations.map(dest => ({ name: dest.name(), platform: dest.platform(), architecture: dest.architecture(), isActive: activeDestination && dest.name() === activeDestination.name() })); return JSON.stringify(destInfo, null, 2); })() `; const result = await JXAExecutor.execute(script); // Parse the result to check if destinations array is empty try { const destInfo = JSON.parse(result); if (Array.isArray(destInfo) && destInfo.length === 0) { return { content: [{ type: 'text', text: 'No run destinations found for the project' }] }; } } catch (error) { // If parsing fails, return the raw result } return { content: [{ type: 'text', text: result }] }; }
  • MCP server switch case that registers and dispatches the tool call to the ProjectTools handler after parameter validation.
    case 'xcode_get_run_destinations': if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await ProjectTools.getRunDestinations(args.xcodeproj as string, this.openProject.bind(this));
  • Tool definition including name, description, and input schema (requires xcodeproj path unless preferred is set). Used by both MCP server listTools handler and CLI.
    name: 'xcode_get_run_destinations', description: 'Get list of available run destinations for a specific project', inputSchema: { type: 'object', properties: { xcodeproj: { type: 'string', description: preferredXcodeproj ? `Absolute path to the .xcodeproj file (or .xcworkspace if available) - defaults to ${preferredXcodeproj}` : 'Absolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj', }, }, required: preferredXcodeproj ? [] : ['xcodeproj'], },
  • MCP listTools request handler that dynamically registers all tools (including xcode_get_run_destinations) by calling getToolDefinitions from shared/toolDefinitions.ts.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { const toolOptions: { includeClean: boolean; preferredScheme?: string; preferredXcodeproj?: string; } = { includeClean: this.includeClean }; if (this.preferredScheme) toolOptions.preferredScheme = this.preferredScheme; if (this.preferredXcodeproj) toolOptions.preferredXcodeproj = this.preferredXcodeproj; const toolDefinitions = getToolDefinitions(toolOptions); return { tools: toolDefinitions.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })), }; });
  • JXA script executed via JXAExecutor to access Xcode's workspace.runDestinations() API, extract name/platform/architecture/active status, and return formatted JSON.
    const script = ` (function() { ${getWorkspaceByPathScript(projectPath)} const destinations = workspace.runDestinations(); const activeDestination = workspace.activeRunDestination(); const destInfo = destinations.map(dest => ({ name: dest.name(), platform: dest.platform(), architecture: dest.architecture(), isActive: activeDestination && dest.name() === activeDestination.name() })); return JSON.stringify(destInfo, null, 2); })()

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/lapfelix/XcodeMCP'

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