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;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: pre-validation of project existence and Xcode installation, structured JSON responses, better error messages, and consistent response format. It doesn't mention rate limits or authentication needs, but covers core operational traits well for a cleaning tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the key recommendation. It uses bullet points efficiently to highlight advantages, and every sentence adds value without redundancy. The length is appropriate for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description does a good job covering the tool's purpose, usage, and behavioral context. It could be more complete by explicitly mentioning the output format details or error handling specifics, but it provides sufficient context for an agent to understand and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters. The description doesn't add specific parameter semantics beyond implying validation for 'projectPath' and cleaning scope for 'configuration' and 'scheme'. This meets the baseline of 3 when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Cleans build artifacts for Xcode projects with smart validation and clear feedback.' It specifies the verb ('cleans'), resource ('build artifacts for Xcode projects'), and distinguishes it from the direct CLI alternative by highlighting intelligent features like validation and structured output.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: '⚡ **Prefer this over 'xcodebuild clean'**' and lists advantages over the direct CLI alternative. It also distinguishes from sibling tools like 'xcodebuild-build' by focusing on cleaning rather than building, though it doesn't explicitly name all siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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