list_schems_proj
Retrieve available schemes from an Xcode project file by specifying the project path. Simplify project management and streamline development workflows.
Instructions
Lists available schemes in the project file. IMPORTANT: Requires projectPath. Example: list_schems_proj({ projectPath: '/path/to/MyProject.xcodeproj' })
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the .xcodeproj file (Required) |
Implementation Reference
- src/tools/build_settings.ts:84-151 (handler)Core handler function that runs 'xcodebuild -list -project <path>', parses the schemes section from output, lists them, and provides suggested next tool calls.async function _handleListSchemesLogic(params: { workspacePath?: string; projectPath?: string; }): Promise<ToolResponse> { log('info', 'Listing schemes'); try { // For listing schemes, we can't use executeXcodeBuild directly since it's not a standard action // We need to create a custom command with -list flag const command = ['xcodebuild', '-list']; if (params.workspacePath) { command.push('-workspace', params.workspacePath); } else if (params.projectPath) { command.push('-project', params.projectPath); } // No else needed, one path is guaranteed by callers const result = await executeCommand(command, 'List Schemes'); if (!result.success) { return createTextResponse(`Failed to list schemes: ${result.error}`, true); } // Extract schemes from the output const schemesMatch = result.output.match(/Schemes:([\s\S]*?)(?=\n\n|$)/); if (!schemesMatch) { return createTextResponse('No schemes found in the output', true); } const schemeLines = schemesMatch[1].trim().split('\n'); const schemes = schemeLines.map((line) => line.trim()).filter((line) => line); // Prepare next steps with the first scheme if available let nextStepsText = ''; if (schemes.length > 0) { const firstScheme = schemes[0]; const projectOrWorkspace = params.workspacePath ? 'workspace' : 'project'; const path = params.workspacePath || params.projectPath; nextStepsText = `Next Steps: 1. Build the app: ${projectOrWorkspace === 'workspace' ? 'macos_build_workspace' : 'macos_build_project'}({ ${projectOrWorkspace}Path: "${path}", scheme: "${firstScheme}" }) or for iOS: ${projectOrWorkspace === 'workspace' ? 'ios_simulator_build_by_name_workspace' : 'ios_simulator_build_by_name_project'}({ ${projectOrWorkspace}Path: "${path}", scheme: "${firstScheme}", simulatorName: "iPhone 16" }) 2. Show build settings: ${projectOrWorkspace === 'workspace' ? 'show_build_set_ws' : 'show_build_set_proj'}({ ${projectOrWorkspace}Path: "${path}", scheme: "${firstScheme}" })`; } return { content: [ { type: 'text', text: `✅ Available schemes:`, }, { type: 'text', text: schemes.join('\n'), }, { type: 'text', text: nextStepsText, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log('error', `Error listing schemes: ${errorMessage}`); return createTextResponse(`Error listing schemes: ${errorMessage}`, true); } }
- src/tools/build_settings.ts:229-245 (registration)Tool registration function defining the tool name 'list_schems_proj', description, input schema, and handler lambda that validates projectPath and calls the core logic.export function registerListSchemesProjectTool(server: McpServer): void { registerTool<BaseProjectParams>( server, 'list_schems_proj', "Lists available schemes in the project file. IMPORTANT: Requires projectPath. Example: list_schems_proj({ projectPath: '/path/to/MyProject.xcodeproj' })", { projectPath: projectPathSchema, }, async (params: BaseProjectParams) => { // Validate required parameters const projectValidation = validateRequiredParam('projectPath', params.projectPath); if (!projectValidation.isValid) return projectValidation.errorResponse!; return _handleListSchemesLogic(params); }, ); }
- src/tools/common.ts:23-23 (schema)Zod schema for the required projectPath input parameter used by the tool.export const projectPathSchema = z.string().describe('Path to the .xcodeproj file (Required)');
- src/utils/register-tools.ts:118-122 (registration)Configuration entry in toolRegistrations array that enables conditional registration of the list_schems_proj tool via registerTools(server) based on environment variable.{ register: registerListSchemesProjectTool, groups: [ToolGroup.PROJECT_DISCOVERY], envVar: 'XCODEBUILDMCP_TOOL_LIST_SCHEMES_PROJECT', },