Content
# iOS Screenshot MCP Server
MCP Server for iOS device screenshot based on Appium, can be used for AI clients like Trae that support MCP protocol.
## Installation
```bash
uv sync
```
## Usage
### Method 1: Stdio Mode (Recommended for Trae)
```bash
uv run python mcp_server.py --stdio
```
### Method 2: SSE Mode (For Remote Connection)
```bash
uv run python mcp_server.py
```
The server will run at `http://localhost:8000`.
## Trae MCP Configuration
### Stdio Mode (Recommended)
Add the following JSON configuration to Trae's MCP Servers configuration:
```json
{
"name": "iOS Screenshot MCP",
"type": "stdio",
"command": "uv run python mcp_server.py --stdio",
"cwd": "~/mcp-servers/ios-playwright-mcp",
"enabled": true
}
```
### SSE Mode
Start the server first:
```bash
cd ~/mcp-servers/ios-playwright-mcp
uv run python mcp_server.py
```
Add the following JSON configuration to Trae's MCP Servers configuration:
```json
{
"name": "iOS Screenshot MCP",
"type": "sse",
"url": "http://localhost:8000/mcp/sse",
"enabled": true
}
```
## Claude Code MCP Configuration
```json
"mcpServers": {
"ios-playwright": {
"name": "ios-playwright",
"type": "stdio",
"command": "bash",
"args": [
"-c",
"source ~/mcp-servers/ios-playwright-mcp/.venv/bin/activate && uv run python ~/mcp-servers/ios-playwright-mcp/mcp_server.py --stdio"
],
"cwd": "~/mcp-servers/ios-playwright-mcp/"
}
}
```
## Tool Description
### take_ios_screenshot_tool
Captures the iOS device screen and saves it as an image file.
**Parameters:**
| Parameter | Type | Default Value | Description |
|------|------|--------|------|
| platform_name | str | iOS | Platform name |
| automation_name | str | XCUITest | Automation framework name |
| device_name | str | iPhone 16 Pro Max | Device name |
| udid | str | 32EFED52-E30A-4CC8-AAE9-525B5A3A5B6A | Device unique identifier |
| bundle_id | str | com.xue.Demo01 | App Bundle ID |
| appium_server_url | str | http://127.0.0.1:4723 | Appium server URL |
| output_path | str | screen.png | Screenshot save path |
**Return Value:**
The full path of the screenshot file.
## Prerequisites
Before calling the screenshot tool, ensure that:
1. **Appium Server** is running at `http://127.0.0.1:4723`
2. **Target device/simulator** is connected
3. **Specified app** (`bundle_id`) is installed on the device
## File Structure
```
.
├── mcp_server.py # MCP Server main file
├── screenshot_service.py # Screenshot logic service module
├── main.py # Original screenshot script
├── pyproject.toml # Project configuration
└── README.md # Project description
```