Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

xcodebuild-version

Retrieve structured Xcode and SDK version details in JSON or text format, validate installations, and enable caching for faster queries. Simplifies environment validation and avoids parsing raw CLI output.

Instructions

Prefer this over 'xcodebuild -version' - Gets Xcode version info with structured output and caching.

Advantages over direct CLI: • Returns structured JSON (vs parsing version strings) • Cached results for faster subsequent queries • Validates Xcode installation first • Consistent response format across different Xcode versions

Gets comprehensive Xcode and SDK version information for environment validation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
outputFormatNoOutput format preferencejson
sdkNoSpecific SDK to query (optional)

Implementation Reference

  • Core handler function that executes the xcodebuild -version command, handles optional sdk and outputFormat parameters, parses JSON or text output, and returns structured MCP content.
    export async function xcodebuildVersionTool(args: any) {
      const { sdk, outputFormat = 'json' } = args as VersionToolArgs;
    
      try {
        // Build command
        let command = 'xcodebuild -version';
    
        if (sdk) {
          command += ` -sdk ${sdk}`;
        }
    
        if (outputFormat === 'json') {
          command += ' -json';
        }
    
        // Execute command
        const result = await executeCommand(command);
    
        if (result.code !== 0) {
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to get version information: ${result.stderr}`
          );
        }
    
        let responseText: string;
    
        if (outputFormat === 'json') {
          try {
            // Parse and format JSON response
            const versionInfo = JSON.parse(result.stdout);
            responseText = JSON.stringify(versionInfo, null, 2);
          } catch {
            // If JSON parsing fails, the output might be plain text
            // This can happen with older Xcode versions
            responseText = JSON.stringify(
              {
                version: result.stdout,
                format: 'text',
              },
              null,
              2
            );
          }
        } else {
          responseText = result.stdout;
        }
    
        return {
          content: [
            {
              type: 'text' as const,
              text: responseText,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `xcodebuild-version failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • MCP server tool registration for 'xcodebuild-version', including Zod inputSchema validation, description from docs, defer loading config, and wrapper handler that validates Xcode installation before calling the core handler.
    server.registerTool(
      'xcodebuild-version',
      {
        description: getDescription(XCODEBUILD_VERSION_DOCS, XCODEBUILD_VERSION_DOCS_MINI),
        inputSchema: {
          sdk: z.string().optional(),
          outputFormat: z.enum(['json', 'text']).default('json'),
        },
        ...DEFER_LOADING_CONFIG,
      },
      async args => {
        try {
          await validateXcodeInstallation();
          return await xcodebuildVersionTool(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 optional 'sdk' string parameter and 'outputFormat' enum with default 'json'.
    inputSchema: {
      sdk: z.string().optional(),
      outputFormat: z.enum(['json', 'text']).default('json'),
    },
  • Full and mini documentation strings for the tool, used in registration description and rtfm tool.
    export const XCODEBUILD_VERSION_DOCS = `
    # xcodebuild-version
    
    ⚡ **Get Xcode and SDK version information** with structured output
    
    ## What it does
    
    Retrieves comprehensive version information about your Xcode installation and available SDKs. Returns structured JSON data that's easy to parse and validate, eliminating the need to parse raw command-line output. Validates Xcode installation before execution to provide clear error messages if Xcode is not properly configured.
    
    ## Why you'd use it
    
    - Validate environment before running builds or tests (CI/CD validation)
    - Check SDK availability for specific platform versions
    - Ensure consistent Xcode versions across team or build environments
    - Get structured version data for automated tooling and scripts
    
    ## Parameters
    
    ### Optional
    - **sdk** (string): Query specific SDK version (e.g., "iphoneos", "iphonesimulator")
    - **outputFormat** (string, default: 'json'): "json" or "text" output format
    
    ## Returns
    
    Structured JSON response containing Xcode version, build number, and SDK information. Falls back gracefully to text format for older Xcode versions that don't support JSON output.
    
    ## Examples
    
    ### Get Xcode version as JSON
    \`\`\`typescript
    const result = await xcodebuildVersionTool({ outputFormat: "json" });
    \`\`\`
    
    ### Query specific SDK
    \`\`\`typescript
    const sdkInfo = await xcodebuildVersionTool({ sdk: "iphoneos" });
    \`\`\`
    
    ## Related Tools
    
    - xcodebuild-showsdks: Show all available SDKs
    - xcodebuild-list: List project information
    `;
    
    export const XCODEBUILD_VERSION_DOCS_MINI =
      'Get Xcode and SDK version info. Use rtfm({ toolName: "xcodebuild-version" }) for docs.';
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 traits: it performs a read operation (gets info), includes caching for performance, validates installations, and returns structured JSON or text. However, it lacks details on error handling, cache duration, or specific validation failures, leaving some behavioral aspects unclear.

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, starting with a strong recommendation and key advantages. Each sentence earns its place by highlighting benefits (structured output, caching, validation, consistency) and the core purpose, with no redundant or vague information, making it efficient and easy to scan.

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 the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is mostly complete. It covers purpose, advantages, and context well, but lacks details on return values (since no output schema exists) and could benefit from more on error cases or cache behavior. However, it provides sufficient context for effective use in most scenarios.

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?

The input schema has 100% description coverage, so the baseline score is 3. The description does not add specific parameter semantics beyond what the schema provides (e.g., it doesn't explain 'sdk' usage or 'outputFormat' implications in detail), but it hints at context like 'consistent response format' which loosely relates to parameters without adding substantial value.

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 with specific verbs and resources: 'Gets Xcode version info with structured output and caching' and 'Gets comprehensive Xcode and SDK version information for environment validation.' It explicitly distinguishes itself from the direct CLI command 'xcodebuild -version' and from sibling tools by focusing on version retrieval rather than building, cleaning, listing, or SDK operations.

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 -version'**' and lists advantages like structured JSON output, caching, validation, and consistent formatting. It implicitly suggests alternatives (direct CLI or other xcodebuild tools) and clearly defines the context for environment validation, making it easy to choose this over 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