Skip to main content
Glama

xcode_get_run_destinations

Retrieve available run destinations for an Xcode project to configure build targets and deployment options.

Instructions

Get list of available run destinations for a specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xcodeprojYesAbsolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj

Implementation Reference

  • Executes the core tool logic: validates project path, ensures project is open in Xcode, runs JXA script to fetch workspace.runDestinations(), formats as JSON with active status, 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 }] };
    }
  • Defines the tool name, description, and input schema requiring the xcodeproj path (absolute path to Xcode project/workspace).
    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'],
    },
  • Registers the tool in the MCP server's CallToolRequest handler switch statement: validates xcodeproj param and dispatches to ProjectTools.getRunDestinations.
    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));
  • Includes the tool in the xcodeTools array used for environment validation to ensure Xcode and osascript are available before execution.
    const xcodeTools = [...buildTools, 'xcode_open_project', 'xcode_get_schemes', 'xcode_set_active_scheme', 
                       'xcode_get_run_destinations', 'xcode_get_workspace_info', 'xcode_get_projects'];
    const xcresultTools = ['xcresult_browse', 'xcresult_browser_get_console', 'xcresult_summary', 'xcresult_get_screenshot', 'xcresult_get_ui_hierarchy', 'xcresult_get_ui_element', 'xcresult_list_attachments', 'xcresult_export_attachment'];

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