MCP iOS模拟器截图服务器
一个使用模型上下文协议(MCP)从iOS模拟器捕获屏幕截图并将它们保存到指定目录的服务器。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "mcp-ios-simulator-screenshot"
}
}
}
服务介绍
MCP iOS 模拟器截图
一个使用 Model Context Protocol (MCP) 从 iOS 模拟器捕获屏幕截图的服务器。
概述
此项目实现了一个 MCP 协议服务器,该服务器捕获 iOS 模拟器当前屏幕并将其保存到指定目录中。
设置
- 安装:
# Global installation
npm install -g mcp-ios-simulator-screenshot
# Or, install in your project
npm install mcp-ios-simulator-screenshot
# Or, clone from repository
git clone https://github.com/yorifuji/mcp-ios-simulator-screenshot.git
cd mcp-ios-simulator-screenshot
npm install
npm run build
- MCP 客户端配置:
将服务器信息添加到您的 MCP 客户端配置文件中,如下所示:
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "mcp-ios-simulator-screenshot"
}
}
}
环境变量
此服务器不使用环境变量。
命令行参数
此服务器不使用命令行参数。
高级配置
根据安装方法进行 MCP 客户端配置
全局安装时
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "mcp-ios-simulator-screenshot"
}
}
}
本地安装时
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "node",
"args": [
"/path/to/node_modules/mcp-ios-simulator-screenshot/build/index.js"
]
}
}
}
从仓库克隆时
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "node",
"args": ["/path/to/mcp-ios-simulator-screenshot/build/index.js"]
}
}
}
使用 npx 时
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "npx",
"args": ["mcp-ios-simulator-screenshot"]
}
}
}
使用 Docker 时
{
"mcpServers": {
"mcp-ios-simulator-screenshot": {
"command": "docker",
"args": ["run", "-i", "mcp-ios-simulator-screenshot"]
}
}
}
故障排除
-
如果无法捕获屏幕截图:
- 检查 iOS 模拟器是否正在运行
- 检查 Xcode 命令行工具是否已安装
- 检查
xcrun simctl io booted screenshot命令是否可以直接执行
-
如果出现权限错误:
- 检查您是否有对输出目录的写入权限
项目结构
./
├── src/
│ ├── index.ts # Entry point
│ ├── config.ts # Configuration
│ ├── types.ts # Type definitions
│ └── services/
│ └── screenshot-service.ts # Screenshot service
├── build/ # Build output
├── .screenshots/ # Default output directory
└── package.json # Project configuration
工具
get_ios_simulator_screenshot
从 iOS 模拟器捕获屏幕截图并保存到指定目录。
参数
| 参数名 | 类型 | 描述 | 默认值 |
|---|---|---|---|
| output_filename | 字符串 | 输出文件名 | simulator_[timestamp].png |
| output_directory | 字符串 | 输出目录 | .screenshots |
| resize | 布尔值 | 是否调整图像大小 | true |
| max_width | 整数 | 调整大小的最大宽度(像素) | 640 |
| device_id | 字符串 | 指定模拟器设备(例如,iPhone15,2) |
启动的设备 (booted) |
输出格式
成功时:
{
"success": true,
"message": "iOS Simulator screenshot saved successfully",
"filePath": ".screenshots/simulator_2025-04-10T16-51-16-755Z.png",
"metadata": {
"width": 1170,
"height": 2532,
"format": "png",
"size": 382946,
"timestamp": "2025-04-10T16:51:16.755Z"
}
}
出错时:
{
"success": false,
"message": "Error capturing iOS Simulator screenshot: [error message]",
"error": {
"code": "ENOENT",
"command": "xcrun simctl io booted screenshot --type=png -",
"stderr": "No matching devices found."
}
}
要求
- Node.js 16.0.0 或更高版本
- macOS(需要 iOS 模拟器)
- Xcode 命令行工具
技术栈
- TypeScript
- Node.js
- MCP SDK (@modelcontextprotocol/sdk)
许可证
MIT