iOS模拟器MCP服务器
 ](https://www.npmjs.com/package/ios-simulator-mcp)
用于与iOS模拟器交互的模型上下文协议(MCP)服务器。此服务器允许您通过获取有关iOS模拟器的信息、控制UI交互和检查UI元素来与它们进行交互。
安全通知:已修复版本\;
}
**笔记:** 环境变量通过以下方式传递 `SIMCTL_CHILD_` 因为 `simctl launch` 不支持 `--env/--envs` 在所有Xcode版本上。
**例子:**
{ "bundle_id": "com.example.app", "terminate_running": true, "env": { "FOO": "bar", "BAZ": "qux" } }
## 💡 用例:通过MCP工具调用进行QA步骤
此MCP服务器允许与模型上下文协议(MCP)客户端集成的AI助手通过调用工具来执行质量保证任务。这在实现功能后立即有用,有助于确保UI一致性和正确行为。
### 如何使用
在功能实现后,指示您的人工智能助手在其MCP客户端环境中使用可用的工具。例如,在Cursor的代理模式下,您可以使用下面的提示快速验证和记录UI交互。
### 示例提示
- **验证UI元素:**
Verify all accessibility elements on the current screen
- **确认文本输入:**
Enter "QA Test" into the text input field and confirm the input is correct
- **检查点击响应:**
Tap on coordinates x=250, y=400 and verify the expected element is triggered
- **验证滑动操作:**
Swipe from x=150, y=600 to x=150, y=100 and confirm correct behavior
- **详细元素检查:**
Describe the UI element at position x=300, y=350 to ensure proper labeling and functionality
- **向您的AI代理显示模拟器屏幕:**
View the current simulator screen
- **拍摄屏幕截图:**
Take a screenshot of the current simulator screen and save it to my_screenshot.png
- **录制视频:**
Start recording a video of the simulator screen (saves to the default output directory, which is ~/Downloads unless overridden by IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR)
- **停止录制:**
Stop the current simulator screen recording
- **安装应用程序:**
Install the app at path/to/MyApp.app on the simulator
- **启动应用程序:**
Launch the Safari app (com.apple.mobilesafari) on the simulator
## 先决条件
- Node.js
- macOS(因为iOS模拟器仅在macOS上可用)
- [项目](https://developer.apple.com/xcode/resources/) 已安装iOS模拟器
- 脸书 [国际开发银行](https://fbidb.io/) 工具 [(请参阅安装指南)](https://fbidb.io/docs/installation)
## 安装
本节提供了将iOS模拟器MCP服务器与不同模型上下文协议(MCP)客户端集成的说明。
### 使用游标安装
Cursor通过其位于以下位置的配置文件管理MCP服务器 `~/.cursor/mcp.json`.
#### 选项1:使用NPX(推荐)
1. 编辑光标MCP配置文件。您通常可以直接从Cursor打开它,也可以使用以下命令:# Open with your default editor (or use 'code', 'vim', etc.) open ~/.cursor/mcp.json # Or use Cursor's command if available # cursor ~/.cursor/mcp.json
1. 添加或更新 `mcpServers` iOS模拟器服务器配置部分:{ "mcpServers": { // ... other servers might be listed here ... "ios-simulator": { "command": "npx", "args": ["-y", "ios-simulator-mcp"] } } }
确保JSON结构有效,特别是在以下情况下 `mcpServers` 已经存在。
1. 重新启动Cursor以使更改生效。
#### 方案2:地方发展
1. 克隆此存储库:git clone https://github.com/joshuayoes/ios-simulator-mcp cd ios-simulator-mcp
1. 安装依赖项:npm install
1. 构建项目:npm run build
1. 编辑光标MCP配置文件(如选项1所示)。
1. 添加或更新 `mcpServers` 部分,指向您的本地版本:{ "mcpServers": { // ... other servers might be listed here ... "ios-simulator": { "command": "node", "args": ["/full/path/to/your/ios-simulator-mcp/build/index.js"] } } }
**重要提示:** 替换 `/full/path/to/your/` 带有克隆位置的绝对路径 `ios-simulator-mcp` 存储库。
1. 重新启动Cursor以使更改生效。
### 使用Claude代码进行安装
Claude Code CLI可以使用 `claude mcp` 命令或直接编辑其配置文件。有关Claude Code MCP配置的更多详细信息,请参阅 [官方文档](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp).
#### 选项1:使用NPX(推荐)
1. 使用添加服务器 `claude mcp add` 命令:claude mcp add ios-simulator npx ios-simulator-mcp
1. 如有必要,重新启动任何正在运行的Claude Code会话。
#### 方案2:地方发展
1. 克隆此存储库,安装依赖项,并按照游标“本地开发”步骤1-3中的描述构建项目。
1. 使用添加服务器 `claude mcp add` 命令,指向您的本地版本:claude mcp add ios-simulator -- node "/full/path/to/your/ios-simulator-mcp/build/index.js"
**重要提示:** 替换 `/full/path/to/your/` 带有克隆位置的绝对路径 `ios-simulator-mcp` 存储库。
1. 如有必要,重新启动任何正在运行的Claude Code会话。
## 配置
### 环境变量
|变量|描述|示例|
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
| `IOS_SIMULATOR_MCP_FILTERED_TOOLS` |以逗号分隔的工具名称列表,用于从注册中筛选出来。 | `screenshot,record_video,stop_recording` |
| `IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR` |为屏幕截图和视频录制等输出文件指定默认目录。如果未设置, `~/Downloads` 将被使用。如果您的代理对文件系统的访问权限有限,这可能会很方便。 | `~/Code/awesome-project/tmp` |
| `IOS_SIMULATOR_MCP_IDB_PATH` |指定IDB可执行文件的自定义路径。如果未设置, `idb` 将被使用(假设它在您的PATH中)。如果IDB安装在非标准位置,则很有用。 | `~/bin/idb` 或 `/usr/local/bin/idb` |
#### 配置示例
{ "mcpServers": { "ios-simulator": { "command": "npx", "args": ["-y", "ios-simulator-mcp"], "env": { "IOS_SIMULATOR_MCP_FILTERED_TOOLS": "screenshot,record_video,stop_recording", "IOS_SIMULATOR_MCP_DEFAULT_OUTPUT_DIR": "~/Code/awesome-project/tmp", "IOS_SIMULATOR_MCP_IDB_PATH": "~/bin/idb" } } } }
## MCP注册表服务器列表
](https://mseep.ai/app/joshuayoes-ios-simulator-mcp)
## 许可证
麻省理工学院
