Skip to main content
Glama

build_run_mac_ws

Build and run macOS applications from Xcode workspaces in a single command, streamlining development workflows.

Instructions

Builds and runs a macOS app from a workspace in one step.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspacePathYesPath to the .xcworkspace file (Required)
schemeYesThe scheme to use (Required)
configurationNoBuild configuration (Debug, Release, etc.)
derivedDataPathNoPath where build products and other derived data will go
extraArgsNoAdditional xcodebuild arguments
preferXcodebuildNoIf true, prefers xcodebuild over the experimental incremental build system, useful for when incremental build system fails.

Implementation Reference

  • Core handler logic for building and running macOS app from workspace: builds using xcodebuild, extracts app path from build settings, and launches with 'open' command.
    async function _handleMacOSBuildAndRunLogic(params: {
      workspacePath?: string;
      projectPath?: string;
      scheme: string;
      configuration: string;
      derivedDataPath?: string;
      arch?: string;
      extraArgs?: string[];
      preferXcodebuild?: boolean;
    }): Promise<ToolResponse> {
      log('info', 'Handling macOS build & run logic...');
      const _warningMessages: { type: 'text'; text: string }[] = [];
      const _warningRegex = /\[warning\]: (.*)/g;
    
      try {
        // First, build the app
        const buildResult = await _handleMacOSBuildLogic(params);
    
        // 1. Check if the build itself failed
        if (buildResult.isError) {
          return buildResult; // Return build failure directly
        }
        const buildWarningMessages = buildResult.content?.filter((c) => c.type === 'text') ?? [];
    
        // 2. Build succeeded, now get the app path using the helper
        const appPathResult = await _getAppPathFromBuildSettings(params);
    
        // 3. Check if getting the app path failed
        if (!appPathResult.success) {
          log('error', 'Build succeeded, but failed to get app path to launch.');
          const response = createTextResponse(
            `✅ Build succeeded, but failed to get app path to launch: ${appPathResult.error}`,
            false, // Build succeeded, so not a full error
          );
          if (response.content) {
            response.content.unshift(...buildWarningMessages);
          }
          return response;
        }
    
        const appPath = appPathResult.appPath; // We know this is a valid string now
        log('info', `App path determined as: ${appPath}`);
    
        // 4. Launch the app using the verified path
        // Launch the app
        try {
          await promisify(exec)(`open "${appPath}"`);
          log('info', `✅ macOS app launched successfully: ${appPath}`);
          const successResponse: ToolResponse = {
            content: [
              ...buildWarningMessages,
              {
                type: 'text',
                text: `✅ macOS build and run succeeded for scheme ${params.scheme}. App launched: ${appPath}`,
              },
            ],
          };
          return successResponse;
        } catch (launchError) {
          const errorMessage = launchError instanceof Error ? launchError.message : String(launchError);
          log('error', `Build succeeded, but failed to launch app ${appPath}: ${errorMessage}`);
          const errorResponse = createTextResponse(
            `✅ Build succeeded, but failed to launch app ${appPath}. Error: ${errorMessage}`,
            false, // Build succeeded
          );
          if (errorResponse.content) {
            errorResponse.content.unshift(...buildWarningMessages);
          }
          return errorResponse;
        }
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        log('error', `Error during macOS build & run logic: ${errorMessage}`);
        const errorResponse = createTextResponse(
          `Error during macOS build and run: ${errorMessage}`,
          true,
        );
        return errorResponse;
      }
    }
  • Tool registration function that calls registerTool with name 'build_run_mac_ws', Zod schema, and handler reference.
    export function registerMacOSBuildAndRunWorkspaceTool(server: McpServer): void {
      type WorkspaceParams = {
        workspacePath: string;
        scheme: string;
        configuration?: string;
        derivedDataPath?: string;
        arch?: string;
        extraArgs?: string[];
        preferXcodebuild?: boolean;
      };
    
      registerTool<WorkspaceParams>(
        server,
        'build_run_mac_ws',
        'Builds and runs a macOS app from a workspace in one step.',
        {
          workspacePath: workspacePathSchema,
          scheme: schemeSchema,
          configuration: configurationSchema,
          derivedDataPath: derivedDataPathSchema,
          extraArgs: extraArgsSchema,
          preferXcodebuild: preferXcodebuildSchema,
        },
        async (params) =>
          _handleMacOSBuildAndRunLogic({
            ...params,
            configuration: params.configuration ?? 'Debug',
            preferXcodebuild: params.preferXcodebuild ?? false,
          }),
      );
    }
  • Central tool registration array entry that conditionally registers the macOS build-run workspace tool.
    {
      register: registerMacOSBuildAndRunWorkspaceTool,
      groups: [ToolGroup.MACOS_WORKFLOW, ToolGroup.APP_DEPLOYMENT],
      envVar: 'XCODEBUILDMCP_TOOL_MACOS_BUILD_AND_RUN_WORKSPACE',
    },
  • Zod input schema definition for the tool parameters, composed from common schemas.
    {
      workspacePath: workspacePathSchema,
      scheme: schemeSchema,
      configuration: configurationSchema,
      derivedDataPath: derivedDataPathSchema,
      extraArgs: extraArgsSchema,
      preferXcodebuild: preferXcodebuildSchema,
    },
  • Helper function that executes the xcodebuild build command for macOS.
    async function _handleMacOSBuildLogic(params: {
      workspacePath?: string;
      projectPath?: string;
      scheme: string;
      configuration: string;
      derivedDataPath?: string;
      arch?: string;
      extraArgs?: string[];
      preferXcodebuild?: boolean;
    }): Promise<ToolResponse> {
      log('info', `Starting macOS build for scheme ${params.scheme} (internal)`);
    
      return executeXcodeBuildCommand(
        {
          ...params,
        },
        {
          platform: XcodePlatform.macOS,
          arch: params.arch,
          logPrefix: 'macOS Build',
        },
        params.preferXcodebuild,
        'build',
      );
    }
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 'builds and runs' but doesn't clarify critical aspects like whether this is a destructive operation (e.g., overwrites previous builds), execution time, error handling, or output format. For a tool that performs build and run operations, this lack of detail is a significant gap.

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: 'Builds and runs a macOS app from a workspace in one step.' It's front-loaded with the core purpose, has zero wasted words, and clearly communicates the tool's intent without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of building and running macOS apps, the lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral traits (e.g., side effects, performance), usage context relative to siblings, or what to expect upon execution (e.g., success/failure indicators, app launch). For a tool with six parameters and no structured safety hints, this is inadequate.

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 six parameters thoroughly. The description adds no additional parameter semantics beyond implying the tool uses a workspace (matching 'workspacePath') and involves building/running (matching parameters like 'scheme' and 'configuration'). This meets the baseline of 3 when the schema does the heavy lifting.

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 tool's purpose: 'Builds and runs a macOS app from a workspace in one step.' It specifies the verb ('builds and runs'), resource ('macOS app'), and scope ('from a workspace'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'build_mac_ws' or 'build_run_mac_proj', which is a minor gap.

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. With many sibling tools for building and running iOS/macOS apps (e.g., 'build_mac_ws', 'build_run_mac_proj', 'build_run_ios_sim_id_ws'), there's no indication of when this specific tool is preferred, such as for workspace-based macOS builds that include running the app, or prerequisites like having Xcode installed.

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