get_ios_bundle_id
Extract the bundle identifier from an iOS app bundle (.app) by providing the app path to identify the application's unique ID for development and testing purposes.
Instructions
Extracts the bundle identifier from an iOS app bundle (.app). IMPORTANT: You MUST provide the appPath parameter. Example: get_ios_bundle_id({ appPath: '/path/to/your/app.app' }) Note: In some environments, this tool may be prefixed as mcp0_get_ios_bundle_id.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appPath | Yes | Path to the iOS .app bundle to extract bundle ID from (full path to the .app directory) |
Implementation Reference
- src/tools/bundleId.ts:120-186 (handler)The async handler function for the 'get_ios_bundle_id' tool. Validates the appPath, checks if the file exists, extracts the bundle ID using 'defaults read' or 'PlistBuddy' from Info.plist, logs the result, and returns a formatted response with the bundle ID and next steps.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 iOS app: ${params.appPath}`); try { let bundleId; try { bundleId = execSync(`defaults read "${params.appPath}/Info" CFBundleIdentifier`) .toString() .trim(); } catch { try { bundleId = execSync( `/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${params.appPath}/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 iOS bundle ID: ${bundleId}`); return { content: [ { type: 'text', text: ` Bundle ID for iOS app: ${bundleId}`, }, { type: 'text', text: `Next Steps: - Launch in simulator: launch_app_in_simulator({ simulatorUuid: "YOUR_SIMULATOR_UUID", bundleId: "${bundleId}" })`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log('error', `Error extracting iOS 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 iOS app bundle (.app directory).`, }, ], }; } },
- src/tools/bundleId.ts:113-119 (schema)Zod schema for input parameters: requires 'appPath' as a string describing the path to the iOS .app bundle.{ appPath: z .string() .describe( 'Path to the iOS .app bundle to extract bundle ID from (full path to the .app directory)', ), },
- src/tools/bundleId.ts:109-188 (registration)The registerGetiOSBundleIdTool function that registers the 'get_ios_bundle_id' tool on the MCP server, including name, description, schema, and handler.export function registerGetiOSBundleIdTool(server: McpServer): void { server.tool( 'get_ios_bundle_id', "Extracts the bundle identifier from an iOS app bundle (.app). IMPORTANT: You MUST provide the appPath parameter. Example: get_ios_bundle_id({ appPath: '/path/to/your/app.app' }) Note: In some environments, this tool may be prefixed as mcp0_get_ios_bundle_id.", { appPath: z .string() .describe( 'Path to the iOS .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 iOS app: ${params.appPath}`); try { let bundleId; try { bundleId = execSync(`defaults read "${params.appPath}/Info" CFBundleIdentifier`) .toString() .trim(); } catch { try { bundleId = execSync( `/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${params.appPath}/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 iOS bundle ID: ${bundleId}`); return { content: [ { type: 'text', text: ` Bundle ID for iOS app: ${bundleId}`, }, { type: 'text', text: `Next Steps: - Launch in simulator: launch_app_in_simulator({ simulatorUuid: "YOUR_SIMULATOR_UUID", bundleId: "${bundleId}" })`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log('error', `Error extracting iOS 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 iOS app bundle (.app directory).`, }, ], }; } }, ); }
- src/utils/register-tools.ts:383-390 (registration)Entry in the toolRegistrations array that conditionally registers the get_ios_bundle_id tool based on environment variable, assigning it to relevant tool groups.register: registerGetiOSBundleIdTool, groups: [ ToolGroup.IOS_SIMULATOR_WORKFLOW, ToolGroup.IOS_DEVICE_WORKFLOW, ToolGroup.APP_DEPLOYMENT, ToolGroup.PROJECT_DISCOVERY, ], envVar: 'XCODEBUILDMCP_TOOL_GET_IOS_BUNDLE_ID',