xcode_get_schemes
Retrieve available build schemes from an Xcode project file to configure and manage development workflows.
Instructions
Get list of available schemes for a specific project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xcodeproj | Yes | Absolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj |
Implementation Reference
- src/tools/ProjectTools.ts:310-346 (handler)Core handler function for xcode_get_schemes: validates project path, ensures project is open, executes JXA script via JXAExecutor to retrieve all schemes and active scheme from Xcode, handles empty schemes case, returns formatted JSON list.public static async getSchemes(projectPath: string, openProject: OpenProjectCallback): Promise<McpResult> { const validationError = PathValidator.validateProjectPath(projectPath); if (validationError) return validationError; await openProject(projectPath); const script = ` (function() { ${getWorkspaceByPathScript(projectPath)} const schemes = workspace.schemes(); const activeScheme = workspace.activeScheme(); const schemeInfo = schemes.map(scheme => ({ name: scheme.name(), id: scheme.id(), isActive: activeScheme && scheme.id() === activeScheme.id() })); return JSON.stringify(schemeInfo, null, 2); })() `; const result = await JXAExecutor.execute(script); // Parse the result to check if schemes array is empty try { const schemeInfo = JSON.parse(result); if (Array.isArray(schemeInfo) && schemeInfo.length === 0) { return { content: [{ type: 'text', text: 'No schemes found in the project' }] }; } } catch (error) { // If parsing fails, return the raw result } return { content: [{ type: 'text', text: result }] }; }
- src/XcodeServer.ts:489-493 (handler)Dispatch handler in main MCP CallToolRequest switch statement: validates xcodeproj argument and delegates to ProjectTools.getSchemes.case 'xcode_get_schemes': if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await ProjectTools.getSchemes(args.xcodeproj as string, this.openProject.bind(this));
- src/shared/toolDefinitions.ts:78-92 (schema)JSON Schema definition for xcode_get_schemes input parameters (xcodeproj path, optional if preferred provided). Used by getToolDefinitions for ListTools response.{ name: 'xcode_get_schemes', description: 'Get list of available schemes for a specific project', inputSchema: { type: 'object', properties: { xcodeproj: { type: 'string', description: preferredXcodeproj ? `Absolute path to the .xcodeproj file (or .xcworkspace if available) - defaults to ${preferredXcodeproj}` : 'Absolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj', }, }, required: preferredXcodeproj ? [] : ['xcodeproj'], },
- src/XcodeServer.ts:302-311 (registration)Registration via dynamic tool list: calls getToolDefinitions (which includes xcode_get_schemes) in ListToolsRequest handler to provide tool metadata to MCP clients.const toolOptions: { includeClean: boolean; preferredScheme?: string; preferredXcodeproj?: string; } = { includeClean: this.includeClean }; if (this.preferredScheme) toolOptions.preferredScheme = this.preferredScheme; if (this.preferredXcodeproj) toolOptions.preferredXcodeproj = this.preferredXcodeproj; const toolDefinitions = getToolDefinitions(toolOptions);