droidpilot
Drive an Android emulator or real device from an LLM agent over MCP: inspect the screen, perform touch and keyboard actions, and manage apps.
Observe the UI: get a compact numbered element list with handles, optionally with a screenshot, and inspect screen size/backend status.
Capture screenshots: request a JPEG at a chosen width.
Tap and press: tap handles or
x,ycoordinates, tap by visible text, long-press, and press keys such as back/home/recent/enter.Gesture: swipe, drag by holding, scroll/pages, and two-finger pinch zoom on emulators.
Type text: enter Unicode text into the focused field, optionally clearing it first.
Rotate the device: turn to portrait/landscape/reverse orientations.
Wait for UI changes: wait for specific text/resource IDs or for loading/animations to finish.
Manage apps: launch, force-stop, identify the foreground app, and list installed packages.
Act with settling: action tools wait for the screen to respond and stabilize, then return the updated element list.
Drives Android emulators and real Android devices, providing UI tree inspection, screenshots, taps, long presses, swipes, scrolling, pinch gestures, text input, key presses, rotation, app management, and waiting for the UI to settle.
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., "@droidpilot open Settings and turn on dark theme"
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.
droidpilot
An MCP server for driving an Android emulator from an LLM agent, built to be fast and to not mislead the agent about what is on screen.
UI tree from uiautomator2 (on-device server, ~30 ms per dump), compressed into a short numbered element list (~20x smaller than the raw XML).
Frames and touch through the Android Emulator's own gRPC endpoint: a 108 px frame in ~2 ms, a 540 px screenshot in ~8 ms, and multi-touch gestures (pinch, drag).
Waits like a person: every action waits until the screen has responded and stopped changing (and until page-load bars are gone), then returns the new element list. One round trip per step.
Real devices work too (everything falls back to uiautomator2); the gRPC fast paths are emulator-only.
Setup
git clone https://github.com/WaziXuan/droidpilot && cd droidpilot
python -m venv .venv && .venv/bin/pip install -e . # Windows: .venv\Scripts\pip install -e .Start the emulator with the gRPC endpoint enabled:
emulator -avd <your_avd> -grpc 8554Register the server with your MCP client, e.g. Claude Code:
claude mcp add droidpilot -- /path/to/droidpilot/.venv/bin/python -m droidpilotOptions (flags or environment variables):
Flag | Env | Default | |
|
| only connected device | adb serial |
|
|
| emulator gRPC address, |
|
|
| minimum gap between actions |
|
|
| |
|
| off |
|
Wireless, reboot-proof: the on-phone agent
adb over TCP is lost on every reboot, and on Android 10 and older only a USB cable
turns it back on. agent/ is a small app (no dependencies, built with the plain SDK
tools) that runs as an accessibility service: Android restarts it by itself after a
reboot, so a phone left somewhere stays drivable with nobody next to it. It serves the
UI tree (in uiautomator's format, so the parser is shared), screenshots
(MediaProjection), gestures, text entry and app launching over HTTP on port 8790,
protected by a token only processes on the phone can read.
python scripts/build_agent.py # -> agent/build/droidpilot-agent.apk
python scripts/setup_agent.py --serial SERIAL --check PHONE_IP # once, over USB: install, enable, grant, save token
python -m droidpilot --agent PHONE_IP --transport streamable-http --port 8766PHONE_IP is any address the PC can reach, e.g. the phone's Tailscale IP. The token
is saved to ~/.droidpilot/agent_token (or set DROIDPILOT_AGENT_TOKEN). Keep
agent/build/agent.keystore: updates signed with another key must uninstall first.
Requirements and limits: no PIN/pattern lock (Android starts no apps after a reboot
until the first unlock; a swipe lock is passed automatically). Without adb there is
no force-stop (app_stop goes home and kills the background app) and keys are
limited to home, back, recents, notifications, power, wakeup, sleep and delete;
press_key enter still works by tapping the keyboard's action key.
If Tailscale's split tunneling excludes an app (say Termux, so its traffic keeps using the
local connection), that app can't answer connections over the tailnet. The agent stays
inside the VPN and can forward for it, accepting only on the Tailscale address; forwards
are saved and come back after a reboot:
curl -H "X-Token: $TOKEN" -d '{"listen":8023,"target":8022}' http://PHONE_IP:8790/forwards # tailnet :8023 -> 127.0.0.1:8022
curl -H "X-Token: $TOKEN" -d '{"listen":8023,"remove":true}' http://PHONE_IP:8790/forwardsMeasured on an Xperia XZ1 Compact (Android 9) over Tailscale: observe ≈0.13 s,
540 px screenshot ≈0.1 s; back up about a minute after adb reboot.
Related MCP server: android-agent-mcp
What the agent sees
package: com.android.settings elements: 12 keyboard: shown (covers y>=1517)
[e1] ImageButton "Back" @(63,219) 126x147 click
[e2] EditText "dark" #open_search_view_edit_text @(529,220) 807x126 click,long,edit,focused
[e5] LinearLayout "Dark theme | Display" @(540,414) 1080x214 click
[e6] Switch #switch_widget @(944,414) 188x214 click,unchecked
[e11] LinearLayout "Bedtime mode" @(540,1549) 1080x214 click,under-keyboard
[e12] Key "Search" @(994,2196) 161x156 click,ime-action[handle] Class "label" #resource-id @(center) WxH flags. Handles are valid for the latest list only.
The list leaves out status-bar icons, keyboard keys (except the action key), items scrolled under a
toolbar or out of their container, slivers too thin to tap, page-sized click targets, and wrappers that
repeat their child. The header adds loading while a spinner or page-load bar is visible.
Tools
Tool | |
| element list, optionally with a screenshot |
| JPEG of the screen |
| target is a handle ( |
| tap the best element whose label matches |
|
|
| pages overlap by default |
| two-finger zoom in/out (gRPC) |
| into the focused field; any Unicode |
|
|
|
|
| wait for an element / for loading to finish |
| app management |
| backends in use |
Action tools return the settled element list (observe_after=True), with how long settling took.
Design notes
Measured on an x86_64 Android 14 emulator (software rendering) on a Ryzen 7 7800X3D:
Operation | Median |
gRPC frame, 540 px wide | 8 ms |
gRPC frame, full size | 32 ms |
uiautomator2 hierarchy dump | 30 ms |
| 136 ms |
| 238 ms |
| ~300 ms |
uiautomator2 | ~2.8 s |
uiautomator2 | 5.1 s vs 35 ms |
Settling. Dumping the hierarchy blocks while an app animates (~0.5 s per dump mid-transition), so settling polls tiny frames and dumps once at the end. A tap's ripple happens inside the tapped element and is not the response: a cold-started screen can sit still for ~0.4 s between ripple and transition, so only changes outside the touched element count. Settling continues while a progress bar is indeterminate or advancing (browser page loads), and stops for static gauges.
Typing uses the accessibility set-text action: no clipboard (which raises the Android 13+ clipboard overlay), no switching the user's input method, and the app's text watchers still fire.
Submitting. Search boxes often ignore
KEYCODE_ENTER;press_key entertaps the keyboard's action key, found in the keyboard's accessibility tree.KEYCODE_SEARCHis not used: it opens the Google app.Scrolling pauses the finger before lifting so lists move by the requested distance instead of flinging past items.
Rotation. uiautomator reports coordinates for the current display rotation. On the emulator, touch events always use natural (unrotated) coordinates, while gRPC frames come in the orientation of the emulator's body, i.e. its window. Frames are turned by (display − body) quarter turns, which matched uiautomator2's own screenshots in all nine combinations tried, and touch points are mapped to natural coordinates. The rotation comes from each hierarchy dump at no extra cost.
The window stays upright for whoever is watching. When the display rotates without the body (an app locking landscape, or a forced rotation setting), the content would show sideways in the emulator window. droidpilot then turns the emulator's body to match, as a person turns the phone to watch a landscape video.
rotatelikewise turns the body instead of forcing a system setting; if the app refuses the new orientation, the body is turned back. Disable with--no-follow-rotation.Loading bars are waited out for at most 2 s once the picture is still (pages often keep a bar up for a resource that never arrives); the element list still says
loading, andwait_idlewaits for as long as you allow.Pacing. A minimum gap between actions (300 ms) keeps taps from landing on half-drawn screens.
Limitations
Content without accessibility information (games, canvas, some WebViews) needs
screenshot.The gRPC endpoint is unauthenticated on localhost; don't expose it.
Development
pip install -e .[dev]
pytest # offline tests for the element list
python scripts/bench.py # latency of each backend
python scripts/settle_trace.py "540,1355" # frame-by-frame response to a tap
python scripts/mcp_call.py observe # call tools like an MCP client
python scripts/gen_proto.py # regenerate gRPC stubs from proto/Related projects
mobile-next/mobile-mcp: cross-platform (iOS + Android) MCP server
droidrun/mobilerun: LLM-agnostic mobile agent framework
jodaco/android-uiautomator-mcp, tanbro/uiautomator2-mcp-server: uiautomator2-based MCP servers
openatx/uiautomator2, which this builds on
License
MIT. proto/droidpilot/_proto/emulator_controller.proto and the generated stubs come from the
Android Emulator and are Apache-2.0; see LICENSE.
Available Tools
18 toolsapp_currentC
Foreground package and activity.
Inputs: no named parameters.
app_launchB
Launch an app by package name (see app_list).
Inputs: package (required), max_wait_ms, observe_after. Returns: result
app_listC
Installed packages, optionally filtered by substring.
Inputs: contains. Returns: result
app_stopC
Force-stop an app.
Inputs: package (required). Returns: result
long_pressC
Press and hold an element handle or "x,y".
Inputs: target (required), hold_ms, max_wait_ms, observe_after. Returns: result
observeB
List interactive and labelled elements on screen with handles. Optionally attach a screenshot.
Inputs: width, screenshot.
pinchA
Two-finger pinch: zoom "in" or "out", centred on a handle/"x,y" or the screen centre. Emulator gRPC only.
Inputs: zoom (required), target, max_wait_ms, observe_after. Returns: result
press_keyB
Press a key: back, home, recent, delete, tab, volume_up, volume_down, power, or any KEYCODE_ name. "enter" (also "search"/"go"/"send"/"done") presses the on-screen keyboard's action key when the keyboard is shown, which is what submits most search boxes and chat inputs.
Inputs: key (required), max_wait_ms, observe_after. Returns: result
rotateA
Turn the device to "portrait", "landscape", "reverse_portrait" or "reverse_landscape", like a person
turning the phone. The display only follows if auto-rotate is on and the app allows it; check the
orientation in the returned header.
Inputs: orientation (required), max_wait_ms, observe_after. Returns: result
screenshotA
Current screen as JPEG, scaled to width px wide (the device is usually 1080 wide; scale coordinates back).
Inputs: width.
scrollA
Scroll "down" (reveal content below), "up", "left" or "right", within a scrollable handle or the whole
screen, by about distance of its height/width so consecutive pages overlap. fling=True lets the list
coast further (faster for long lists, but items can be skipped).
Inputs: direction (required), fling, target, distance, +3 more. Returns: result
statusC
Which backends are in use, screen size and pacing.
Inputs: no named parameters.
swipeC
Swipe from start to end (handles or "x,y"). Set hold_ms > 0 to press first, i.e. drag.
Inputs: end (required), start (required), hold_ms, duration_ms, +2 more. Returns: result
tapC
Tap an element handle ("e7") or device coordinates ("540,1200").
Inputs: target (required), max_wait_ms, observe_after. Returns: result
tap_textC
Tap the first element whose text (or content description) contains text.
Inputs: text (required), exact, max_wait_ms, observe_after. Returns: result
type_textB
Type into the focused field (tap the field first). Unicode is fine. clear=True replaces existing text.
Inputs: text (required), clear, max_wait_ms, observe_after. Returns: result
wait_forC
Wait until an element whose label (text or content description) contains text, and/or with
resource id resource_id, appears.
Inputs: text, timeout, resource_id, observe_after. Returns: result
wait_idleA
Wait until the screen stops changing and nothing is loading (use when the element list says
loading, e.g. a web page still coming in), then return the element list.
Inputs: max_wait_ms. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool has a distinct action: observation (screenshot/observe), input (type_text, press_key), gestures (tap, tap_text, long_press, swipe, scroll, pinch), waiting, and app lifecycle. Minor overlap exists between screenshot and observe (which can attach a screenshot) and between swipe and scroll, but descriptions clearly delineate when to use each.
Names are uniformly lowercase snake_case with an `app_` prefix grouping the package-management tools and verb_noun forms like type_text, press_key, wait_for, long_press. A handful of bare single-word names (screenshot, observe, tap, status) deviate from the verb_noun pattern but remain unambiguous.
18 tools is slightly on the heavy side but each maps to a needed mobile-automation primitive (perception, gesture input, waiting, app control, device state). No tool appears redundant enough to drop outright.
Core lifecycle is well covered: observe/screenshot for perception, tap/type/swipe/pinch/press_key for interaction, wait_for/wait_idle for synchronization, and app_launch/stop/current/list for app management. Gaps exist around clipboard/paste, deep-link or URL opening, and notification/shell access, but agents can work around most of these via existing tools.
Maintenance
Related MCP Connectors
Let Claude, ChatGPT and other agents use your Android phone: see the screen, tap, type, open apps.
Cloud Android devices for AI agents: install an APK, read the screen, tap, type, read logcat.
Give your AI agent a real cloud Android phone: push APKs, drive it, get screenshots and logs.
Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables AI agents to interact with Android devices through visual UI element detection and automated interactions. Provides comprehensive Android automation capabilities including touch gestures, text input, screenshots, and video recording via uiautomator2.124-
- AlicenseNot gradedqualityCmaintenanceEnables LLM agents to drive real Android devices or emulators by reading the live accessibility tree, acting on UI nodes instead of coordinates, verifying every action, and typing Unicode text.4Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to operate a real Android phone through its accessibility service, exposing screen trees with stable refs, taps, typing, gestures, notifications, apps, and other device controls.5MIT
- AlicenseAqualityBmaintenanceEnables AI agents to see and drive a real Android phone over plain ADB: screenshots and numbered UI trees, gestures, typing with accents and emoji, SMS/RCS reading and prepared replies, notifications, files, and settings, with no root and no app installed on the phone. Safeguards mask security codes and require explicit confirmation before sending, paying, deleting or confirming anything.183MIT