Skip to main content
Glama

get_mac_bundle_id

Extract the bundle identifier from a macOS .app bundle by providing the full path to the application. Use this tool to retrieve the unique identifier required for macOS app management and automation tasks.

Instructions

Extracts the bundle identifier from a macOS app bundle (.app). IMPORTANT: You MUST provide the appPath parameter. Example: get_mac_bundle_id({ appPath: '/path/to/your/app.app' }) Note: In some environments, this tool may be prefixed as mcp0_get_macos_bundle_id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appPathYesPath to the macOS .app bundle to extract bundle ID from (full path to the .app directory)

Implementation Reference

  • The handler function that validates the appPath, checks if the file exists, extracts the CFBundleIdentifier from the app bundle's Info.plist using `defaults read` or fallback to `PlistBuddy`, logs the process, and returns a formatted response with the bundle ID and next steps, or error message.
        async (params): Promise<ToolResponse> => {
          const appPathValidation = validateRequiredParam('appPath', params.appPath);
          if (!appPathValidation.isValid) {
            return appPathValidation.errorResponse!;
          }
    
          const appPathExistsValidation = validateFileExists(params.appPath);
          if (!appPathExistsValidation.isValid) {
            return appPathExistsValidation.errorResponse!;
          }
    
          log('info', `Starting bundle ID extraction for macOS app: ${params.appPath}`);
    
          try {
            let bundleId;
    
            try {
              bundleId = execSync(`defaults read "${params.appPath}/Contents/Info" CFBundleIdentifier`)
                .toString()
                .trim();
            } catch {
              try {
                bundleId = execSync(
                  `/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${params.appPath}/Contents/Info.plist"`,
                )
                  .toString()
                  .trim();
              } catch (innerError: unknown) {
                throw new Error(
                  `Could not extract bundle ID from Info.plist: ${innerError instanceof Error ? innerError.message : String(innerError)}`,
                );
              }
            }
    
            log('info', `Extracted macOS bundle ID: ${bundleId}`);
    
            return {
              content: [
                {
                  type: 'text',
                  text: ` Bundle ID for macOS app: ${bundleId}`,
                },
                {
                  type: 'text',
                  text: `Next Steps:
    - Launch the app: launch_macos_app({ appPath: "${params.appPath}" })`,
                },
              ],
            };
          } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            log('error', `Error extracting macOS bundle ID: ${errorMessage}`);
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Error extracting iOS bundle ID: ${errorMessage}`,
                },
                {
                  type: 'text',
                  text: `Make sure the path points to a valid macOS app bundle (.app directory).`,
                },
              ],
            };
          }
        },
      );
  • Input schema using Zod for the 'appPath' parameter, a required string describing the full path to the macOS .app bundle.
    {
      appPath: z
        .string()
        .describe(
          'Path to the macOS .app bundle to extract bundle ID from (full path to the .app directory)',
        ),
    },
  • Registers the 'get_mac_bundle_id' tool on the MCP server with name, description, input schema, and handler function.
        'get_mac_bundle_id',
        "Extracts the bundle identifier from a macOS app bundle (.app). IMPORTANT: You MUST provide the appPath parameter. Example: get_mac_bundle_id({ appPath: '/path/to/your/app.app' }) Note: In some environments, this tool may be prefixed as mcp0_get_macos_bundle_id.",
        {
          appPath: z
            .string()
            .describe(
              'Path to the macOS .app bundle to extract bundle ID from (full path to the .app directory)',
            ),
        },
        async (params): Promise<ToolResponse> => {
          const appPathValidation = validateRequiredParam('appPath', params.appPath);
          if (!appPathValidation.isValid) {
            return appPathValidation.errorResponse!;
          }
    
          const appPathExistsValidation = validateFileExists(params.appPath);
          if (!appPathExistsValidation.isValid) {
            return appPathExistsValidation.errorResponse!;
          }
    
          log('info', `Starting bundle ID extraction for macOS app: ${params.appPath}`);
    
          try {
            let bundleId;
    
            try {
              bundleId = execSync(`defaults read "${params.appPath}/Contents/Info" CFBundleIdentifier`)
                .toString()
                .trim();
            } catch {
              try {
                bundleId = execSync(
                  `/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${params.appPath}/Contents/Info.plist"`,
                )
                  .toString()
                  .trim();
              } catch (innerError: unknown) {
                throw new Error(
                  `Could not extract bundle ID from Info.plist: ${innerError instanceof Error ? innerError.message : String(innerError)}`,
                );
              }
            }
    
            log('info', `Extracted macOS bundle ID: ${bundleId}`);
    
            return {
              content: [
                {
                  type: 'text',
                  text: ` Bundle ID for macOS app: ${bundleId}`,
                },
                {
                  type: 'text',
                  text: `Next Steps:
    - Launch the app: launch_macos_app({ appPath: "${params.appPath}" })`,
                },
              ],
            };
          } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            log('error', `Error extracting macOS bundle ID: ${errorMessage}`);
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Error extracting iOS bundle ID: ${errorMessage}`,
                },
                {
                  type: 'text',
                  text: `Make sure the path points to a valid macOS app bundle (.app directory).`,
                },
              ],
            };
          }
        },
      );
  • Top-level registration entry in the toolRegistrations array for conditional registration of the get_mac_bundle_id tool via registerGetMacOSBundleIdTool, associated with specific tool groups and controlled by environment variable.
    {
      register: registerGetMacOSBundleIdTool,
      groups: [ToolGroup.MACOS_WORKFLOW, ToolGroup.APP_DEPLOYMENT, ToolGroup.PROJECT_DISCOVERY],
      envVar: 'XCODEBUILDMCP_TOOL_GET_MACOS_BUNDLE_ID',
    },

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the extraction action and includes an important operational note about the mandatory parameter, but doesn't describe what happens if the path is invalid, whether the tool modifies files, or what format the extracted identifier returns. It provides basic context but misses details about error conditions and output format.

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 efficiently structured with the core purpose first, followed by important requirement, example, and environmental note. Every sentence serves a clear purpose, though the environmental prefix note could be considered slightly extraneous. Overall, it's well-organized with minimal waste.

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?

For a single-parameter tool with no annotations and no output schema, the description provides adequate basic information about what the tool does and how to invoke it. However, it doesn't describe the return value format or potential error conditions, which would be helpful given the lack of output schema. It's minimally complete but could be more comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents the single 'appPath' parameter completely. The description reinforces this with the mandatory requirement and provides a concrete example, adding practical context beyond the schema's technical description. With only one parameter, this exceeds the baseline expectation.

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 specific action ('Extracts the bundle identifier') and target resource ('from a macOS app bundle (.app)'), distinguishing it from sibling tools like 'get_app_bundle_id' which lacks the macOS specificity. It provides a precise verb+resource combination that leaves no ambiguity about the tool's function.

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 includes explicit guidance on when to use this tool (for macOS .app bundles) and provides a mandatory parameter requirement ('You MUST provide the appPath parameter'), but it doesn't explicitly state when NOT to use it or name specific alternatives among the many sibling tools. The context is clear but lacks explicit exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.