Skip to main content
Glama

get_mac_bundle_id

Extract the bundle identifier from a macOS app bundle (.app) by specifying the full path to the app directory using the appPath parameter.

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

  • Core handler logic for extracting the macOS bundle identifier (CFBundleIdentifier) from a .app bundle's Info.plist using 'defaults read' or 'PlistBuddy' commands, with error handling and response formatting.
    export async function get_mac_bundle_idLogic(
      params: GetMacBundleIdParams,
      executor: CommandExecutor,
      fileSystemExecutor: FileSystemExecutor,
    ): Promise<ToolResponse> {
      const appPath = params.appPath;
    
      if (!fileSystemExecutor.existsSync(appPath)) {
        return {
          content: [
            {
              type: 'text',
              text: `File not found: '${appPath}'. Please check the path and try again.`,
            },
          ],
          isError: true,
        };
      }
    
      log('info', `Starting bundle ID extraction for macOS app: ${appPath}`);
    
      try {
        let bundleId;
    
        try {
          bundleId = await executeSyncCommand(
            `defaults read "${appPath}/Contents/Info" CFBundleIdentifier`,
            executor,
          );
        } catch {
          try {
            bundleId = await executeSyncCommand(
              `/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${appPath}/Contents/Info.plist"`,
              executor,
            );
          } catch (innerError) {
            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: ${bundleId}`,
            },
            {
              type: 'text',
              text: `Next Steps:
    - Launch: launch_mac_app({ appPath: "${appPath}" })
    - Build again: build_macos({ scheme: "SCHEME_NAME" })`,
            },
          ],
          isError: false,
        };
      } 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 macOS bundle ID: ${errorMessage}`,
            },
            {
              type: 'text',
              text: `Make sure the path points to a valid macOS app bundle (.app directory).`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters (appPath: string) and inferred TypeScript type for the tool.
    const getMacBundleIdSchema = z.object({
      appPath: z
        .string()
        .describe(
          'Path to the macOS .app bundle to extract bundle ID from (full path to the .app directory)',
        ),
    });
    
    // Use z.infer for type safety
    type GetMacBundleIdParams = z.infer<typeof getMacBundleIdSchema>;
  • Default export registering the tool with MCP, including name, description, schema, and a typed handler wrapper around the core logic.
    export default {
      name: 'get_mac_bundle_id',
      description:
        "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.",
      schema: getMacBundleIdSchema.shape, // MCP SDK compatibility
      handler: createTypedTool(
        getMacBundleIdSchema,
        (params: GetMacBundleIdParams) =>
          get_mac_bundle_idLogic(params, getDefaultCommandExecutor(), getDefaultFileSystemExecutor()),
        getDefaultCommandExecutor,
      ),
    };
  • Helper function to execute shell commands synchronously via the CommandExecutor, used internally by the handler.
    async function executeSyncCommand(command: string, executor: CommandExecutor): Promise<string> {
      const result = await executor(['/bin/sh', '-c', command], 'macOS Bundle ID Extraction');
      if (!result.success) {
        throw new Error(result.error ?? 'Command failed');
      }
      return result.output || '';
    }
  • Re-export of the tool from project-discovery module to make it available under macos/tools directory.
    export { default } from '../project-discovery/get_mac_bundle_id.ts';
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.

Install Server

Other Tools

Related 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/getsentry/XcodeBuildMCP'

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