xcode_clean
Clean Xcode project build directories to resolve build issues by removing cached files and temporary data from previous builds.
Instructions
Clean the build directory 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/BuildTools.ts:305-330 (handler)Core handler logic: validates project path, opens project, executes JXA script to call workspace.clean() and waits for completion using polling loop, returns result with action ID.public static async clean(projectPath: string, openProject: OpenProjectCallback): Promise<McpResult> { const validationError = PathValidator.validateProjectPath(projectPath); if (validationError) return validationError; await openProject(projectPath); const script = ` (function() { ${getWorkspaceByPathScript(projectPath)} const actionResult = workspace.clean(); while (true) { if (actionResult.completed()) { break; } delay(0.5); } return \`Clean completed. Result ID: \${actionResult.id()}\`; })() `; const result = await JXAExecutor.execute(script); return { content: [{ type: 'text', text: result }] }; }
- Tool schema definition conditionally added if includeClean=true. Defines inputSchema with xcodeproj parameter (required unless preferred provided).if (includeClean) { tools.splice(5, 0, { name: 'xcode_clean', description: 'Clean the build directory 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:411-418 (registration)Tool registration/dispatch in main CallToolRequestSchema handler: checks if enabled, validates args, calls BuildTools.clean()case 'xcode_clean': if (!this.includeClean) { throw new McpError(ErrorCode.MethodNotFound, `Clean tool is disabled`); } if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await BuildTools.clean(args.xcodeproj as string, this.openProject.bind(this));
- src/XcodeServer.ts:863-870 (registration)Duplicate registration/dispatch in callToolDirect method (CLI bypass).case 'xcode_clean': if (!this.includeClean) { throw new McpError(ErrorCode.MethodNotFound, `Clean tool is disabled`); } if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await BuildTools.clean(args.xcodeproj as string, this.openProject.bind(this));
- src/XcodeServer.ts:179-180 (helper)xcode_clean included in buildTools array for environment validation and limitations checking.const buildTools = ['xcode_build', 'xcode_test', 'xcode_build_and_run', 'xcode_debug', 'xcode_clean']; const xcodeTools = [...buildTools, 'xcode_open_project', 'xcode_get_schemes', 'xcode_set_active_scheme',