Skip to main content
Glama

clean_proj

Remove build artifacts from Xcode projects using xcodebuild. Specify the project path to clean derived data and temporary files.

Instructions

Cleans build products for a specific project file using xcodebuild. IMPORTANT: Requires projectPath. Scheme/Configuration are optional. Example: clean_proj({ projectPath: '/path/to/MyProject.xcodeproj', scheme: 'MyScheme' })

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the .xcodeproj file (Required)
schemeNoOptional: The scheme to clean
configurationNoOptional: Build configuration to clean (Debug, Release, etc.)
derivedDataPathNoOptional: Path where derived data might be located
extraArgsNoAdditional xcodebuild arguments

Implementation Reference

  • Core handler logic shared between clean_ws and clean_proj tools. Executes xcodebuild clean command with provided parameters, defaulting scheme to empty and configuration to 'Debug', using macOS platform.
    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
      );
    }
  • Zod input schema for the clean_proj tool defining required projectPath and optional parameters.
    {
      projectPath: z.string().describe('Path to the .xcodeproj 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'),
    },
  • Direct registration of the 'clean_proj' tool on the MCP server, including name, description, schema, and handler reference.
    export function registerCleanProjectTool(server: McpServer): void {
      server.tool(
        'clean_proj',
        "Cleans build products for a specific project file using xcodebuild. IMPORTANT: Requires projectPath. Scheme/Configuration are optional. Example: clean_proj({ projectPath: '/path/to/MyProject.xcodeproj', scheme: 'MyScheme' })",
        {
          projectPath: z.string().describe('Path to the .xcodeproj 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),
      );
    }
  • Central registration entry for conditionally enabling and registering the clean_proj tool based on environment variable.
    {
      register: registerCleanProjectTool,
      groups: [
        ToolGroup.MACOS_WORKFLOW,
        ToolGroup.IOS_SIMULATOR_WORKFLOW,
        ToolGroup.IOS_DEVICE_WORKFLOW,
      ],
      envVar: 'XCODEBUILDMCP_TOOL_CLEAN_PROJECT',
    },

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/SampsonKY/XcodeBuildMCP'

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