11/**
22 * App Path Tools - Tools for retrieving app bundle paths
3+ *
4+ * This module provides tools for retrieving app bundle paths for various platforms
5+ * (macOS, iOS, watchOS, etc.) from both project files and workspaces.
6+ *
7+ * Responsibilities:
8+ * - Retrieving app bundle paths for simulator builds
9+ * - Retrieving app bundle paths for device builds
10+ * - Retrieving app bundle paths for macOS builds
11+ * - Supporting architecture-specific builds for macOS
12+ * - Handling platform-specific destination parameters
313 */
414
515import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' ;
616import { log } from '../utils/logger.js' ;
717import { validateRequiredParam , createTextResponse } from '../utils/validation.js' ;
818import { ToolResponse , XcodePlatform } from '../types/common.js' ;
9- import { executeXcodeCommand } from '../utils/xcode.js' ;
19+ import { executeXcodeCommand , constructDestinationString } from '../utils/xcode.js' ;
1020import {
1121 registerTool ,
1222 workspacePathSchema ,
@@ -22,6 +32,13 @@ import {
2232 BaseAppPathSimulatorNameParams ,
2333 BaseAppPathSimulatorIdParams ,
2434} from './common.js' ;
35+ import { z } from 'zod' ;
36+
37+ // Schema for architecture parameter
38+ const archSchema = z
39+ . enum ( [ 'arm64' , 'x86_64' ] )
40+ . optional ( )
41+ . describe ( 'Architecture to build for (arm64 or x86_64). For macOS only.' ) ;
2542
2643// --- Private Helper Functions ---
2744
@@ -37,6 +54,7 @@ async function _handleGetAppPathLogic(params: {
3754 simulatorName ?: string ;
3855 simulatorId ?: string ;
3956 useLatestOS : boolean ;
57+ arch ?: string ;
4058} ) : Promise < ToolResponse > {
4159 log ( 'info' , `Getting app path for scheme ${ params . scheme } on platform ${ params . platform } ` ) ;
4260
@@ -77,7 +95,13 @@ async function _handleGetAppPathLogic(params: {
7795 ) ;
7896 }
7997 } else if ( params . platform === XcodePlatform . macOS ) {
80- destinationString = 'platform=macOS,arch=arm64,arch=x86_64' ;
98+ destinationString = constructDestinationString (
99+ params . platform ,
100+ undefined ,
101+ undefined ,
102+ false ,
103+ params . arch ,
104+ ) ;
81105 } else if ( params . platform === XcodePlatform . iOS ) {
82106 destinationString = 'generic/platform=iOS' ;
83107 } else if ( params . platform === XcodePlatform . watchOS ) {
@@ -160,7 +184,7 @@ async function _handleGetAppPathLogic(params: {
160184 * Registers the get_macos_app_path_workspace tool
161185 */
162186export function registerGetMacOSAppPathWorkspaceTool ( server : McpServer ) : void {
163- type Params = BaseWorkspaceParams & { configuration ?: string } ;
187+ type Params = BaseWorkspaceParams & { configuration ?: string ; arch ?: string } ;
164188 registerTool < Params > (
165189 server ,
166190 'get_macos_app_path_workspace' ,
@@ -169,6 +193,7 @@ export function registerGetMacOSAppPathWorkspaceTool(server: McpServer): void {
169193 workspacePath : workspacePathSchema ,
170194 scheme : schemeSchema ,
171195 configuration : configurationSchema ,
196+ arch : archSchema ,
172197 } ,
173198 async ( params : Params ) => {
174199 const workspaceValidation = validateRequiredParam ( 'workspacePath' , params . workspacePath ) ;
@@ -182,6 +207,7 @@ export function registerGetMacOSAppPathWorkspaceTool(server: McpServer): void {
182207 configuration : params . configuration ?? 'Debug' ,
183208 platform : XcodePlatform . macOS ,
184209 useLatestOS : true ,
210+ arch : params . arch , // Pass the architecture parameter
185211 } ) ;
186212 } ,
187213 ) ;
@@ -191,7 +217,7 @@ export function registerGetMacOSAppPathWorkspaceTool(server: McpServer): void {
191217 * Registers the get_macos_app_path_project tool
192218 */
193219export function registerGetMacOSAppPathProjectTool ( server : McpServer ) : void {
194- type Params = BaseProjectParams & { configuration ?: string } ;
220+ type Params = BaseProjectParams & { configuration ?: string ; arch ?: string } ;
195221 registerTool < Params > (
196222 server ,
197223 'get_macos_app_path_project' ,
@@ -200,6 +226,7 @@ export function registerGetMacOSAppPathProjectTool(server: McpServer): void {
200226 projectPath : projectPathSchema ,
201227 scheme : schemeSchema ,
202228 configuration : configurationSchema ,
229+ arch : archSchema ,
203230 } ,
204231 async ( params : Params ) => {
205232 const projectValidation = validateRequiredParam ( 'projectPath' , params . projectPath ) ;
@@ -213,6 +240,7 @@ export function registerGetMacOSAppPathProjectTool(server: McpServer): void {
213240 configuration : params . configuration ?? 'Debug' ,
214241 platform : XcodePlatform . macOS ,
215242 useLatestOS : true ,
243+ arch : params . arch ,
216244 } ) ;
217245 } ,
218246 ) ;
0 commit comments