
Xcodemcp
io.github.lapfelix由 GitHub 帳號 lapfelix 發布v2.1.4更新於 Oct 24, 2026
Control Xcode directly via JXA for build, test, debug operations with XCLogParser integration
概覽
在 macOS 上透過 JavaScript for Automation 控制 Xcode 的本機 MCP 伺服器,讓助理開啟專案、建置、測試、除錯並分析測試結果
- 可以做什麼
- 開啟專案與工作區、檢視工作區資訊、列出專案、依行號開啟檔案,以及列出或切換 scheme 與執行目標,並可執行環境健康檢查。建置、清理、測試、建置並執行、啟動除錯和停止目前操作,建置錯誤會被解析出精確位置。瀏覽 XCResult 結果包:摘要、主控台輸出、截圖、UI 階層與 UI 元素詳情,並列出或匯出測試附件。
- 適用情境
- 適合讓助理在 Mac 上直接操作既有的 Xcode 專案:建置與執行應用程式、執行測試、除錯失敗,以及深入分析 XCResult 測試結果。也可與 Apple 官方 Xcode MCP 並行,以 sidekick 模式只提供專案管理與結果分析。
- 執行需求
- macOS 且已安裝 Xcode,Node.js 18 以上版本,並透過 stdio 在本機執行 npm 套件。XCLogParser 為選用但建議安裝,用於精確解析建置錯誤。需要授予 Xcode 自動化權限。選用環境變數可設定偏好 scheme 與專案、日誌等級和日誌檔。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Xcodemcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Using with Apple's Official Xcode MCP: Apple now provides an official Xcode MCP server. XcodeMCP can run alongside it in sidekick mode (
--sidekick-only), providing complementary tools like project management and XCResult analysis. In a future version, XcodeMCP will transition to sidekick-only mode by default. See configuration below.
XcodeMCP
Model Context Protocol (MCP) server that controls Xcode directly through JavaScript for Automation (JXA). Available as both an MCP server and a standalone CLI.
What it does
- Controls Xcode directly through JavaScript for Automation (not xcodebuild CLI)
- Opens projects, builds, runs, tests, and debugs from within Xcode
- Parses build logs with precise error locations using XCLogParser
- Provides comprehensive environment validation and health checks
- Supports graceful degradation when optional dependencies are missing
- NEW: Includes a full-featured CLI with 100% MCP server feature parity
Requirements
- macOS with Xcode installed
- Node.js 18+
- XCLogParser (recommended):
brew install xclogparser
Usage
XcodeMCP can be used in two ways:
- MCP Server: Integrate with Claude Desktop, VS Code, or other MCP clients
- CLI Tool: Run commands directly from the terminal with
xcodecontrol
Quick Install
[Install in VS Code] [Install in VS Code Insiders] [Install MCP Server]
XCLogParser is recommended but optional:
Install from npm
Run directly with npx:
Or install globally:
MCP Configuration
Add to your MCP configuration:
Claude Code CLI Setup
To add XcodeMCP to Claude Code using the command line:
Without the clean build folder tool
To add XcodeMCP to Claude Code using the command line:
Using Preferred Values for Single Project Workflows
For projects where you're working with a single xcodeproj and scheme, you can configure preferred values to make tool parameters optional:
With preferred values configured:
- Tool parameters become optional instead of required
- Tool descriptions show default values (e.g., "defaults to MyApp.xcodeproj")
- You can still override defaults by providing explicit parameters
- Reduces repetition when working with a single project
Troubleshooting
If /mcp in Claude Code indicates the MCP failed, try running it from the project folder manually to see what the output is: npx -y xcodemcp@latest
Sidekick Mode
When using XcodeMCP alongside Apple's official Xcode MCP server, enable sidekick mode to only include complementary tools:
- Project management: Open/close projects, manage schemes, workspace info
- XCResult analysis: Browse test results, extract screenshots, inspect UI hierarchies
This excludes build/run/test/debug tools that Apple's MCP handles natively.
Claude Code CLI Setup (Both Servers)
First, enable Xcode Tools in Xcode > Settings > Intelligence > Model Context Protocol.
Then add both Apple's Xcode MCP and XcodeMCP in sidekick mode:
JSON Configuration (Both Servers)
Future direction: In a future version, XcodeMCP will transition to sidekick-only mode by default, focusing exclusively on tools that complement Apple's official Xcode MCP rather than duplicating functionality.
Development Setup
For local development:
CLI Usage
XcodeMCP includes a powerful CLI that provides 100% feature parity with the MCP server, allowing you to run any tool as a one-shot command:
Installation
Install globally to use the CLI:
Basic Usage
Path Resolution
The CLI supports both absolute and relative paths for convenience:
Relative paths are resolved from your current working directory, making the CLI much more convenient to use when working within project directories.
Verbosity Control
Control logging output with verbosity flags:
Quick Examples
Tool Name Mapping
CLI commands use kebab-case instead of underscores:
xcode_build→buildxcode_test→testxcode_build_and_run→build-and-runxcode_health_check→health-checkxcresult_browse→xcresult-browsefind_xcresults→find-xcresults
Available Tools
Project Management:
xcode_open_project- Open projects and workspacesxcode_get_workspace_info- Get workspace status and detailsxcode_get_projects- List projects in workspacexcode_open_file- Open files with optional line number
Build Operations:
xcode_build- Build with detailed error parsingxcode_clean- Clean build artifactsxcode_test- Run tests with optional argumentsxcode_build_and_run- Build and run the active schemexcode_debug- Start debugging sessionxcode_stop- Stop current operation
Configuration:
xcode_get_schemes- List available schemesxcode_set_active_scheme- Switch active schemexcode_get_run_destinations- List simulators and devices
XCResult Analysis:
xcresult_browse- Browse test results and analyze failuresxcresult_browser_get_console- Get console output for specific testsxcresult_summary- Quick overview of test resultsxcresult_get_screenshot- Extract screenshots from test failuresxcresult_get_ui_hierarchy- Get UI hierarchy as AI-readable JSON with timestamp selectionxcresult_get_ui_element- Get detailed properties of specific UI elements by indexxcresult_list_attachments- List all attachments for a testxcresult_export_attachment- Export specific attachments from test results
Diagnostics:
xcode_health_check- Environment validation and troubleshooting
XCResult Analysis Features
XcodeMCP provides comprehensive tools for analyzing Xcode test results (.xcresult files), making it easy to debug test failures and extract valuable information:
Test Result Analysis
- Browse Results: Navigate through test hierarchies, view pass/fail status, and examine detailed test information
- Console Logs: Extract console output and test activities with precise timestamps for debugging
- Quick Summaries: Get overview statistics including pass rates, failure counts, and duration
Visual Debugging
- Screenshot Extraction: Extract PNG screenshots from test failures using ffmpeg frame extraction from video attachments
- Timestamp Precision: Specify exact timestamps to capture UI state at specific moments during test execution
UI Hierarchy Analysis
- AI-Readable Format: Extract UI hierarchies as compressed JSON with single-letter properties (
t=type,l=label,f=frame,c=children,j=index) - Timestamp Selection: Automatically find the closest UI hierarchy capture to any specified timestamp
- Element Deep-Dive: Use index references to get full details of any UI element, including accessibility properties and frame information
- Size Optimization: 75%+ size reduction compared to full hierarchy data while maintaining all essential information
Attachment Management
- Complete Inventory: List all attachments (screenshots, videos, debug descriptions, UI hierarchies) for any test
- Selective Export: Export specific attachments by index or type
- Smart Detection: Automatically identify and categorize different attachment types
Usage Examples
Configuration
Logging Configuration
XcodeMCP supports configurable logging to help with debugging and monitoring:
Environment Variables
-
LOG_LEVEL: Controls logging verbosity (default:INFO)SILENT: No logging outputERROR: Only error messagesWARN: Warnings and errorsINFO: General operational information (recommended)DEBUG: Detailed diagnostic information
-
XCODEMCP_LOG_FILE: Optional file path for logging- Logs are written to the specified file in addition to stderr
- Parent directories are created automatically
- Example:
/tmp/xcodemcp.logor~/Library/Logs/xcodemcp.log
-
XCODEMCP_CONSOLE_LOGGING: Enable/disable console output (default:true)- Set to
falseto disable stderr logging (useful when using file logging only)
- Set to
Examples
Debug logging with file output:
Silent mode (no logging):
File-only logging:
All logs are properly formatted with timestamps and log levels, and stderr output maintains compatibility with the MCP protocol.
Troubleshooting
XCLogParser Not Found
If you see a warning that XCLogParser is not found even though it's installed:
-
Verify installation:
-
Common issues and solutions:
-
PATH issue: If
which xclogparserreturns nothing, add the installation directory to your PATH: -
Wrong command: Older documentation may reference
xclogparser --version, but the correct command isxclogparser version(without dashes) -
Permission issue: Ensure xclogparser is executable:
-
-
Environment validation: Run the health check to get detailed diagnostics:
Note: XcodeMCP can operate without XCLogParser, but build error parsing will be limited.
Example Output
Build with errors:
Health check:
來源:README.md,提交 8124fd1
工具
0版本歷史
1- v2.1.4最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分