
一个支持 iOS 和 Android 使用的 MCP 服务器。无缝映射原生屏幕和 WebView。支持多个并行设备。
概览
一个MCP服务器,允许AI代理控制iOS和Android设备(点击、滚动、打字、截图、阅读UI树和运行代码)。支持多台设备同时运行。 1. — 在每个移动设备上运行的轻量级HTTP服务器(Android为UIAutomator,iOS为XCUITest),用于暴露无障碍树并接受交互命令。2. — 将两个平台的原始UI树归一化为统一的平面元素列表。3. — 外部接口。处理设备发现、引导、端口分配及向设备内服务器的代理请求。 设备在首次使用时启动——服务器安装驱动应用,分配端口,启动设备内服务器,轮询直到服务器恢复正常。之后,所有工具调用通过本地主机HTTP代理,并以每个设备承载令牌认证。 代理可以传递看起来像UIAutomator或XCUITest的代码,这两者底层都是Javascript。
概述(AI 翻译)
一个MCP服务器,允许AI代理控制iOS和Android设备(点击、滚动、打字、截图、阅读UI树和运行代码)。支持多台设备同时运行。
工作原理
三层架构:
- 设备内服务器 — 在每个移动设备上运行的轻量级HTTP服务器(Android上的UIAutomator,iOS上的XCUITest),它们会暴露无障碍树并接受交互命令。
- UI 树筛选 — 将两个平台的原始 UI 树归一化为统一的平面元素列表。
- MCP 服务器 — 外部接口。处理设备发现、引导、端口分配以及向设备内服务器发送代理请求。
设备在首次使用时启动——服务器安装驱动应用,分配端口,启动设备内服务器,轮询直到服务器恢复正常。之后,所有工具调用通过本地主机HTTP代理,并以每个设备承载令牌认证。
工具
| 工具 | 描述 |
|---|---|
list_devices |
可用iOS和Android设备列表 |
screenshot |
捕捉设备屏幕(JPEG) |
uitree |
将UI元素树设置为平面列表,并可选搜索和限制。 |
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Mobile Device MCP
An MCP server that lets AI agents control iOS and Android devices (tap, scroll, type, take screenshots, read UI trees, and run code). Works with multiple devices at the same time.
How It Works
Three-layer architecture:
- On-device servers — Lightweight HTTP servers running on each mobile device (UIAutomator on Android, XCUITest on iOS) that expose the accessibility tree and accept interaction commands.
- UI tree filter — Normalizes raw UI trees from both platforms into a unified flat element list.
- MCP server — The external interface. Handles device discovery, bootstrapping, port allocation, and proxies requests to on-device servers.
Devices are bootstrapped on first use — the server installs the driver app, allocates a port, starts the on-device server, and polls until it’s healthy. After that, all tool calls are proxied over localhost HTTP with per-device bearer token auth.
Tools
| Tool | Description |
|---|---|
list_devices |
List available iOS and Android devices |
screenshot |
Capture the device screen (JPEG) |
uitree |
Get the UI element tree as a flat list, with optional search and limit. Off-screen elements are excluded unless include_invisible: true |
tap |
Tap at screen coordinates |
double_tap |
Double-tap at screen coordinates |
long_press |
Long-press at screen coordinates (configurable duration) |
scroll |
Swipe from start to end coordinates |
type_text |
Type text into the focused element |
press_button |
Press a hardware/navigation button (home, back, enter, volumeUp/Down, dpadUp/Down/Left/Right/Center) |
launch_app |
Launch an app by bundle ID / package name |
terminate_app |
Force-stop an app |
list_apps |
List installed apps |
install_app |
Install an app from a host-local file (.apk for Android, .app for iOS simulator, .app/.ipa for iOS device). Replaces existing installs |
run_code |
Execute sandboxed JavaScript on-device (see run_code below) |
run_code
Agents can pass code that looks like UIAutomator or XCUITest, both being Javascript under the hood. The sandbox restricts (Android) potentially dangerous Java operations and only allows (iOS) some XCUITest-ish commands
- Android: Rhino engine with UIAutomator bindings —
uiDevice(click, swipe, find elements, press keys, read display info),By(selectors),Until(wait conditions),console.log() - iOS: JavaScriptCore with XCUITest bindings —
app(query elements, tap, type, swipe),springboard,device,openApp(bundleId),sleep(ms),console.log()
Both platforms automatically kill runaway scripts (infinite loops) and create a fresh sandbox per call.
Prerequisites
- Node.js 18+ (for running via
npx) - Android: Android SDK with
adbon PATH - iOS Simulator: Xcode with
xcrun,simctl
安装
npx -y @srmorete/mobile-device-mcp@latest配置
{
"mcpServers": {
"mobile-device-mcp": {
"command": "npx",
"args": ["-y", "@srmorete/mobile-device-mcp@latest"],
"env": {
"MDMS_PORT_ANDROID": "18000", # optional
"MDMS_PORT_IOS": "19000" # optional
}
}
}
}