Mobile Pilot
README.md
# Mobile Pilot
MCP server that lets AI assistants control Android emulators and iOS simulators — start devices, take screenshots, tap, swipe, type, and more.
## Requirements
- **Node.js** >= 18
- **macOS** (ARM64 or Intel)
### Android
- Android SDK with `adb` and `emulator` in your PATH (or `ANDROID_HOME` set)
- At least one AVD created via Android Studio or `avdmanager`
### iOS
- Xcode with Command Line Tools (`xcode-select --install`)
- `xcrun simctl` available
- At least one iOS Simulator runtime installed
## Installation
```bash
git clone https://github.com/xilenco/mobile-pilot.git
cd mobile-pilot
npm install
npm run build
```
## Usage
### With Claude Code
Add to your MCP config (`~/.claude/claude_desktop_config.json` or project `.mcp.json`):
```json
{
"mcpServers": {
"mobile-pilot": {
"command": "node",
"args": ["/path/to/mobile-pilot/dist/index.js"],
"env": {
"ANDROID_HOME": "/Users/you/Library/Android/sdk",
"ANDROID_AVD_HOME": "/Users/you/.android/avd"
}
}
}
}
```
### Standalone
```bash
npm start
```
The server communicates over stdio using the MCP protocol.
## macOS Permissions
### Accessibility (required for iOS interactions)
iOS tap, swipe, type, and press_key use macOS accessibility APIs to interact with the Simulator window. You must grant Accessibility permission to the app running the MCP server.
**System Settings > Privacy & Security > Accessibility**
Add the terminal or app that runs the server:
- **Claude Code CLI**: add `Terminal.app`, `iTerm`, or your terminal emulator
- **Claude Desktop**: add `Claude.app`
- **VS Code**: add `Visual Studio Code.app`
Without this permission, iOS interaction tools will fail with an error.
### Screen Recording (required for iOS screenshots)
`xcrun simctl io screenshot` may require Screen Recording permission on some macOS versions.
**System Settings > Privacy & Security > Screen Recording**
Add the same app as above.
### Full Disk Access (optional)
Not required for normal operation. Only needed if you work with app data containers on simulators.
## Tools
### Device Management
| Tool | Description |
|------|-------------|
| `list_devices` | List available emulators/simulators and their state (running/shutdown) |
| `start_device` | Start an Android emulator (AVD) or iOS simulator |
| `stop_device` | Stop a running emulator/simulator |
| `screenshot` | Capture a screenshot (returned as PNG image) |
### Interaction
| Tool | Description |
|------|-------------|
| `tap` | Tap at a position using ratios (0.0–1.0, where 0,0 = top-left) |
| `swipe` | Swipe between two positions using ratios, with configurable duration |
| `type_text` | Type text into a focused text field |
| `press_key` | Press a hardware/system key (home, back, enter, etc.) |
### Apps
| Tool | Description |
|------|-------------|
| `install_app` | Install an APK (Android) or .app bundle (iOS) on a running device |
| `launch_app` | Launch an app by package name (Android) or bundle ID (iOS) |
| `list_apps` | List installed apps on a device |
### Advanced
| Tool | Description |
|------|-------------|
| `shell` | Run a shell command on a device (`adb shell` / `simctl spawn`) |
| `record_screen` | Record the device screen for a given duration (saved as .mp4) |
| `get_logs` | Get recent device logs (logcat for Android, unified log for iOS) |
### Parameters
All tools require `platform` (`"android"` or `"ios"`) and `device` (device ID or name).
#### Coordinate system
`tap` and `swipe` use **ratios from 0.0 to 1.0** relative to the screen:
- `(0, 0)` = top-left corner
- `(1, 1)` = bottom-right corner
- `(0.5, 0.5)` = center of screen
This makes coordinates independent of device resolution and Simulator window size. The MCP automatically maps ratios to the correct screen position by reading the Simulator's content area at runtime.
**Examples:**
```
tap(x: 0.5, y: 0.95) → tap the search bar at the bottom
swipe(x1: 0.02, y1: 0.5, x2: 0.7, y2: 0.5) → swipe-back gesture (left edge to center)
swipe(x1: 0.5, y1: 0.8, x2: 0.5, y2: 0.3) → scroll down
```
#### press_key supported keys
**Android**: `home`, `back`, `enter`, `tab`, `delete`, `power`, `volume_up`, `volume_down`, `menu`, `search`, `app_switch`
**iOS**: `home`, `lock`, `enter`, `tab`, `delete`, `escape`, `up`, `down`, `left`, `right` (plus any single character)
## How It Works
### Android
All interactions go through `adb`:
- Device management: `adb devices`, `emulator -avd`
- Input: `adb shell input tap/swipe/text/keyevent` (ratios converted to pixels via `wm size`)
- Screenshots: `adb shell screencap`
- Apps: `adb install`, `adb shell pm`, `adb shell monkey`
- Logs: `adb logcat`
- Screen recording: `adb shell screenrecord`
### iOS
- Device management: `xcrun simctl boot/shutdown/list`
- Screenshots: `xcrun simctl io screenshot`
- Tap/Swipe: Swift CGEvents via osascript (simulates mouse on the Simulator window, ratios auto-mapped to the content area)
- Text input: `xcrun simctl pbcopy` + Cmd+V paste via AppleScript
- Key presses: AppleScript keystroke/key code events to Simulator.app
- Apps: `xcrun simctl install/launch/listapps`
- Logs: `xcrun simctl spawn log show`
- Screen recording: `xcrun simctl io recordVideo`
> **Note**: iOS interactions require the Simulator window to be visible. The tools will automatically bring Simulator to the foreground.
## License
MIT
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues