使用说明
iPhone MCP server that lets AI use iPhones
iPhone mcp
MCP服务器,允许AI代理在MacOS上控制真实的iPhone和iPhone模拟器。 适用于Claude Code、Cursor、Codex、OpenCode和任何兼容MCP的AI代理。
需求
- macOS
- Xcode(从App Store或
xcode-select --install) - Node.js 18+
- 家酿
安装
npm install @blitzdev/iphone-mcp
快速开始
全局(在任何项目中使用)
npx @blitzdev/iphone-mcp --setup-all
这将安装依赖关系并配置 @blitzdev/iphone-mcp 对于您的所有AI代理。它会自动设置Claude Code、Cursor、Codex、OpenCode。
注意:对于Cursor,您需要在Cursor设置中启用blitz iphone MCP服务器
项目范围(仅一个项目)
cd <your project>
npx @blitzdev/iphone-mcp --setup-here
这会提示您选择要配置的AI代理(Claude Code、Cursor、Codex、OpenCode),并将配置文件写入您的项目目录。 @blitzdev/iphone-mcp 仅当您在该目录中打开代理时才可用。
那就问吧
打开一个新的AI代理会话并询问:
> scan the simulator screen and tell me what you see
> connect to my iPhone and test the login flow
> find bugs in my app — tap around, try edge cases, report anything weird
它能做什么?
| 功能 | 模拟器 | 物理iPhone |
|---|---|---|
| 点击、滑动、键入文本 | 是 | 是 |
| 按下按钮(主页、锁定、Siri) | 是 | 是 |
| 使用坐标扫描UI元素 | 是 | 是 |
| 截图 | 是 | 是 |
| 列出并启动已安装的应用程序 | 是 | 是 |
| 自动检测设备 | 是 | 是 |
| 浏览器中的实时屏幕查看器 | -- | 是 |
iPhone
通过USB连接您的iPhone,或确保它在同一个Wi-Fi网络上(家庭/办公室网络工作,公共咖啡馆Wi-Fi无法工作)。
首次设置 --您的iPhone需要:
- 开发者模式 已启用(设置>隐私和安全>开发人员模式)
- 信任此计算机 当电话提示时
然后问你的经纪人:
> connect to my iPhone
代理将在您的手机上构建并安装WebDriver agent(第一次需要1-3分钟),然后给您一个URL,如下所示 http://localhost:5152?udid=... --在浏览器中打开它,查看手机屏幕的实时视图。
模拟器
启动任何iPhone模拟器,然后让你的AI代理与之交互。除此之外,不需要额外的设置 --setup-all 或 --setup-here.
> what apps are installed on the simulator?
> launch Safari and go to example.com
> take a screenshot
示例会话
You: test the checkout flow in my app
Agent: Let me scan the simulator to see what's on screen.
[calls scan_ui]
I can see the home screen. Let me launch your app first.
[calls launch_app with bundleId "com.myapp"]
[calls get_screenshot]
The app is open on the main screen. I see a "Shop" tab at the bottom.
Let me tap it and walk through the checkout flow.
[calls device_action: tap on "Shop" tab]
[calls scan_ui]
I see a list of products. Let me add one to cart...
MCP工具参考
这些是您的AI代理可以调用的工具:
| 工具 | 它做什么 |
|---|---|
get_execution_context |
查找可用的模拟器和iPhone |
scan_ui |
查找可点击的元素——按钮、链接、文本字段——及其坐标 |
describe_screen |
完整的UI元素层次结构(比scan_UI更详细) |
device_action |
轻触、滑动、按下按钮、键入文本、按键 |
device_actions |
按顺序运行多个操作 |
get_screenshot |
保存屏幕截图并返回文件路径 |
list_devices |
列出所有模拟器和物理设备 |
launch_app |
按捆绑包ID启动应用程序 |
list_apps |
列出已安装的应用程序 |
setup_device |
在物理iPhone上构建并安装WebDriver Agent |
手动MCP配置
如果你宁愿自己配置:
克劳德代码 --添加到 ~/.claude.json (全球)或 .mcp.json (项目):
{
"mcpServers": {
"blitz-iphone": {
"command": "npx",
"args": ["@blitzdev/iphone-mcp"]
}
}
}
光标 --添加到 ~/.cursor/mcp.json (全球)或 .cursor/mcp.json (项目):
{
"mcpServers": {
"blitz-iphone": {
"command": "npx",
"args": ["@blitzdev/iphone-mcp"]
}
}
}
法典 --添加到 ~/.codex/config.toml (全球)或 .codex/config.toml (项目):
[mcp_servers.blitz-iphone]
command = "npx"
args = ["@blitzdev/iphone-mcp"]
开源代码 --添加到 opencode.json 在项目根目录中:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"blitz-iphone": {
"type": "local",
"command": ["npx", "-y", "@blitzdev/iphone-mcp"],
"enabled": true
}
}
}
故障排除
“未找到已启动的模拟器” --打开模拟器.app或运行 xcrun simctl boot "iPhone 16" 第一。
未检测到物理设备 --确保开发人员模式已打开,手机已通过USB连接,并且您已点击手机上的“信任”。
WDA构建失败 --打开Xcode>设置>帐户,确保已登录Apple ID。Xcode需要一个签名身份来构建WDA。
“连接被拒绝”错误 --idb同伴可能已经坠毁。跑 npx @blitzdev/iphone-mcp --setup-all 再次重新初始化。
许可证
麻省理工学院