Skip to main content
Glama

get_mac_app_path_ws

Retrieve the app bundle path for a macOS application by specifying workspace path and scheme in Xcode projects.

Instructions

Gets the app bundle path for a macOS application using a workspace. IMPORTANT: Requires workspacePath and scheme. Example: get_mac_app_path_ws({ workspacePath: '/path/to/workspace', scheme: 'MyScheme' })

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspacePathYesPath to the .xcworkspace file (Required)
schemeYesThe scheme to use (Required)
configurationNoBuild configuration (Debug, Release, etc.)
archNoArchitecture to build for (arm64 or x86_64). For macOS only.

Implementation Reference

  • Core handler logic shared among app path tools. For macOS, it constructs the destination with architecture if provided, runs 'xcodebuild -showBuildSettings', parses the output to extract BUILT_PRODUCTS_DIR and FULL_PRODUCT_NAME, and returns the app path.
    async function _handleGetAppPathLogic(params: {
      workspacePath?: string;
      projectPath?: string;
      scheme: string;
      configuration: string;
      platform: XcodePlatform;
      simulatorName?: string;
      simulatorId?: string;
      useLatestOS: boolean;
      arch?: string;
    }): Promise<ToolResponse> {
      log('info', `Getting app path for scheme ${params.scheme} on platform ${params.platform}`);
    
      try {
        // Create the command array for xcodebuild with -showBuildSettings option
        const command = ['xcodebuild', '-showBuildSettings'];
    
        // Add the workspace or project
        if (params.workspacePath) {
          command.push('-workspace', params.workspacePath);
        } else if (params.projectPath) {
          command.push('-project', params.projectPath);
        }
    
        // Add the scheme and configuration
        command.push('-scheme', params.scheme);
        command.push('-configuration', params.configuration);
    
        // Handle destination based on platform
        const isSimulatorPlatform = [
          XcodePlatform.iOSSimulator,
          XcodePlatform.watchOSSimulator,
          XcodePlatform.tvOSSimulator,
          XcodePlatform.visionOSSimulator,
        ].includes(params.platform);
    
        let destinationString = '';
    
        if (isSimulatorPlatform) {
          if (params.simulatorId) {
            destinationString = `platform=${params.platform},id=${params.simulatorId}`;
          } else if (params.simulatorName) {
            destinationString = `platform=${params.platform},name=${params.simulatorName}${params.useLatestOS ? ',OS=latest' : ''}`;
          } else {
            return createTextResponse(
              `For ${params.platform} platform, either simulatorId or simulatorName must be provided`,
              true,
            );
          }
        } else if (params.platform === XcodePlatform.macOS) {
          destinationString = constructDestinationString(
            params.platform,
            undefined,
            undefined,
            false,
            params.arch,
          );
        } else if (params.platform === XcodePlatform.iOS) {
          destinationString = 'generic/platform=iOS';
        } else if (params.platform === XcodePlatform.watchOS) {
          destinationString = 'generic/platform=watchOS';
        } else if (params.platform === XcodePlatform.tvOS) {
          destinationString = 'generic/platform=tvOS';
        } else if (params.platform === XcodePlatform.visionOS) {
          destinationString = 'generic/platform=visionOS';
        } else {
          return createTextResponse(`Unsupported platform: ${params.platform}`, true);
        }
    
        command.push('-destination', destinationString);
    
        // Execute the command directly
        const result = await executeCommand(command, 'Get App Path');
    
        if (!result.success) {
          return createTextResponse(`Failed to get app path: ${result.error}`, true);
        }
    
        if (!result.output) {
          return createTextResponse('Failed to extract build settings output from the result.', true);
        }
    
        const buildSettingsOutput = result.output;
        const builtProductsDirMatch = buildSettingsOutput.match(/BUILT_PRODUCTS_DIR = (.+)$/m);
        const fullProductNameMatch = buildSettingsOutput.match(/FULL_PRODUCT_NAME = (.+)$/m);
    
        if (!builtProductsDirMatch || !fullProductNameMatch) {
          return createTextResponse(
            'Failed to extract app path from build settings. Make sure the app has been built first.',
            true,
          );
        }
    
        const builtProductsDir = builtProductsDirMatch[1].trim();
        const fullProductName = fullProductNameMatch[1].trim();
        const appPath = `${builtProductsDir}/${fullProductName}`;
    
        let nextStepsText = '';
        if (params.platform === XcodePlatform.macOS) {
          nextStepsText = `Next Steps:
    1. Get bundle ID: get_macos_bundle_id({ appPath: "${appPath}" })
    2. Launch the app: launch_macos_app({ appPath: "${appPath}" })`;
        } else if (params.platform === XcodePlatform.iOSSimulator) {
          nextStepsText = `Next Steps:
    1. Get bundle ID: get_ios_bundle_id({ appPath: "${appPath}" })
    2. Boot simulator: boot_simulator({ simulatorUuid: "SIMULATOR_UUID" })
    3. Install app: install_app_in_simulator({ simulatorUuid: "SIMULATOR_UUID", appPath: "${appPath}" })
    4. Launch app: launch_app_in_simulator({ simulatorUuid: "SIMULATOR_UUID", bundleId: "BUNDLE_ID" })`;
        } else if (params.platform === XcodePlatform.iOS) {
          nextStepsText = `Next Steps:
    1. Get bundle ID: get_ios_bundle_id({ appPath: "${appPath}" })
    2. Use Xcode to install the app on your connected iOS device`;
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ App path retrieved successfully: ${appPath}`,
            },
            {
              type: 'text',
              text: nextStepsText,
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        log('error', `Error retrieving app path: ${errorMessage}`);
        return createTextResponse(`Error retrieving app path: ${errorMessage}`, true);
      }
    }
  • Registers the 'get_mac_app_path_ws' tool on the MCP server using registerTool from common, defining input schema, description, and a handler that validates params and calls the core _handleGetAppPathLogic with macOS platform and workspace settings.
    export function registerGetMacOSAppPathWorkspaceTool(server: McpServer): void {
      type Params = BaseWorkspaceParams & { configuration?: string; arch?: string };
      registerTool<Params>(
        server,
        'get_mac_app_path_ws',
        "Gets the app bundle path for a macOS application using a workspace. IMPORTANT: Requires workspacePath and scheme. Example: get_mac_app_path_ws({ workspacePath: '/path/to/workspace', scheme: 'MyScheme' })",
        {
          workspacePath: workspacePathSchema,
          scheme: schemeSchema,
          configuration: configurationSchema,
          arch: archSchema,
        },
        async (params: Params) => {
          const workspaceValidation = validateRequiredParam('workspacePath', params.workspacePath);
          if (!workspaceValidation.isValid) return workspaceValidation.errorResponse!;
    
          const schemeValidation = validateRequiredParam('scheme', params.scheme);
          if (!schemeValidation.isValid) return schemeValidation.errorResponse!;
    
          return _handleGetAppPathLogic({
            ...params,
            configuration: params.configuration ?? 'Debug',
            platform: XcodePlatform.macOS,
            useLatestOS: true,
            arch: params.arch, // Pass the architecture parameter
          });
        },
      );
    }
  • Zod schema for the optional 'arch' parameter used in macOS app path tools.
    const archSchema = z
      .enum(['arm64', 'x86_64'])
      .optional()
      .describe('Architecture to build for (arm64 or x86_64). For macOS only.');
  • Central registration entry that conditionally registers the macOS app path workspace tool via its register function during server initialization.
      register: registerGetMacOSAppPathWorkspaceTool,
      groups: [ToolGroup.MACOS_WORKFLOW, ToolGroup.APP_DEPLOYMENT, ToolGroup.PROJECT_DISCOVERY],
      envVar: 'XCODEBUILDMCP_TOOL_GET_MACOS_APP_PATH_WORKSPACE',
    },
  • src/index.ts:57-57 (registration)
    Top-level call to registerTools which includes the get_mac_app_path_ws tool registration.
    registerTools(server);
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. It mentions the requirement for workspacePath and scheme but lacks behavioral details such as what happens if the workspace/scheme is invalid, whether it performs a build operation, error handling, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is front-loaded with the core purpose, followed by important requirements and an example. It uses two sentences efficiently, though the example could be slightly more concise. Overall, it avoids unnecessary verbosity and communicates key points effectively.

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 no annotations and no output schema, the description provides basic purpose and requirements but lacks details on behavior, error cases, or return values. For a tool with 4 parameters and potential complexity in macOS app path retrieval, this is adequate but leaves room for more comprehensive guidance to ensure correct usage.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value by emphasizing that workspacePath and scheme are required, but does not provide additional semantics beyond what the schema specifies. This meets the baseline for high schema coverage.

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 verb ('Gets') and resource ('app bundle path for a macOS application'), specifying it uses a workspace. It distinguishes from sibling 'get_mac_app_path_proj' by explicitly mentioning workspace usage, making the purpose specific and differentiated.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('using a workspace') and explicitly states prerequisites ('Requires workspacePath and scheme'). However, it does not mention when not to use it or name alternatives like the project-based sibling, which would be helpful for full differentiation.

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/SampsonKY/XcodeBuildMCP'

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