Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

xcodebuild-clean

Clean Xcode project build artifacts with pre-validation and structured JSON output for better error handling and troubleshooting, avoiding direct CLI limitations.

Instructions

Prefer this over 'xcodebuild clean' - Intelligent cleaning with validation and structured output.

Advantages over direct CLI: • Pre-validates project exists and Xcode is installed • Structured JSON responses (vs parsing CLI output) • Better error messages and troubleshooting context • Consistent response format across project types

Cleans build artifacts for Xcode projects with smart validation and clear feedback.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configurationNoConfiguration to clean
projectPathYesPath to .xcodeproj or .xcworkspace file
schemeYesScheme to clean

Implementation Reference

  • The main handler function `xcodebuildCleanTool` that validates inputs, constructs and executes the `xcodebuild clean` command, and returns structured results including success status, duration, and output.
    export async function xcodebuildCleanTool(args: any) { const { projectPath, scheme, configuration } = args as CleanToolArgs; try { // Validate inputs await validateProjectPath(projectPath); validateScheme(scheme); // Build command const command = buildXcodebuildCommand('clean', projectPath, { scheme, configuration, }); console.error(`[xcodebuild-clean] Executing: ${command}`); // Execute command const startTime = Date.now(); const result = await executeCommand(command, { timeout: 180000, // 3 minutes for clean }); const duration = Date.now() - startTime; // Format response const responseText = JSON.stringify( { success: result.code === 0, command, duration, output: result.stdout, error: result.stderr, exitCode: result.code, }, null, 2 ); return { content: [ { type: 'text' as const, text: responseText, }, ], isError: result.code !== 0, }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `xcodebuild-clean failed: ${error instanceof Error ? error.message : String(error)}` ); } }
  • Registers the 'xcodebuild-clean' tool with the MCP server, providing input schema, description from docs, and a wrapper handler that validates Xcode installation before calling the main handler.
    // xcodebuild-clean server.registerTool( 'xcodebuild-clean', { description: getDescription(XCODEBUILD_CLEAN_DOCS, XCODEBUILD_CLEAN_DOCS_MINI), inputSchema: { projectPath: z.string(), scheme: z.string(), configuration: z.string().optional(), }, ...DEFER_LOADING_CONFIG, }, async args => { try { await validateXcodeInstallation(); return await xcodebuildCleanTool(args); } catch (error) { if (error instanceof McpError) throw error; throw new McpError( ErrorCode.InternalError, `Tool execution failed: ${error instanceof Error ? error.message : String(error)}` ); } } );
  • Zod input schema defining required projectPath and scheme, optional configuration for the tool.
    inputSchema: { projectPath: z.string(), scheme: z.string(), configuration: z.string().optional(), },
  • TypeScript interface defining the expected arguments for the clean tool handler.
    interface CleanToolArgs { projectPath: string; scheme: string; configuration?: string; }

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/conorluddy/xc-mcp'

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