Skip to content

MCP server fails to connect in Claude Code despite working correctly from CLI #210

@seanberry

Description

@seanberry

Description

XcodeBuildMCP v2.0.5 fails to connect when used as an MCP server in Claude Code. The server binary works perfectly from the command line (starts on stdio, registers 24 tools + 5 resources), but Claude Code's /mcp reconnect consistently fails with "Failed to reconnect to XcodeBuildMCP."

Environment

  • XcodeBuildMCP version: 2.0.5 (globally installed via npm install -g xcodebuildmcp@latest)
  • Claude Code version: 2.1.38
  • macOS: Darwin 25.2.0 (arm64, Apple Silicon — MacBook Air M2)
  • Node.js: v23.10.0
  • npm/npx: 11.5.2
  • Xcode: 26.2 (Build 17C52)
  • Global install path: /opt/homebrew/lib/node_modules/xcodebuildmcp/
  • Global binary path: /opt/homebrew/bin/xcodebuildmcp

Steps to Reproduce

  1. Install xcodebuildmcp globally: npm install -g xcodebuildmcp@latest
  2. Verify the server works from CLI: xcodebuildmcp mcp (starts and listens on stdio — works fine)
  3. Configure Claude Code's ~/.claude/mcp.json with the server (see configs tried below)
  4. Run /mcp in Claude Code to reconnect
  5. Result: "Failed to reconnect to XcodeBuildMCP."

Configurations Attempted

Attempt 1: Hardcoded path to cli.js

{
  "mcpServers": {
    "XcodeBuildMCP": {
      "command": "node",
      "args": ["/opt/homebrew/lib/node_modules/xcodebuildmcp/build/cli.js"]
    }
  }
}

Result: Failed — this was from an older install and was missing the mcp subcommand required by v2.x.

Attempt 2: npx with mcp subcommand

{
  "mcpServers": {
    "XcodeBuildMCP": {
      "command": "npx",
      "args": ["-y", "xcodebuildmcp@latest", "mcp"]
    }
  }
}

Result: Failed — npx -y xcodebuildmcp@latest mcp runs fine in terminal (server starts, v2.0.5), but Claude Code cannot connect.

Attempt 3: Global binary directly

{
  "mcpServers": {
    "XcodeBuildMCP": {
      "command": "/opt/homebrew/bin/xcodebuildmcp",
      "args": ["mcp"]
    }
  }
}

Result: Failed — binary works fine from terminal, Claude Code still can't connect.

Attempt 4: Wrapper shell script (current config)

Created /Users/seanberry/bin/xcodebuildmcp-mcp:

#!/usr/bin/env bash
exec /opt/homebrew/bin/xcodebuildmcp mcp
{
  "mcpServers": {
    "XcodeBuildMCP": {
      "command": "/Users/seanberry/bin/xcodebuildmcp-mcp"
    }
  }
}

Result: Failed — same behavior.

What Works

  • Running xcodebuildmcp mcp directly in the terminal starts the server correctly on stdio
  • The server registers 24 tools and 5 resources
  • The wrapper script (exec /opt/homebrew/bin/xcodebuildmcp mcp) also runs fine from terminal

What Doesn't Work

  • Claude Code's /mcp reconnect fails with every configuration above
  • Full Claude Code restarts between config changes were also attempted
  • No error details are provided beyond "Failed to reconnect to XcodeBuildMCP."

Possible Contributing Factors

  • Working directory path contains spaces and parentheses: The project is at ~/Library/Mobile Documents/com~apple~CloudDocs/Coding/Tic Tac Shuffle (iOS)/. This could potentially cause issues with process spawning or path handling.
  • iCloud Drive path: The project lives under Mobile Documents/com~apple~CloudDocs/ which is iCloud Drive — this may have unusual filesystem behavior.
  • Claude Code MCP client behavior: It's unclear what exactly Claude Code does when spawning the MCP server process. There may be environment differences (PATH, working directory, shell) compared to running from a terminal.

Expected Behavior

Claude Code should be able to start the XcodeBuildMCP server process and communicate with it over stdio, the same way it works when running the command manually in a terminal.

Additional Context

This may partially be a Claude Code client issue rather than an XcodeBuildMCP issue, but filing here since the failure is specific to this server. Happy to provide any additional logs or debugging output if there's a way to get more verbose error information from either side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions