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', },

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