这是一个用于与 iOS 模拟器交互的模型上下文协议(MCP)服务器。借助该服务器,您能够获取模拟器的相关信息、控制 UI 交互并检查 UI 元素,从而实现与 iOS 模拟器的交互。
https://github.com/user-attachments/assets/453ebe7b-cc93-4ac2-b08d-0f8ac8339ad3
在使用本服务器前,您需要满足以下先决条件:
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 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);
});
可以通过设置以下环境变量来配置 MCP 服务器的行为:
| 属性 | 详情 |
|---|---|
SIMULATOR_MCP_MODE |
设置服务器运行模式(开发/生产),默认值为开发 |
SIMULATOR_MCP_LOG |
启用详细日志记录,默认值为禁用 |
SIMULATOR_MCP_PORT |
定义服务器监听端口,默认值为 3001 |
本项目采用 MIT 许可证。