README
🚀 iOS 模拟器 MCP 服务器
这是一个用于与 iOS 模拟器交互的模型上下文协议(MCP)服务器。借助该服务器,您能够获取模拟器的相关信息、控制 UI 交互并检查 UI 元素,从而实现与 iOS 模拟器的交互。
https://github.com/user-attachments/assets/453ebe7b-cc93-4ac2-b08d-0f8ac8339ad3
🚀 快速开始
在使用本服务器前,您需要满足以下先决条件:
- Node.js 版本 >= 8.0.0
- npm 或 yarn 包管理器
- 安装并配置了 iOS 模拟器工具链
✨ 主要特性
- 广泛兼容:支持多种 iOS 模拟器版本。
- 高效管理:具备高效的状态管理和上下文跟踪能力。
- 灵活处理:拥有灵活的事件处理机制。
- 调试便利:提供详细的日志记录和调试选项。
📦 安装指南
使用 Cursor 进行安装
- 使用 NPX 快速安装:
npx ios-simulator-mcp --install - 本地构建和安装(可选):
git clone https://github.com/joshuayoes/ios-simulator-mcp.git cd ios-simulator-mcp npm install npm run build
使用 Claude Code 进行安装
- 使用 NPX 快速添加服务器:
claude mcp add ios-simulator --command npx --args "-y,ios-simulator-mcp" - 本地构建和添加(可选):
git clone https://github.com/joshuayoes/ios-simulator-mcp.git cd ios-simulator-mcp npm install npm run build claude mcp add ios-simulator --command node --args "/full/path/to/build/index.js"
💻 使用示例
基础用法
const { SimulatorMcpServer } = require('ios-simulator-mcp');
// 创建服务器实例
const server = new SimulatorMcpServer({
port: 3001,
mode: 'development',
logging: true
});
// 启动服务器
server.start().then(() => {
console.log('服务器已启动并在端口 3001 上监听');
}).catch(err => {
console.error('启动服务器时出错:', err);
});
高级用法
const { SimulatorMcpServer } = require('ios-simulator-mcp');
// 创建并配置服务器实例
const server = new SimulatorMcpServer({
port: 3001,
events: {
'custom-event': (context) => {
// 自定义事件处理逻辑
console.log('检测到自定义事件:', context);
return { status: 'handled', response: '自定义事件已处理' };
}
}
});
// 启动服务器
server.start().then(() => {
console.log('服务器已启动并在端口 3001 上监听');
}).catch(err => {
console.error('启动服务器时出错:', err);
});
📚 详细文档
功能
- 获取当前启动的 iOS 模拟器 ID
- 与模拟器 UI 交互:
- 获取当前正在处理的活动(action)
- 获取有关当前活动的上下文信息
- 控制对当前活动的响应
- 检查和修改模拟器状态
- 收集和分析模拟器性能数据
配置
环境变量
可以通过设置以下环境变量来配置 MCP 服务器的行为:
| 属性 | 详情 |
|------|------|
| SIMULATOR_MCP_MODE | 设置服务器运行模式(开发/生产),默认值为开发 |
| SIMULATOR_MCP_LOG | 启用详细日志记录,默认值为禁用 |
| SIMULATOR_MCP_PORT | 定义服务器监听端口,默认值为 3001 |
📄 许可证
本项目采用 MIT 许可证。
Scan to contact