Xcode MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Facilitates iOS app development by providing build and test capabilities for iOS simulator targets, with default configuration for iPhone 15 Pro simulator.

  • Enables building and testing Xcode projects with the ability to specify schemes, configurations, and destinations. Supports running specific tests, generating code coverage reports, and accessing build and test logs.

Xcode MCP 服务器

Xcode MCP 服务器提供了用于构建和测试 Xcode 项目的模型上下文协议 (MCP) 接口。它使 AI 助手能够通过标准化接口直接触发构建、运行测试、监控进度和访问日志。

特征

  • 使用自定义方案和配置构建 Xcode 项目
  • 运行具有精细控制的单元测试(运行特定测试或跳过测试)
  • 生成代码覆盖率报告
  • 实时传输构建和测试日志
  • 访问详细的构建和测试报告
  • JSON 格式的输出
  • 自动日志持久化

要求

  • Node.js 16+
  • Xcode 命令行工具
  • TypeScript
  • MCP 兼容客户端(例如 Claude Desktop)

安装

# Clone the repository git clone https://github.com/PolarVista/Xcode-mcp-server.git cd xcode-mcp-server # Install dependencies npm install # Build the server npm run build

与 Claude Desktop 一起使用

  1. 启动服务器:
    npm run start /path/to/build/logs/directory
  2. 在 Claude Desktop 设置中:
    "command": "node", "args": ["/path/to/the/xcode-mcp-server/build/index.js", "/path/to/your/project/folder"], "env": { "PATH": "/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin" }

可用工具

构建项目

使用指定的参数构建 Xcode 项目。

参数:

  • projectPath (必需):.xcodeproj 或 .xcworkspace 的路径
  • scheme (必填):构建方案名称
  • configuration (可选):构建配置(调试/发布,默认为调试)
  • destination (可选):构建目标(默认为“platform=iOS Simulator,name=iPhone 15 Pro”)

Claude 中的用法示例:

build_project({ projectPath: "/path/to/Project.xcodeproj", scheme: "MyApp", configuration: "Debug" })

运行测试

运行带有可选过滤的单元测试。

参数:

  • projectPath (必需):.xcodeproj 或 .xcworkspace 的路径
  • scheme (必填):测试方案名称
  • testIdentifier (可选):要运行的特定测试(例如,“MyTests/testExample”)
  • skipTests (可选):要跳过的测试标识符数组
  • configuration (可选):构建配置(调试/发布,默认为调试)
  • destination (可选):测试目的地(默认为“platform=iOS Simulator,name=iPhone 15 Pro”)

Claude 中的用法示例:

run_tests({ projectPath: "/path/to/Project.xcodeproj", scheme: "MyAppTests", testIdentifier: "LoginTests/testSuccessfulLogin", skipTests: ["PerformanceTests/testLargeDataLoad"], configuration: "Debug" })

日志

  • 所有日志都存储在build-logs/下的指定基础目录中
  • 构建操作创建:
    • 纯文本日志( build-[timestamp].log
    • JSON 格式的日志( build-[timestamp].log.json
    • Xcode 报告( report-[timestamp].txt
  • 测试操作创建:
    • 测试日志( test-[timestamp].log
    • JSON 格式的日志( test-[timestamp].log.json
    • 测试报告( test-report-[timestamp].txt
    • 代码覆盖率报告( coverage-[timestamp].txt
  • 最新日志(构建或测试)可通过xcode-build://latest-log资源访问
-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器,使 AI 助手能够直接通过标准化界面构建和测试 Xcode 项目,并具有运行测试、监控进度和实时访问日志的功能。

  1. Features
    1. Requirements
      1. Installation
        1. Usage with Claude Desktop
          1. Available Tools
            1. build_project
            2. run_tests
          2. Logs
            ID: 0ewrg3bfpc