XCode CLI MCP:Xcode CLI 工具和 iOS 模拟器的便利封装器。逐步披露工具响应以减少上下文使用。仅构建时使用 --mini 参数,上下文占用极小。
概览
通过智能上下文工程,XC-MCP使Xcode和iOS模拟器工具对AI代理更为可访问。—— Claude的工具搜索自动按需发现工具,最大限度地减少基线上下文开销,同时保持完整的29个工具功能。 传统的 Xcode CLI 封装器会导出超过MCP协议限制的大量输出:- simctl列表:57,000+令牌(在MCP环境中不可用) - 构建日志:135,000+ 令牌(灾难性溢出) - 先截图自动化:每屏170个令牌,延迟2000毫秒 - 操作间无状态存储 - ✅ - 所有工具都被推迟;Claude按需发现 - ✅ - 用于常见操作的高级抽象 - ✅ - 平台负责工具发现 - ✅ (比截图快3-4倍,成本3-4倍)-✅(缓存→ ID摘要→按需提供完整细节)- ✅ 并支持全面的错误处理 添加到 ~/Library/Application Support/Claude/claude_desktop_config。
概述(AI 翻译)
一个MCP服务器,允许AI代理构建、运行和驱动iOS应用——而不会被Xcode的输出淹没。
XC-MCP将xcodebuild、simctl和[idb包裹成77个工具。它的工作不仅仅是暴露这些工具
命令,但为了使其输出符合模型上下文:先做摘要,按需提供完整细节,
以及应用允许的地方用无障碍树代替截图。
为什么它存在
Xcode 工具输出的规模是没有上下文窗口存活的。与真实应用比较 (Grapla,Xcode 27,iPhone 17 Pro 模拟器):
| 操作 | 原始输出 | XC-MCP 响应 | 简化 |
|---|---|---|---|
一个增量xcodebuild build |
1.67 MB ·~419,000个代币 | 1.1 KB ·~285个代币 | ~1,470× |
xcrun simctl list --json |
131 KB ·~32,800个令牌 | 1.5 KB ·~370个令牌 | ~90× |
一份坠机报告(.ips) |
10.7 KB | 1.4 KB 摘要 | ~7.5× |
单一原始构建日志本身就会溢出一个20万令牌的上下文。完整输出永远不会是 丢弃:它被缓存并作为MCP资源链返回,以便代理可以钻探 它需要的准确错误。
快速开始
克劳德代码:
法典CLI:
或者添加到“~/.codex/config”中。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
XC-MCP
An MCP server that lets AI agents build, run and drive iOS apps — without drowning in Xcode’s output.
XC-MCP wraps xcodebuild, simctl and idb as 81 tools. Its job is not just to expose those
commands but to make their output fit in a model’s context: summaries first, full detail on demand,
and the accessibility tree instead of screenshots wherever the app allows it.
Why it exists
Xcode tooling produces output at a scale no context window survives. Measured against a real app (Grapla, Xcode 27, iPhone 17 Pro simulator):
| Operation | Raw output | XC-MCP response | Reduction |
|---|---|---|---|
One incremental xcodebuild build |
1.67 MB · ~419,000 tokens | 1.1 KB · ~285 tokens | ~1,470× |
xcrun simctl list --json |
131 KB · ~32,800 tokens | 1.5 KB · ~370 tokens | ~90× |
One crash report (.ips) |
10.7 KB | 1.4 KB summary | ~7.5× |
A single raw build log would overflow a 200k-token context on its own. The full output is never thrown away: it is cached and returned as an MCP resource link, so an agent can drill into the exact errors it needs.
Quick start
Claude Code:
claude mcp add xc-mcp -- npx -y xc-mcp
Codex CLI:
codex mcp add xc-mcp -- npx -y xc-mcp
or add it to ~/.codex/config.toml directly:
[mcp_servers.xc-mcp]
command = "npx"
args = ["-y", "xc-mcp"]
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"xc-mcp": { "command": "npx", "args": ["-y", "xc-mcp"] }
}
}
Then ask your agent to build and run your app. rtfm({}) lists the tool categories.
Requirements
| Requirement | Version | Needed for |
|---|---|---|
| macOS | 13+ | everything |
| Node.js | 20+ (CI tests 22 and 24) | running the server |
| Xcode + Command Line Tools | 15+ (26+ for iOS 26/27 simulators) | xcodebuild, simctl |
idb CLI + companion |
1.5.1+ | every idb-* tool: tapping, typing, accessibility |
xcode-select --install
# idb — required for all UI automation
brew tap facebook/fb
brew install facebook/fb/idb-companion facebook/fb/idb-cli
brew install idb-companionno longer works — it moved from Homebrew core to Meta’sfacebook/fbtap.
Run idb-doctor whenever UI automation misbehaves. It checks the CLI, the companion version,
the Xcode framework layout, stale companion registrations, CLI/companion version mismatches, and the axbridge guest needed by deep reads.
Xcode 27
安装
npx -y xc-mcp配置
{
"mcpServers": {
"xc-mcp": { "command": "npx", "args": ["-y", "xc-mcp"] }
}
}