droidpilot
<p align="center"><img src="assets/logo.svg" alt="droidpilot logo" width="520"></p>
<p align="center">
<img alt="license" src="https://img.shields.io/badge/license-MIT-green">
<img alt="python" src="https://img.shields.io/badge/python-3.12%2B-blue">
<img alt="protocol" src="https://img.shields.io/badge/protocol-MCP-6f42c1">
<img alt="status" src="https://img.shields.io/badge/status-proof%20of%20concept-orange">
</p>
# droidpilot
droidpilot lets an AI coding agent use a real Android phone. The agent looks at the screen and touches it like a finger.
droidpilot is an [MCP](https://modelcontextprotocol.io) server. Any agent that supports MCP can use it. Examples: Claude Code, Codex, Gemini CLI, Kiro.
## What it does
| Action | Tool |
|---|---|
| Look at the screen | `observe` (UI list, snapshot id, state), `screenshot` |
| Touch | `tap_text`, `tap_element`, `tap`, `double_tap`, `long_press` |
| Move a finger | `swipe`, `scroll` |
| Use two or more fingers | `pinch`, `gesture` |
| Type and press keys | `type_text`, `press_key` |
| Open an app | `open_app`, `list_apps` |
| Wait | `wait`, `wait_for` |
An action returns in about 0.4 seconds. It does not check the screen. The next `observe` says `changed=yes` or `changed=NO`. The agent can then find a tap that did nothing.
`observe` also wakes and unlocks a phone that has no PIN. If a PIN blocks it, the result starts with `NEEDS_HUMAN`.
A tap on a buy, pay, send or delete button returns `BLOCKED`. The agent must repeat it with `confirm=true`.
## How it works
```
AI agent --MCP--> droidpilot --scrcpy control socket--> phone (real touch events)
|
+--adb screencap + uiautomator--> screenshot + numbered UI elements
```
1. droidpilot sends touch events through the scrcpy control socket. This gives real multi-touch.
2. If scrcpy fails, droidpilot uses `adb shell input`. This gives one finger only.
3. droidpilot reads the screen with `screencap` and `uiautomator dump`.
## Quick start
Do these steps once on the phone:
1. Open Settings > About. Tap **Build number** 7 times.
2. Open Developer options. Turn on **USB debugging**.
3. On realme and Oppo phones, turn on **Disable permission monitoring**.
4. Set the USB mode to **File transfer**. Do not use USB tethering.
5. Connect the cable. Tap **Allow** on the phone.
Then run these commands on the computer:
```bash
source env.sh # sets the paths for adb and scrcpy
uv run droidpilot doctor # checks the phone and every layer
uv run droidpilot serve # starts the MCP server
```
## Add to an agent
Use this command as the MCP server. The transport is stdio.
```bash
uv --directory /path/to/droidpilot run droidpilot serve
```
An example config is in [`examples/mcp.example.json`](examples/mcp.example.json).
## Settings
| Variable | Default | Meaning |
|---|---|---|
| `DROIDPILOT_VERIFY` | `off` | `full` checks the screen after each action with screenshots. It is slow (about 5 seconds). |
| `DROIDPILOT_SETTLE_MS` | `400` | Wait after each action. |
| `DROIDPILOT_GUARD` | `on` | `off` turns the safety guard off. |
| `DROIDPILOT_COMPACT` | `1` | `0` lists every UI element. |
| `DROIDPILOT_SERIAL` | first device | Choose a phone when more than one is connected. |
| `DROIDPILOT_HOME` | `~/.cache/droidpilot` | Where the run log is kept. |
## Commands
| Command | Use |
|---|---|
| `droidpilot serve` | Start the MCP server. |
| `droidpilot doctor` | Test adb, the phone, the screen, and touch. |
| `droidpilot clean` | Remove the files droidpilot put on the phone. |
## Test
```bash
uv run pytest # no phone needed
uv run python tests/e2e_device.py # needs a phone or an emulator
```
## Known limits
- `observe` takes about 3 seconds. The UI dump on the phone is the limit. See [docs/ROADMAP.md](docs/ROADMAP.md).
- Apps that block screenshots show a black screen. The UI tree can still work.
- Web views inside apps give only part of their UI to the tree.
- A phone without a PIN is easy to use. A phone with a PIN needs the user to unlock it.
## Documents
- [Roadmap: effort, impact, and what we dropped](docs/ROADMAP.md)
- [Performance numbers](docs/PERFORMANCE.md)
- [Security](SECURITY.md)
- [Research summary](docs/RESEARCH.md)
- [Findings log](docs/FINDINGS.md)
## License
MIT. See [LICENSE](LICENSE).
TDQS
Scored across 18 tools
Most tools target clearly distinct capabilities (observe vs screenshot vs wait vs wait_for are well differentiated in descriptions). The tap family (tap, tap_text, tap_element), and the movement family (swipe, scroll, pinch, gesture) are related but descriptions make the boundaries intelligible. An agent can generally pick correctly, though swipe vs scroll and gesture vs pinch require reading the description.
Casing is uniformly lowercase snake_case, but verb style is mixed: verb_noun tools (open_app, list_apps, press_key, type_text, tap_text, tap_element) coexist with bare verbs (tap, swipe, scroll, pinch, observe, wait), nouns (screenshot, gesture) and a noun_phrase (device_status). Still readable, but no single predictable pattern.
18 tools is on the heavy side but each maps to a real mobile-automation capability (observation, touch, gesture, text input, app management, waiting). Nothing is obviously redundant, though a few bare taps could arguably be collapsed. Count is justified by the breadth of the domain.
The surface covers the mobile interaction lifecycle well: observe/status/screenshot for perception, a full touch and gesture set, text/key input, app launch and listing, and both time- and element-based waits. Minor gaps remain: no close/stop app, no element-scoped scroll or swipe (only coordinates), and no text clearing or clipboard retrieval.