Skip to main content
Glama

xcode_clean

Remove build artifacts from Xcode projects to free up storage and ensure clean builds. Specify the path to the .xcodeproj or .xcworkspace file to start cleaning.

Instructions

Clean the build directory for a specific project

Input Schema

NameRequiredDescriptionDefault
xcodeprojYesPath to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths

Input Schema (JSON Schema)

{ "properties": { "xcodeproj": { "description": "Path to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths", "type": "string" } }, "required": [ "xcodeproj" ], "type": "object" }

Implementation Reference

  • Core implementation of the xcode_clean tool: validates the project path, opens the project, executes the Xcode clean action via JXAExecutor (AppleScript), waits for completion in a loop, and returns the result.
    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 }] }; }
  • MCP server request handler for xcode_clean tool: checks if clean is enabled via constructor option, validates xcodeproj argument, delegates execution to BuildTools.clean after opening project.
    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));
  • Input schema definition for xcode_clean tool, conditionally inserted into tool list if includeClean option is true. Defines xcodeproj as required string parameter (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'], }, }); }
  • Includes 'xcode_clean' in buildTools array used for environment validation checks and tool limitations in degraded mode.
    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', 'xcode_get_run_destinations', 'xcode_get_workspace_info', 'xcode_get_projects']; const xcresultTools = ['xcresult_browse', 'xcresult_browser_get_console', 'xcresult_summary', 'xcresult_get_screenshot', 'xcresult_get_ui_hierarchy', 'xcresult_get_ui_element', 'xcresult_list_attachments', 'xcresult_export_attachment'];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lapfelix/XcodeMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server