clean_ws
Clean build products for a specific Xcode workspace using xcodebuild. Specify workspace path; optionally include scheme, configuration, or derived data path to remove unnecessary artifacts.
Instructions
Cleans build products for a specific workspace using xcodebuild. IMPORTANT: Requires workspacePath. Scheme/Configuration are optional. Example: clean_ws({ workspacePath: '/path/to/MyProject.xcworkspace', scheme: 'MyScheme' })
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| configuration | No | Optional: Build configuration to clean (Debug, Release, etc.) | |
| derivedDataPath | No | Optional: Path where derived data might be located | |
| extraArgs | No | Additional xcodebuild arguments | |
| scheme | No | Optional: The scheme to clean | |
| workspacePath | Yes | Path to the .xcworkspace file (Required) |
Implementation Reference
- src/tools/clean.ts:27-51 (handler)The core handler function that performs the xcodebuild 'clean' action, handling parameters and defaults for workspace cleaning.async function _handleCleanLogic(params: { workspacePath?: string; projectPath?: string; scheme?: string; configuration?: string; derivedDataPath?: string; extraArgs?: string[]; }): Promise<ToolResponse> { log('info', 'Starting xcodebuild clean request (internal)'); // For clean operations, we need to provide a default platform and configuration return executeXcodeBuildCommand( { ...params, scheme: params.scheme || '', // Empty string if not provided configuration: params.configuration || 'Debug', // Default to Debug if not provided }, { platform: XcodePlatform.macOS, // Default to macOS, but this doesn't matter much for clean logPrefix: 'Clean', }, false, 'clean', // Specify 'clean' as the build action ); }
- src/tools/clean.ts:55-74 (registration)Registers the 'clean_ws' tool on the MCP server, defining its name, description, input schema (using Zod), and handler callback.export function registerCleanWorkspaceTool(server: McpServer): void { server.tool( 'clean_ws', "Cleans build products for a specific workspace using xcodebuild. IMPORTANT: Requires workspacePath. Scheme/Configuration are optional. Example: clean_ws({ workspacePath: '/path/to/MyProject.xcworkspace', scheme: 'MyScheme' })", { workspacePath: z.string().describe('Path to the .xcworkspace file (Required)'), scheme: z.string().optional().describe('Optional: The scheme to clean'), configuration: z .string() .optional() .describe('Optional: Build configuration to clean (Debug, Release, etc.)'), derivedDataPath: z .string() .optional() .describe('Optional: Path where derived data might be located'), extraArgs: z.array(z.string()).optional().describe('Additional xcodebuild arguments'), }, (params) => _handleCleanLogic(params), ); }
- src/tools/clean.ts:59-71 (schema)Input schema for the 'clean_ws' tool using Zod for validation of parameters like workspacePath, scheme, etc.{ workspacePath: z.string().describe('Path to the .xcworkspace file (Required)'), scheme: z.string().optional().describe('Optional: The scheme to clean'), configuration: z .string() .optional() .describe('Optional: Build configuration to clean (Debug, Release, etc.)'), derivedDataPath: z .string() .optional() .describe('Optional: Path where derived data might be located'), extraArgs: z.array(z.string()).optional().describe('Additional xcodebuild arguments'), },
- src/utils/register-tools.ts:141-148 (registration)Central registry entry that enables conditional registration of the clean_ws tool based on environment variable.register: registerCleanWorkspaceTool, groups: [ ToolGroup.MACOS_WORKFLOW, ToolGroup.IOS_SIMULATOR_WORKFLOW, ToolGroup.IOS_DEVICE_WORKFLOW, ], envVar: 'XCODEBUILDMCP_TOOL_CLEAN_WORKSPACE', },