MCP iOS Simulator Screenshot

MIT License
  • Apple

Integrations

  • Captures screenshots from iOS Simulator devices and saves them to a specified directory with options for output filename, directory, image resizing, and selecting specific simulator devices.

  • Runs on macOS to capture iOS Simulator screenshots, requiring macOS as the underlying operating system to access the iOS Simulator environment.

  • Leverages Xcode Command Line Tools to interact with iOS Simulator devices and capture screenshots through the xcrun simctl command.

MCP iOS 模拟器截图

使用模型上下文协议 (MCP) 从 iOS 模拟器捕获屏幕截图的服务器。

概述

本项目实现了一个MCP协议服务器,可以抓取iOS模拟器的当前屏幕,并保存到指定的目录。

设置

  1. 安装
# 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
  1. 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

工具

获取ios模拟器截图

从 iOS 模拟器捕获屏幕截图并将其保存到指定目录。

参数

参数名称类型描述默认值
输出文件名细绳输出文件名模拟器_[时间戳].png
输出目录细绳输出目录.截图
调整大小布尔值是否调整图像大小真的
最大宽度整数调整大小的最大宽度(像素)640
设备 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)

执照

麻省理工学院

其他语言

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

使用模型上下文协议 (MCP) 从 iOS 模拟器捕获屏幕截图并将其保存到指定目录的服务器。

  1. Overview
    1. Setup
      1. Environment Variables
        1. Command Line Arguments
          1. Advanced Configuration
            1. MCP Client Configuration by Installation Method
          2. Troubleshooting
            1. Project Structure
              1. Tools
                1. get_ios_simulator_screenshot
              2. Requirements
                1. Technology Stack
                  1. License
                    1. Other Languages
                      ID: vz30wisdsx