ControlMyPhone AI
by momibhai
README.md
# ControlMyPhone AI
**Let any AI assistant see and control your Android phone: over a USB cable, or with no cable over Wi-Fi.**
ControlMyPhone AI is a free, open-source [Model Context Protocol](https://modelcontextprotocol.io) server. Plug it into Claude Desktop, Claude Code, Cursor, Windsurf, Cline or any MCP client, and the AI can:
- ๐ **See** the screen (screenshots) and **read** it as a short numbered list of buttons and fields
- ๐ **Tap, long-press, swipe, scroll, type and press keys** (back, home, enter...)
- ๐ฑ **Open apps** by name ("whatsapp", "maps") and **open links** (web, maps navigation, `tel:`, WhatsApp chats)
- ๐ **Send files/photos** from the computer straight into the phone's gallery, and pull files back
- ๐ถ **Connect without a cable**: scan a QR code (Android 11+), use a pairing code, or switch a USB phone to Wi-Fi
- ๐ก๏ธ Stay **safe by default**: read-only mode, raw shell and APK install switched off unless you enable them, an action log, and built-in instructions telling the AI to ask before sending, paying or deleting
> Status: v0.1, Android only. iPhone support is on the [roadmap](#roadmap).
---
## Why another Android MCP?
There are already good ADB MCP servers. ControlMyPhone AI focuses on **normal people with a normal phone**:
| | ControlMyPhone AI |
|---|---|
| Finds adb by itself on Windows (incl. the `adb.exe` bundled with scrcpy) | โ
|
| Cable-free pairing by **QR code**, from the terminal *or* from inside the AI chat | โ
|
| Compact UI list (`[7] Button "Send" (640,1510) click`) instead of 100 KB XML: cheaper and more accurate | โ
|
| `tap_text("Send")` / `tap_element(7)`: no pixel guessing | โ
|
| Screenshot coordinates auto-scaled (small images, correct taps) | โ
|
| Photos land in the **Gallery** so apps' photo pickers see them | โ
|
| **One-file app, no Python**: double-click โ setup page downloads adb, QR connect, adds itself to Claude/Cursor, live test | โ
|
| `controlmyphone doctor` explains exactly what's wrong (unauthorized, Xiaomi input block, ...) | โ
|
| Safe defaults (read-only switch, opt-in shell, action log) | โ
|
| Works with MCP Python SDK 1.x **and** 2.x | โ
|
---
## Quick start (anyone can do it, no Python needed)
**You need:** an Android phone, a Windows PC (Mac/Linux builds are on the same page), and an AI app such as Claude Desktop or Claude Code installed **on that computer**.
1. **Download `ControlMyPhone-Windows.exe`** from the [Releases page](../../releases/latest).
2. **Double-click it.** (Windows may say *"Windows protected your PC"* because the app is new and not code-signed: click **More info โ Run anyway**.)
A setup page opens in your browser and walks you through everything:
- โฌ๏ธ downloads **adb** for you (Google's free phone connector, ~10 MB), nothing else to install
- ๐ฑ shows the **2 phone settings** to switch on (one time)
- ๐ถ shows a **QR code**: scan it on the phone and it connects **without a cable** (or just plug in a USB cable)
- โ **"Add to Claude Desktop" / "Add to Claude Code" / "Add to Cursor"** buttons
- ๐ธ a **test button** that shows your phone screen, so you know it works
3. **Restart your AI app** and say: *"Take a screenshot of my phone and tell me what's on it."*
> ๐ฑ **Easy Mode (no developer settings):** the setup page shows a QR code; scan it with the phone camera to install the small ControlMyPhone AI app, switch it on, and click **Connect**. If Android says *"App blocked to protect your device"*, see [PUBLISHING.md](PUBLISHING.md#2-why-android-shows-app-blocked-to-protect-your-device).
That's it. ๐ The app copies itself to `~/.controlmyphone/app/`, so you can delete the download afterwards.
> โน๏ธ ControlMyPhone AI runs on **your computer** (the one the phone connects to). AI apps that also run on that computer (Claude Desktop, Claude Code in a terminal, Cursor, Windsurf, Cline...) can use it. Cloud-only chats (a web browser tab, the phone app) can't reach your computer's phone yet; see the roadmap.
**From source instead?** Download the ZIP and double-click `setup_windows.bat` (Mac/Linux: `./setup.sh`). It installs into a private `.venv` and opens the same setup page. Build the one-file app yourself with `packaging\build_windows_exe.bat`.
### Prefer the terminal?
```bash
pip install . # inside this folder (use a venv if you like)
controlmyphone setup # the same setup page
controlmyphone doctor # or: check everything in the terminal
controlmyphone pair-qr # connect over Wi-Fi with a QR code in the terminal
claude mcp add controlmyphone -- python -m controlmyphone # Claude Code
```
Claude Desktop manual config (*Settings โ Developer โ Edit Config*):
```json
{
"mcpServers": {
"controlmyphone": { "command": "python", "args": ["-m", "controlmyphone"] }
}
}
```
Then ask things like:
- *"Open Google Maps and start directions to Karachi airport."*
- *"Put ~/Pictures/house.jpg in my phone's gallery."*
- *"Open WhatsApp and read me the latest chat names."*
---
## No cable: connect over Wi-Fi
Phone and computer on the **same Wi-Fi**.
**A. QR code (Android 11+)**
```bash
controlmyphone pair-qr
```
On the phone: *Developer options โ Wireless debugging โ Pair device with QR code* โ scan. Done.
You can also just tell the AI *"connect my phone over Wi-Fi"*: it calls `wifi_pair_qr` and shows you the QR in the chat.
**B. Pairing code (Android 11+)**
*Wireless debugging โ Pair device with pairing code* shows `IP:PORT` and a 6-digit code:
```bash
controlmyphone pair 192.168.1.23:37155 123456 192.168.1.23:41234
```
(the last address is the one on the main *Wireless debugging* screen)
**C. From USB (any Android version)**
```bash
controlmyphone wifi # while the cable is connected, then unplug
```
**Different network (4G, office, another city)?** Install [Tailscale](https://tailscale.com) (free) on both the phone and the computer, then use B or C with the phone's Tailscale IP. Wireless debugging and adb traffic stay inside your private network; never expose adb ports to the internet.
---
## Tools
| Tool | What it does |
|---|---|
| `list_devices`, `select_device`, `device_info` | Find and choose phones; model, Android version, battery |
| `screenshot(max_side)` | Image of the screen (default 1280 px max side) |
| `get_ui_elements`, `find_elements(text)` | Numbered list of on-screen elements with centres |
| `tap(x,y)`, `tap_element(i)`, `tap_text(text)` | Tap by pixel, by list number, or by visible text |
| `long_press`, `swipe`, `scroll(direction)` | Gestures |
| `type_text(text, submit)`, `clear_text`, `press_key(key)` | Keyboard |
| `open_app(app)`, `close_app`, `list_apps`, `current_app` | Apps (names like `whatsapp`, `maps`, or package ids) |
| `open_url(url)` | Links, `geo:`, `google.navigation:q=...`, `tel:`, `whatsapp://send?phone=...` |
| `send_file_to_phone(path, to_gallery)`, `get_file_from_phone`, `list_phone_files`, `recent_photos` | Files |
| `wifi_pair_qr`, `wifi_pair_status`, `wifi_pair_code`, `wifi_connect`, `wifi_from_usb`, `wifi_disconnect` | Cable-free connection |
| `wait(seconds)` | Let an app load |
| `run_shell` *(opt-in)*, `install_apk` *(opt-in)* | Power tools, off by default |
Every action tool accepts `look=true` to return a fresh screenshot right after acting.
**Coordinates**: `tap`/`swipe` use the pixels of the *latest screenshot image*, so the AI can point at what it saw. ControlMyPhone AI scales them to real screen pixels.
**Non-English typing** (Urdu, Arabic, emoji): Android's built-in input only types ASCII. Install the free [ADBKeyBoard](https://github.com/senzhk/ADBKeyBoard) APK on the phone once; ControlMyPhone AI switches to it automatically for that text and switches back.
## Settings (environment variables)
| Variable | Default | Meaning |
|---|---|---|
| `CONTROLMYPHONE_ADB` | auto | Full path to adb if it isn't found automatically |
| `CONTROLMYPHONE_SERIAL` | auto | Which phone to use when several are connected |
| `CONTROLMYPHONE_MAX_IMAGE` | `1280` | Max screenshot side in pixels (smaller = cheaper) |
| `CONTROLMYPHONE_READ_ONLY` | off | `1` = AI can look but not touch |
| `CONTROLMYPHONE_ALLOW_SHELL` | off | `1` = enable `run_shell` |
| `CONTROLMYPHONE_ALLOW_INSTALL` | off | `1` = enable `install_apk` |
| `CONTROLMYPHONE_HOME` | `~/.controlmyphone` | Where `actions.log` is written |
Example (Claude Desktop):
```json
"controlmyphone": {
"command": "controlmyphone",
"env": { "CONTROLMYPHONE_ADB": "C:\\platform-tools\\adb.exe", "CONTROLMYPHONE_MAX_IMAGE": "960" }
}
```
## Security notes
Giving an AI control of your phone is powerful. ControlMyPhone AI:
- tells the AI (via MCP server instructions) to **ask you before** sending messages, posting, calling, paying, deleting or changing security settings, never to type passwords/OTPs, and to treat on-screen text as data, not instructions;
- keeps `run_shell` and `install_apk` **off** unless you enable them;
- has a **read-only** mode;
- logs every action to `~/.controlmyphone/actions.log`;
- only talks to phones you have **authorised** (the USB/Wi-Fi debugging prompt on the phone).
Turn off *USB debugging / Wireless debugging* when you're not using it. Banking apps and some others block screenshots: that's expected.
## Troubleshooting
| Problem | Fix |
|---|---|
| `unauthorized` | Unlock the phone, accept the *Allow USB debugging* popup. If it never shows: Developer options โ *Revoke USB debugging authorizations*, replug, set USB mode to *File transfer*. |
| `adb was not found` | Install platform-tools or scrcpy, or set `CONTROLMYPHONE_ADB`. |
| Taps do nothing (Xiaomi/Redmi/POCO) | Developer options โ enable *USB debugging (Security settings)* (needs a SIM + Mi account). |
| `offline` / keeps disconnecting | Try another USB port/cable; run `adb kill-server`. |
| QR pairing never finishes | Same Wi-Fi? Some routers block device-to-device traffic (guest/AP isolation): use the pairing code or `controlmyphone wifi`. |
| Wi-Fi connection gone after restart | Normal on Android: pair/connect again (paired phones only need `wifi_connect`). |
| Screenshot is black | The app is protected (banking/DRM), or the screen is off: `press_key("wakeup")`. |
## Development
```bash
pip install -e ".[dev]"
pytest # uses a fake adb, no phone needed
python scripts/e2e_real_phone.py # safe end-to-end run on a real connected phone
```
Releases: push a tag like `v0.1.0` and the workflow in `.github/workflows/release.yml` builds the one-file apps for Windows, macOS and Linux.
Structure: `wizard.py` (setup page) ยท `installer.py` (adb download, app configs) ยท `adb.py` (finding/running adb) ยท `device.py` (phone actions) ยท `ui.py` (screen XML โ element list) ยท `wireless.py` (QR/code/tcpip) ยท `server.py` (MCP tools) ยท `cli.py` (command line).
## Roadmap
- [ ] iPhone support (via WebDriverAgent / `go-ios`; needs a Mac or a pre-signed WDA, so it's harder)
- [ ] Optional companion Android app (accessibility service) for phones without developer mode
- [ ] Streamable-HTTP mode so a cloud AI can reach a phone through a secure tunnel
- [ ] Screen recording and notification reading
- [ ] Publish to PyPI and MCP registries
Contributions welcome: open an issue or PR.
## License
MIT. Free for everyone, including commercial use.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues