Skip to main content
Glama

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
NameRequiredDescriptionDefault
xcodeprojYesAbsolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj

Implementation Reference

  • 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'],
        },
      });
    }
  • 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));
  • 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));
  • 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', 

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