xcode_get_schemes
Retrieve a list of available schemes for an Xcode project using a specified .xcodeproj or .xcworkspace file path. Simplify Xcode build automation and project management.
Instructions
Get list of available schemes for a specific project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xcodeproj | Yes | Path to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths |
Implementation Reference
- src/tools/ProjectTools.ts:310-346 (handler)Core handler function that validates the project path, ensures the project is open, executes a JXA script via JXAExecutor to retrieve schemes from the Xcode workspace (including names, IDs, and active status), handles empty schemes case, and returns formatted JSON.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/shared/toolDefinitions.ts:78-93 (schema)Tool definition including name, description, and input schema (object with optional 'xcodeproj' string parameter). Used by getToolDefinitions() to register the tool.{ 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:489-493 (registration)Switch case in CallToolRequestSchema handler that validates input, resolves preferred xcodeproj if needed, and delegates to ProjectTools.getSchemes handler.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/XcodeServer.ts:301-319 (registration)ListToolsRequestSchema handler that calls getToolDefinitions() (which includes xcode_get_schemes) and returns tool list with schemas for MCP registration.this.server.setRequestHandler(ListToolsRequestSchema, async () => { 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); return { tools: toolDefinitions.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })), }; });