xcode-mcp

xcode-mcp

Bridges AI assistants with Xcode to control projects, builds, simulators, testing, and debugging without manual interaction.

Category
访问服务器

README

xcode-mcp

MCP (Model Context Protocol) server that bridges AI assistants with Xcode, enabling full control over Xcode projects, builds, simulators, testing, and debugging — all without touching Xcode manually.

macOS only. Xcode 14+ required. Node 18+ required.

Quick Install

macOS / Linux:

curl -sL https://raw.githubusercontent.com/Raunaksplanet/xcode-mcp-server/main/install.sh | bash
# or locally:
./install.sh

Windows (PowerShell):

.\install.ps1

The installer: checks prerequisites, installs deps, builds, prompts for your Xcode project path, and registers with OpenCode automatically.

Manual Setup

npm install
npm run build
export XCODE_PROJECT_PATH=/path/to/YourApp.xcodeproj
npm start

OpenCode Integration

Clone the repo and add to ~/.config/opencode/opencode.json:

{
  "mcpServers": {
    "xcode": {
      "command": "node",
      "args": ["path/to/xcode-mcp/dist/index.js"],
      "env": {
        "XCODE_PROJECT_PATH": "/path/to/YourApp.xcodeproj",
        "XCODE_DEFAULT_SCHEME": "YourApp"
      }
    }
  }
}

Environment Variables

Variable Required Description
XCODE_PROJECT_PATH Yes Path to .xcodeproj or .xcworkspace
XCODE_DEFAULT_SCHEME No Default scheme for build/test operations
XCODE_DEFAULT_SIMULATOR No Default simulator UDID or name
XCODE_DERIVED_DATA_PATH No Custom DerivedData path
XCODE_MCP_LOG_LEVEL No Log level: debug/info/warn/error (default: info)
XCODE_MCP_BUILD_TIMEOUT No Build timeout in seconds (default: 300)
XCODE_MCP_TEST_TIMEOUT No Test timeout in seconds (default: 600)

Configuration File

Place .xcode-mcp.json next to your .xcodeproj:

{
  "default_scheme": "MyApp",
  "default_simulator": "iPhone 16 Pro",
  "excluded_paths": ["Pods", "vendor"],
  "build_pre_hooks": ["echo 'Starting build...'"],
  "build_post_hooks": ["echo 'Build complete!'"],
  "custom_destinations": ["platform=iOS Simulator,name=iPhone 16,OS=latest"]
}

Available Tools

Project Management

  • xcode_open_project — Open project in Xcode
  • xcode_get_project_info — Get project info (targets, schemes, configs)
  • xcode_list_targets — List all targets
  • xcode_list_schemes — List all schemes
  • xcode_list_files — List project files
  • xcode_add_file — Add file to project
  • xcode_remove_file — Remove file from project
  • xcode_get_build_settings — Get resolved build settings
  • xcode_set_build_setting — Modify build settings
  • xcode_resolve_packages — Resolve SPM dependencies

Build Tools

  • xcode_build — Build the project
  • xcode_build_for_testing — Build for testing
  • xcode_archive — Archive for distribution
  • xcode_clean — Clean build artifacts
  • xcode_get_build_errors — Parse build errors/warnings
  • xcode_get_analyzer_results — Run static analyzer

Simulator Control

  • xcode_list_simulators — List available simulators
  • xcode_boot_simulator — Boot a simulator
  • xcode_shutdown_simulator — Shutdown simulator
  • xcode_install_app — Install app on simulator
  • xcode_launch_app — Launch app on simulator
  • xcode_terminate_app — Terminate app
  • xcode_get_simulator_logs — Fetch simulator logs
  • xcode_screenshot_simulator — Take screenshot
  • xcode_record_simulator — Record video
  • xcode_open_url_simulator — Open URL (deep link testing)
  • xcode_set_simulator_location — Set location
  • xcode_push_notification_simulator — Simulate push notification
  • xcode_reset_simulator — Reset to factory state

Testing

  • xcode_run_tests — Run all tests
  • xcode_run_single_test — Run specific test
  • xcode_get_test_results — Parse xcresult bundle
  • xcode_get_code_coverage — Get coverage report

Code Management

  • xcode_read_file — Read file content
  • xcode_write_file — Write file content
  • xcode_edit_file — Find and replace in file
  • xcode_get_swift_symbols — Extract Swift symbols
  • xcode_format_file — Format with swift-format
  • xcode_search_in_project — Search across project files

Code Signing

  • xcode_list_certificates — List signing certificates
  • xcode_list_provisioning_profiles — List provisioning profiles
  • xcode_set_signing — Configure signing settings
  • xcode_validate_signing — Verify code signature

Diagnostics

  • xcode_get_warnings — Get build warnings
  • xcode_profile_app — Profile with Instruments
  • xcode_add_spm_package — Add SPM dependency

Resources

  • xcode://project/structure — Project file tree
  • xcode://project/settings — All build settings
  • xcode://build/latest_log — Latest build log
  • xcode://build/errors — Parsed build errors
  • xcode://simulators/list — Available simulators

Prompts

  • fix_build_error — Fix a build error with context
  • create_swift_feature — Implement a Swift feature
  • write_xctest — Generate XCTest cases
  • review_swift_code — Swift best practices review

Architecture

xcode-mcp/
├── src/
│   ├── index.ts          # Entry point
│   ├── server.ts         # MCP server setup
│   ├── tools/            # Tool implementations
│   ├── lib/              # Core libraries
│   │   ├── xcode_runner.ts    # xcodebuild/xcrun wrappers
│   │   ├── pbxproj_parser.ts  # PBXProject parser
│   │   ├── pbxproj_writer.ts  # PBXProject writer
│   │   ├── simulator_manager.ts # simctl wrapper
│   │   ├── process_manager.ts  # Process lifecycle
│   │   ├── logger.ts           # Structured logging
│   │   ├── error_handler.ts    # Error mapping
│   │   └── config.ts          # Configuration
│   ├── types/            # TypeScript type definitions
│   ├── resources/        # MCP resource providers
│   └── prompts/          # MCP prompt templates
├── package.json
└── tsconfig.json

Security

  • All file paths are validated against the project root
  • Command injection prevented via execFile with args arrays
  • Sensitive data (certificates, keys) never logged
  • Concurrent xcodebuild calls are queued (max 2)
  • Path traversal detection on all file operations

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选