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',
    },
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the tool's purpose and a critical requirement (MUST provide appPath), but lacks details on behavioral traits like error handling, file system access implications, or output format. It adds some context but not comprehensive behavioral disclosure.

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 appropriately sized and front-loaded: the first sentence states the purpose, followed by critical usage notes and an example. Every sentence earns its place with no waste, and the structure guides the user effectively.

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

Completeness4/5

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

Given the tool's low complexity (1 parameter, 100% schema coverage, no output schema), the description is mostly complete. It covers purpose, usage, and parameter requirement, but lacks output details (e.g., what the bundle ID looks like) and error scenarios, which would enhance completeness for a tool with no annotations.

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?

Schema description coverage is 100%, so the schema fully documents the single parameter. The description adds minimal value beyond the schema by emphasizing the parameter's necessity ('MUST provide'), but does not explain semantics like path format or bundle structure. With 0 parameters beyond the one covered, baseline 4 is appropriate.

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') and resource ('bundle identifier from a macOS app bundle (.app)'), distinguishing it from sibling tools like 'get_ios_bundle_id' which targets iOS. It provides precise scope and avoids tautology.

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 explicitly states when to use this tool (for macOS apps) and includes an IMPORTANT note about the required parameter, but does not specify when NOT to use it or name alternatives (e.g., 'get_ios_bundle_id' for iOS). It offers clear context without exclusions.

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