turbo-android-mcp
# turbo-android-mcp
`turbo-android-mcp` is a zero-dependency Node.js MCP server that drives Android phones, tablets, and emulators over standard `adb` (`npx -y turbo-android-mcp`) on Windows, macOS, and Linux without device root. When connected over `adb` (`AdbTransport`), `tools/list` exposes only the 12 non-root screen and app tools and hides the 7 host root tools so the model does not waste context tokens or call unavailable commands.
Core capabilities over standard `adb`:
- Multi-window UI trees and delta diffs: `ui_tree` dumps the Android accessibility hierarchy via `uiautomator dump --windows` (preserving split-screen panes and dialogs), strips system bars, and formats clickable or text nodes with center coordinates `(cx,cy)` capped at 6,000 characters. Pass `onlyChanged: true` for a `+` / `~` / `-` delta diff against the previous snapshot, and pass `index`, `text`, or `id` directly to `tap`, `type_text`, and `batch_actions`.
- Mobile Chrome and WebView CDP bridge on port `9333`: Android browsers and WebViews often expose empty trees to `uiautomator`. The built-in CDP bridge (`daemon/cdp-bridge.mjs`) detects `@chrome_devtools_remote`, `@brave_devtools_remote`, and `@webview_devtools_remote_<pid>` sockets, checks the active package against the deny-zone list, and forwards DevTools traffic to `127.0.0.1:9333` for [`turbo-browser-mcp`](https://github.com/Tthanh2k6/turbo-browser-mcp).
- Banking, wallet, and password deny-zones: Every screen read, tap, swipe, text input, app launch, and CDP attach blocks banking and e-wallet apps (`momo`, `zalopay`, `vnpay`, `shopeepay`, `paypal`, `vcb`, `techcombank`, `mbbank`, `bidv`, `vietinbank`), `VNeID`, password managers (`1password`, `bitwarden`, `keepass`, `lastpass`, `dashlane`, `protonpass`), and root managers (`KernelSU`). Password nodes (`password="true"`) are masked as `"••••"`, and `type_text` rejects calls when a password field is focused or targeted.
- Vietnamese and Unicode IME input: ASCII text uses `input text`, while accented Vietnamese, CJK, and emoji text is sent as Base64 broadcasts via `TurboImeService` with automatic restoration of the previous keyboard (`/data/local/tmp/turbo_prev_ime`).
## Install and configure
Requires Node 20 or newer and `adb` (Android Platform Tools) with USB debugging or Wireless debugging enabled on the target Android device.
Claude Code:
```bash
claude mcp add turbo-android -- npx -y turbo-android-mcp
```
MCP clients using an `mcpServers` JSON file (Cursor, Claude Desktop, Antigravity):
```json
{
"mcpServers": {
"turbo-android": {
"command": "npx",
"args": ["-y", "turbo-android-mcp"],
"env": {
"TURBO_ANDROID_ADB": "adb",
"TURBO_ANDROID_SERIAL": "",
"TURBO_ANDROID_LANG": "en"
}
}
}
}
```
From source:
```bash
git clone https://github.com/Tthanh2k6/turbo-android.git
cd turbo-android
node --test test/*.test.mjs
```
## Environment variables
| Variable | Default | Purpose |
| :--- | :--- | :--- |
| `TURBO_ANDROID_ADB` | `adb` | Path or binary name for the Android Debug Bridge executable (`AdbTransport`). |
| `TURBO_ANDROID_SERIAL` | *(empty)* | Target device serial passed to `adb -s <serial>` when multiple devices are connected. |
| `TURBO_ANDROID_LANG` | `en` | Language for tool output and error messages (`en` or `vi`). |
| `TURBO_ANDROID_IME_PACKAGE` | `vn.trungthanh.turboandroid` | Package name (or `package/.Service`) of the companion `TurboImeService` APK used for Base64 Unicode and Vietnamese text input. |
| `TURBO_ANDROID_TRANSPORT` | auto (`adb` on PC/Mac, `chroot` when UID 0 on Linux) | Force `adb` or `chroot` transport. |
| `TURBO_ANDROID_URL` | *(empty in direct ADB mode)* | When set (or when `TURBO_ANDROID_TOKEN` / `TURBO_SESSION_ID` is present), `android-mcp` forwards tool calls over HTTP to `turbo-android-d` (`POST /internal/tool`). |
## MCP tools
### Screen navigation and app tools (no root required over ADB)
| Tool | Purpose | Key parameters |
| :--- | :--- | :--- |
| `ui_tree` | Dump and parse the current screen UI hierarchy into compact nodes with `(cx,cy)` center coordinates, or return a `+` / `~` / `-` delta diff | `onlyChanged` (default `false`) |
| `screenshot` | Capture the screen as a PNG image (downscaled when Python + Pillow are available) | `maxSide` (default `1024`) |
| `tap` | Tap a node by `index`, `text`, or `id` from the latest `ui_tree`, or at physical pixel coordinates | `index`, `text`, `id`, `x`, `y` |
| `swipe` | Swipe from `(x1, y1)` to `(x2, y2)` | `x1`, `y1`, `x2`, `y2`, `durationMs` (default `300`) |
| `key` | Send a hardware or navigation key event | `key` (`BACK`, `HOME`, `ENTER`, `RECENTS`, `VOLUME_UP`, `VOLUME_DOWN`, `POWER`) |
| `type_text` | Type text into the focused field, or first tap a field matched by `index`, `id`, or `targetText` from the latest `ui_tree` | `text`, `value`, `index`, `id`, `targetText`, `submit` (default `false`) |
| `open_app` | Launch an installed application by package name | `package` |
| `open_settings` | Open an Android Settings screen directly | `page` (`main`, `wifi`, `bluetooth`, `display`, `sound`, `battery`, `apps`, `app_details`, `location`, `notifications`, `storage`, `developer`, `date`, `language`, `accessibility`, `network`), `package` |
| `list_apps` | List installed package names | `filter`, `thirdPartyOnly` (default `true`) |
| `current_app` | Get the foreground package and activity from `dumpsys window` | *(none)* |
| `wait` | Sleep for a bounded duration | `ms` (max `5000`, default `1000`) |
| `batch_actions` | Run multiple non-root UI steps (`tap`, `type_text`, `swipe`, `key`, `wait`, `open_app`, `open_settings`, `ui_tree`) in one call | `steps`, `stopOnError` (default `true`), `returnUiTree` (default `false`), `onlyChanged` (default `false`) |
### System inspection and privileged tools (daemon / chroot root mode only)
These 7 tools are hidden from `tools/list` in standard `AdbTransport` mode. When running inside the on-device daemon (`turbo-android-d`) or `ChrootRootTransport`, mutating tools pause and request user approval on the Android screen.
| Tool | Purpose | Key parameters |
| :--- | :--- | :--- |
| `settings_get` | Read a `system`, `secure`, or `global` setting | `namespace`, `key` |
| `settings_put` | Write a `system`, `secure`, or `global` setting (security keys like `adb_enabled` and `enabled_accessibility_services` are blocked) | `namespace`, `key`, `value` |
| `app_manage` | Inspect or manage a package (protected system and deny-zone packages are blocked) | `action` (`info`, `force_stop`, `clear_data`, `enable`, `disable`, `grant_perm`, `revoke_perm`), `package`, `permission` |
| `root_file` | `stat`, `list`, `read`, or `write` files with `realpath` symlink confinement | `action`, `path`, `content`, `encoding` (`utf8`, `base64`), `maxBytes` |
| `system_diagnostics` | Read battery, memory, storage, thermal, redacted `logcat`, or filtered `dumpsys` | `kind`, `service`, `lines`, `filter` |
| `power_saver` | Inspect or control Battery Saver and App Standby Bucket | `action` (`status`, `set_low_power`, `app_standby_bucket`), `enabled`, `package`, `bucket` |
| `root_shell` | Execute a host shell command (destructive commands and `/data/adb` access are blocked) | `command` |
## Safety boundaries
1. **Deny zones:** `ui_tree`, `screenshot`, `tap`, `swipe`, `type_text`, `open_app`, `app_manage`, and the CDP bridge refuse to inspect or interact with banking apps, e-wallets (`momo`, `zalopay`, `vnpay`, `shopeepay`, `paypal`, `vcb`, `techcombank`, `mbbank`, `bidv`, `vietinbank`), `VNeID`, password managers (`1password`, `bitwarden`, `keepass`, `lastpass`, `dashlane`, `protonpass`), and root managers (`KernelSU`).
2. **Password masking and input refusal:** `parseUiTreeXml` masks any node with `password="true"` as `"••••"` and strips its `content-desc`. If a password field is focused in the latest UI tree, `type_text` rejects the call so the user can enter credentials manually.
3. **Log and audit redaction:** `system_diagnostics` and the SHA-256 hash-chained audit log (`daemon/audit-log.mjs`) redact Bearer tokens, URL token query parameters, JWTs, and 32+ character hex secrets.
## On-device daemon and control app (advanced mode)
In addition to standalone `adb` usage from a computer, this repository includes the full on-device stack for rooted Android tablets running a Debian `arm64` chroot:
- `daemon/`: zero-dependency Node ESM HTTP + SSE server (`127.0.0.1:8765`), CLI adapters (`claude`, `codex`, `agy`, `opencode`), project/git/terminal workers, and a local CDP bridge (`127.0.0.1:9333`) that forwards Android Chrome or Brave DevTools sockets to `turbo-browser-mcp`.
- `app/`: Kotlin + Jetpack Compose control client (`minSdk 26`, `targetSdk 36`), foreground service, floating cross-app emergency `STOP` overlay, and `TurboImeService`.
- `scripts/`: chroot installer (`install.sh`), daemon start/stop scripts, and `watchdog.sh`.
## License
MIT
TDQS
Scored across 19 tools
Most tools target a clearly distinct layer (UI tree, screenshot, tap/swipe/key, app lifecycle, settings, root, files, diagnostics). Some fuzziness exists between root_shell and the narrower root_file/settings_put/app_manage, and between open_settings (opens a UI page) and settings_get/settings_put (read/write values), but descriptions and approval semantics keep them separable.
All snake_case with recognizable families (settings_get/put, root_shell/root_file, open_app/open_settings, list_apps). There is a mix of verb-first (list_apps, open_app) and noun-first (ui_tree, app_manage, power_saver, system_diagnostics) patterns, but each family is internally consistent and guessable.
19 tools is on the heavy side but is justified by a broad Android surface (UI automation, app control, settings, root, files, diagnostics, power). No tool looks redundant enough to remove, though batch_actions and root_shell are broad multi-capability entry points that inflate perceived surface.
Covers the core automation loop (observe screen, tap/type/swipe, launch app, batch sequences) plus privileged operations, settings, files, and diagnostics. Notable gaps remain: richer gestures (long-press, double-tap, pinch), element-level waits/conditions, clipboard, and notification-shade interaction, all of which agents must work around via coordinates or root_shell.