Skip to main content
Glama
ebowwa

Xcode MCP Server

by ebowwa

xcode_build_for_device

Build Xcode projects for physical iOS/macOS devices with automatic code signing. Specify project path, scheme, and device ID to generate deployable builds.

Instructions

Build project specifically for physical device with automatic signing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath to .xcodeproj file
schemeYesBuild scheme name
device_idYesPhysical device UUID from list_physical_devices

Implementation Reference

  • Core handler logic for building Xcode project for a specific device using xcodebuild with automatic development team detection and provisioning handling. This is the execution logic for the tool.
    case 'build_with_auto_team':
      // Dynamically detect team and build
      const teamId = await this.fileManager.getDefaultDevelopmentTeam();
      const teamFlag = teamId ? `DEVELOPMENT_TEAM=${teamId}` : '';
      
      const buildCommand = `xcodebuild -project "${args.project_path}" -scheme "${args.scheme}" -destination "id=${args.device_id}" ${teamFlag} -allowProvisioningUpdates -allowProvisioningDeviceRegistration build`;
      
      const { stdout, stderr } = await execAsync(buildCommand);
      output = stdout;
      if (stderr) output += `\n\nWarnings/Errors:\n${stderr}`;
      break;
  • src/index.ts:87-89 (registration)
    Registers the list of available MCP tools, including dynamically generated Xcode tools like xcode_build_for_device.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [...tools, ...webMonitorTools],
    }));
  • MCP CallTool request handler that processes tool calls, strips 'xcode_' prefix from tool name (e.g. xcode_build_for_device -> build_for_device), and delegates to CommandExecutor.executeCommand.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        // Handle web monitor tools
        if (name === 'start_web_monitor') {
          const result = await this.webMonitorManager.start();
          return {
            content: [
              {
                type: 'text',
                text: `${result.message}\n\nWeb interface available at: ${result.url}`
              }
            ]
          };
        }
        
        if (name === 'stop_web_monitor') {
          const result = this.webMonitorManager.stop();
          return {
            content: [
              {
                type: 'text',
                text: result.message
              }
            ]
          };
        }
        
        if (name === 'web_monitor_status') {
          const status = this.webMonitorManager.getStatus();
          let text = status.running 
            ? `Web monitor is running at ${status.url} (port ${status.port})`
            : 'Web monitor is not running';
          return {
            content: [
              {
                type: 'text',
                text: text
              }
            ]
          };
        }
        
        // Handle Xcode commands
        // Remove 'xcode_' prefix if present
        const commandName = name.startsWith('xcode_') ? name.slice(6) : name;
        const result = await this.commandExecutor.executeCommand(commandName, args);
        
        let responseText = result.output;
        if (result.error) {
          responseText += `\n\nWarnings/Errors:\n${result.error}`;
        }
        if (!result.success) {
          responseText = `Command failed: ${result.error}\n\nCommand executed: ${result.command}`;
        }
        
        return {
          content: [
            {
              type: 'text',
              text: responseText,
            },
          ],
        };
  • Dynamically generates MCP tool definitions including name (xcode_ + command name), description, and inputSchema from loaded command definitions.
    // Generate MCP tool definitions from commands
    generateMCPToolDefinitions(): Array<{
      name: string;
      description: string;
      inputSchema: any;
    }> {
      return Object.entries(this.commands).map(([name, command]) => ({
        name: `xcode_${name}`,
        description: command.description,
        inputSchema: {
          type: 'object',
          properties: command.parameters ? Object.fromEntries(
            Object.entries(command.parameters).map(([paramName, paramDef]) => [
              paramName,
              {
                type: paramDef.type,
                description: paramDef.description,
                ...(paramDef.default !== undefined && { default: paramDef.default })
              }
            ])
          ) : {},
          required: command.parameters ? Object.entries(command.parameters)
            .filter(([_, paramDef]) => paramDef.required)
            .map(([paramName]) => paramName) : []
        }
      }));
    }
  • Helper function to detect the default development team ID from Xcode preferences, used in the build process for automatic signing.
    async getDefaultDevelopmentTeam(): Promise<string | null> {
      try {
        const { stdout } = await execAsync('defaults read com.apple.dt.Xcode IDEProvisioningTeamManagerLastSelectedTeamID 2>/dev/null');
        return stdout.trim();
      } catch {
        return null;
      }
    }
Behavior3/5

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

With no annotations, the description carries full burden. It discloses key behavior ('automatic signing') which is crucial for device builds, but doesn't mention other traits like whether this is a read-only operation, potential side effects (e.g., modifying project settings), error conditions, or output format. It adds some value but leaves gaps.

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 a single, efficient sentence that front-loads the core purpose. Every word earns its place, with no redundancy or unnecessary elaboration.

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

Completeness3/5

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

For a 3-parameter tool with no annotations and no output schema, the description is minimally adequate. It covers the purpose and key constraint ('automatic signing'), but lacks details on behavioral traits, error handling, or what the build output entails. It's complete enough for basic understanding but has clear gaps.

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 parameters are fully documented in the schema. The description doesn't add any semantic details beyond what the schema provides (e.g., it doesn't explain parameter relationships or constraints). Baseline 3 is appropriate when the schema does the heavy lifting.

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 specific action ('Build project'), target ('for physical device'), and key constraint ('with automatic signing'). It distinguishes from sibling tools like 'xcode_build_project' (generic build) and 'xcode_run_on_device' (run vs. build).

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

Usage Guidelines4/5

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

The description implies usage context ('for physical device' vs. simulator) and references 'device_id' from 'list_physical_devices', but doesn't explicitly state when NOT to use it or name alternatives like 'xcode_build_project' for simulators. It provides clear prerequisites but lacks explicit exclusions.

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

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/ebowwa/xcode-mcp'

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