phone-control
Enables AI agents to control Android phones over ADB, including taking screenshots, inspecting UI elements, tapping/swiping/typing, managing apps, transferring files, running shell commands, and using wireless ADB.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@phone-controlOpen WeChat and screenshot the screen for me"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
phone-control-mcp
Let any AI agent drive your Android phone. One codebase, two interfaces:
MCP server (
server.py, stdio) — plug into Codex, Claude Desktop, Cursor, or any MCP client and get 28 phone-control tools, including screenshots returned as real images the model can see.Zero-dependency CLI (
phone_control.py) — any agent that can run a shell command can control the phone; also great for humans and cron jobs.
Built on ADB. Pure Python standard library for the core; only the optional MCP layer needs pip install mcp.
Why it's fast
AI phone-control feels slow when every action is a round trip. This project attacks latency on both layers:
Transport layer (measured on vivo V2408A · Android 16 · Windows 11 · USB):
Operation | v1.0 | v1.1 | Speedup |
shell command | 63 ms | 3 ms | 21× |
tap | 118 ms | 19 ms | 6× |
foreground-app check | 141 ms | 37 ms | 4× |
device_info (10+ probes) | 1060 ms | 255 ms | 4× |
ui_dump / find_text | ~2600 ms | ~2210 ms | 1.2׆ |
screenshot (1080×2376 PNG) | ~950 ms | ~950 ms | — |
† The remaining ~2 s is the on-device uiautomator Java startup — a fixed Android cost; our own overhead is now ~200 ms.
Persistent shell session — one long-lived
adb shellwith a marker protocol instead of spawning adb.exe + handshake + device sh per command. Auto-reconnects, auto-falls back to one-shot mode on anything suspicious (multi-line commands, unbalanced quotes, stdin-reading commands are isolated with</dev/null).Single-roundtrip UI fetch —
dump → cat → rmmerged into oneexec-outcall, no temp files, noadb pull.Merged probes —
device_infocollects everything in one shell script.Keep-alive — the MCP server pings the device every 45 s so Windows USB selective-suspend doesn't drop it.
Agent layer (the bigger win — every saved tool call is a saved LLM round trip):
tap_text "Send"— locate a control by on-screen text and tap it in one call.wait_for_text— poll until a screen element appears instead of blindsleep.run_script— run an entire multi-step flow (open app → wait → tap → type → screenshot) as one tool call.
Related MCP server: android-mcp
Install
Requirements: Python 3.10+, an Android phone with USB debugging enabled.
Windows (one command):
powershell -ExecutionPolicy Bypass -File install.ps1Creates .venv, installs the MCP SDK, and auto-downloads Google platform-tools (adb) if missing.
Linux / macOS / manual:
python3 -m venv .venv && .venv/bin/pip install "mcp>=1.2" # only needed for the MCP server
# adb: use your package manager, or set ADB_PATH=/path/to/adbPhone setup (once): Settings → About phone → tap Build number 7 times → Developer options → enable USB debugging → plug in → choose File transfer → accept the RSA prompt (tick Always allow).
Verify: python phone_control.py doctor — fix hints are printed for every failure mode.
Connect your AI tool
Codex CLI
codex mcp add phone-control -- /path/to/.venv/bin/python /path/to/server.pyClaude Desktop / Cursor / any MCP client
{
"mcpServers": {
"phone-control": {
"command": "/path/to/.venv/bin/python",
"args": ["/path/to/server.py"]
}
}
}DeepSeek Harness (DSH)
Skill: copy
skills/phone-control/into~/.dsh/skills/(or<project>/.dsh/skills/) — hot-reloads into the session skill catalog; edit the entry-point path insideSKILL.mdto your checkout.Or plain CLI: agents call
python phone_control.py <subcommand>through the shell; results are UTF-8 JSON.
Plain shell / cron / you
python phone_control.py screenshot now.png
python phone_control.py tap-text "微信"The 28 MCP tools
Group | Tools |
Diagnostics |
|
See the screen |
|
Touch & type |
|
Combos (fast agent flows) |
|
Apps |
|
Files |
|
Escape hatches |
|
Wireless ADB |
|
The CLI mirrors every tool (tap-text, wait-for, script, …) — see python phone_control.py --help.
run_script example
[
{"action": "open", "package": "com.tencent.mm"},
{"action": "wait_for", "text": "微信", "timeout_s": 15},
{"action": "tap_text", "text": "通讯录"},
{"action": "screenshot", "save_path": "contacts.png"}
]Actions: tap tap_text long_press swipe swipe_screen key text sleep wait_for open stop current_app assert_app screenshot find shell. Each step reports {step, action, ok, result|error}; stops on first error unless stop_on_error=false.
Recipes
Chinese / CJK text input — stock adb shell input text is ASCII-only. Install ADBKeyboard once (python phone_control.py install ADBKeyBoard.apk); afterwards input_text auto-switches IME, types via base64 broadcast, and restores your IME.
Wi-Fi (no cable) — Developer options → Wireless debugging → Pair device with pairing code:
python phone_control.py pair 192.168.1.20:37123 123456
python phone_control.py connect 192.168.1.20:40001Keep screen awake while plugged (avoids lock-screen interruptions):
python phone_control.py shell "svc power stayon true"Multiple phones — pass --serial <SN> (CLI) / serial (MCP tools), or set PHONE_SERIAL.
Troubleshooting
Symptom | Fix |
| run |
device | unlock the phone, accept the RSA dialog (Always allow) |
device | replug the cable; |
no device at all | data-capable cable; USB mode = File transfer; OEM drivers (Xiaomi/Huawei suites) |
drops after minutes of idle | USB selective suspend — use the MCP server (keep-alive) or wireless debugging; keep |
secure lock screen | adb cannot (and should not) bypass face/PIN locks — unlock once; with |
black screenshots | DRM surfaces (banking apps, Netflix) block capture by design |
Xiaomi install failures | disable MIUI optimization / allow "Install via USB" |
Development
python test_mcp.py # end-to-end MCP smoke test (no device needed) — also runs in CI
python benchmark.py # latency benchmark (device required)
python regression.py # 40-check integration suite (device required)Project layout — deliberately just two modules:
phone_control.py # core library + CLI, stdlib only
server.py # MCP server (thin wrapper, mcp SDK v1 & v2 compatible)
install.ps1 # Windows one-shot installer (venv + mcp + platform-tools)
skills/ # DeepSeek Harness skill bundleSafety
Destructive operations (
uninstall_app, overwritingpush_file, arbitrarydevice_shell) are documented as confirm-first for agents.The bundled skill instructs agents to never drive payment/banking screens unprompted and never exfiltrate verification codes or screenshots.
Everything runs locally over ADB; no telemetry, no cloud.
License
MIT © phone-control-mcp contributors
This server cannot be deployed
Maintenance
Related MCP Connectors
Give your AI agent a real cloud Android phone: push APKs, drive it, get screenshots and logs.
Cloud Android phones for AI agents: create a phone, read the screen, tap, type, install APKs, park.
Let AI agents control Android and iOS devices on Mobilerun Cloud: screen, input, apps, workflows.
Disposable cloud Android emulators for coding agents: run an APK or PR build, tap, type, screenshot.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to interact with Android devices and emulators via ADB, providing tools for screenshots, UI inspection, touch and text input, app management, and device control.4233 npm20MIT
- AlicenseAqualityCmaintenanceEnables AI agents to control, inspect, and automate Android devices, Waydroid containers, and AVD emulators over ADB. Provides tools for screenshots, UI-hierarchy text-based tapping, gestures, key presses, text input, app management, and raw shell commands.12MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to visually perceive and directly control Android devices via ADB and screen-control tooling, including screenshots, taps, swipes, typing, app management, UI inspection, file transfer, shell commands, and audio/video streaming.151 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to see and control Android devices through ADB and screen mirroring, supporting screen capture, touch input, app management, UI element finding, file transfer, shell commands, clipboard access, and audio/video streaming.151 npmMIT