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';

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/cameroncooke/XcodeBuildMCP'

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