Skip to main content
Glama

PHONE HARNESS

A 64-tool Rust MCP server for real Android devices — built on rmcp, driven by ADB, zero Python runtime.

Rust MCP Platform Tools


Overview

Phone Harness exposes an Android device to any MCP client through a single stdio server. Observation is accessibility-first: it reads uiautomator hierarchies, returns a compact indexed DOM, and rejects actions grounded against a stale observation generation. Actions are executed with ADB.

It is a native Rust rewrite of the original Python universal-phone-harness. The Python implementation remains available separately as a compatibility fallback.

+----------------+      stdio / MCP       +-------------------+      ADB      +----------------+
|  MCP client    |  <------------------>  |  phone_harness    |  <-------->  |  Android device|
|  (OpenCode…)   |   64 tools, JSON-RPC   |  Rust, rmcp 3.12  |   shell I/O  |  USB / WiFi    |
+----------------+                        +-------------------+              +----------------+

Related MCP server: ARTEMIS MCP Server

Features

  • 64 tools — observation, gestures, app lifecycle, logs, GPS mocking, screen recording, SMS/call log, file transfer, permissions, batching, crawling and replay, wireless device lifecycle, semantic scrolling, OCR text extraction, cloud lifecycle and configuration.

  • Generation-gated grounding — indexed actions require the observation_generation returned by phone_observe.

  • Serialized device access — a process-wide lock gate serializes ADB work across concurrent MCP calls; phone_wake wakes a sleeping or locked screen before observation.

  • Resilient observation — transient uiautomator dump failures are retried; phone_ocr_screen reads word boxes with local Tesseract, and phone_observe has an opt-in ocr_fallback for accessibility hierarchies with no text.

  • No Python required — a single 5 MB release binary.

  • Token-bounded output — compact DOM with interactive-only filtering by default.

  • Session recording — interaction traces as JSONL, replayable with text re-grounding.

  • Screen recording — frame capture encoded to MP4 with ffmpeg (for devices without screenrecord).

  • Batch commands — multiple actions in one MCP round-trip.

Tool map

Group

Tools

Observe & assert

phone_observe, phone_ocr_screen, phone_assert_state, phone_wait_for, phone_wait_for_settle, phone_wait_stable, phone_health_check

Input

phone_tap, phone_type, phone_swipe, phone_drag, phone_press_key, phone_long_press, phone_double_tap

Navigation

phone_open_app, phone_open_url, phone_open_settings, phone_dismiss_dialog, phone_scroll_until, phone_scroll_collect

Screen

phone_save_screenshot, phone_take_screenshot, phone_start_screen_recording, phone_stop_screen_recording

Apps

phone_list_devices, phone_list_apps, phone_get_foreground_app, phone_terminate_app, phone_install_app, phone_uninstall_app, phone_clear_app_data

Device lifecycle

phone_wake, phone_pair, phone_connect, phone_use, phone_forget

Clipboard

phone_set_clipboard, phone_get_clipboard

Location

phone_set_location, phone_clear_location

Orientation

phone_get_orientation, phone_set_orientation

Diagnostics

phone_get_device_logs, phone_efficiency_report, phone_shell, phone_setting

Data

phone_get_sms, phone_get_call_log, phone_pull_file, phone_push_file, phone_grant_permission

Media

phone_record_sound, phone_launch_activity

Cloud

phone_cloud_status, phone_cloud_start, phone_cloud_stop

Config

phone_config_get, phone_config_set, phone_update_check

Automation

phone_batch, phone_start_recording, phone_stop_recording, phone_replay_trace, phone_crawl_app

phone_observe is accessibility-first: it reads the uiautomator hierarchy and reports an ocr_fallback result. OCR is also exposed as its own tool, phone_ocr_screen.

Install

Official MCP Registry: io.github.ZachDreamZ/phone-harness-rust (latest version 0.3.0, 64 tools — the registry entry tracks that release).

crates.io: cargo install phone_harness_rust.

Prebuilt .mcpb bundle: download phone-harness-rust.mcpb from the v0.3.0 release and install it in any MCP client that supports MCPB.

Prebuilt binary: copy target/release/phone_harness_rust.exe somewhere stable, then register it with your MCP client.

OpenCode global config — ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "phone_harness": {
        "type": "local",
        "command": ["D:\\path\\to\\phone_harness_rust.exe"],
        "protocol": "legacy"
      }
    }
  }
}

Requirements at runtime: ADB on PATH or at D:\platform-tools\adb.exe, USB debugging authorized, ffmpeg on PATH for screen recording.

Build from source

cargo build --release

On Windows with the MSVC toolchain you need the Visual Studio C++ build tools and a Windows SDK (kernel32.lib, dbghelp.lib). build.ps1 in this repository sets LIB and uses the bundled linker when building from a plain shell.

Usage loop

  1. phone_observe → get [1], [2]… badges and an observation_generation.

  2. phone_tap / phone_type with index and that generation.

  3. Text and coordinate selectors do not need a generation.

  4. On a failed assertion, re-observe — don't reuse a stale generation.

{ "index": 3, "observation_generation": 12 }

Lock gate and wake

All ADB-backed work passes through a process-wide lock gate. Concurrent MCP calls queue behind it instead of interleaving shell commands on the same device; a call holds the gate for the full observe/act sequence and releases it on success or error. Actions still validate observation_generation against the observation taken under the gate, so a generation from a different client or an earlier turn is rejected.

phone_wake wakes a sleeping or locked screen before an observe/act loop. Use it first when a device has been idle and the hierarchy comes back empty or shows only a lock screen. The wake runs through the same gate, so it cannot race with an in-flight action.

Observation fallback chain

  1. The accessibility dump runs first, with bounded retries for transient uiautomator failures (idle device or empty XML). Exhausted retries return a clear error, not a silent blank hierarchy.

  2. phone_ocr_screen is a standalone tool: it captures the screen (or uses a supplied image path) and returns word-level text boxes with min_confidence (default 20). It uses a local Tesseract binary found on PATH or at PHONE_HARNESS_TESSERACT, with eng language data, and needs writable temp space. With no usable engine it returns a structured unsupported error plus an install hint instead of empty text.

  3. phone_observe also accepts an opt-in ocr_fallback flag, off by default. When enabled and the accessibility hierarchy has no text, it runs the same OCR path and reports ocr_fallback (attempted, used, reason, image_path, text_boxes, count) alongside the compact DOM and a fresh observation_generation. When the flag is off, the result reports attempted: false.

  4. OCR needs real pixels. A FLAG_SECURE window produces no image data; neither screenshot nor OCR can read text from such a surface.

Wireless device lifecycle

  • phone_pair performs wireless pairing (the adb pair step that supplies a pairing code).

  • phone_connect connects a paired device over host:port (adb connect).

  • phone_use makes one of the connected devices the active target without disconnecting the others. This is the tool-call equivalent of pinning PHONE_HARNESS_SERIAL.

  • phone_forget removes a paired or saved device so it no longer participates in selection.

Selection still follows the rules below: an explicit PHONE_HARNESS_SERIAL / ANDROID_SERIAL wins, a single ready device is used automatically, and with several devices USB is preferred over Wi-Fi. phone_list_devices reports the current selection and transport.

Semantic scroll helpers

  • phone_scroll_until scrolls repeatedly until a target text/selector appears, bounding the number of swipes so a missing target cannot loop forever.

  • phone_scroll_collect gathers matching nodes across successive scroll steps into one result set — useful for long lists that render only visible rows.

  • phone_wait_stable waits for the hierarchy to settle before acting, complementing phone_wait_for_settle.

All three take fresh observations as they go; re-observe after any of them before issuing an indexed action.

Cloud lifecycle and configuration

  • phone_cloud_status reports the current cloud session state.

  • phone_cloud_start starts a cloud session; phone_cloud_stop ends it.

  • phone_config_get reads a configuration value, phone_config_set writes one, and phone_update_check checks for a newer release.

These tools operate on the server configuration and cloud session; they do not change Android device settings (phone_setting) or the pinned device selection.

Device selection and data tools

  • PHONE_HARNESS_SERIAL (or ANDROID_SERIAL) pins one adb device explicitly. With no pin, a single ready device is used; with several, USB (serial without :) is preferred over Wi-Fi (host:port). phone_list_devices reports the selected device and its transport. Multiple Android devices can stay attached at once.

  • PHONE_HARNESS_ADB overrides the adb binary. Default is D:\platform-tools\adb.exe when present, otherwise adb from PATH.

  • phone_get_sms and phone_get_call_log fetch raw provider rows and sort/filter in-process. Results are newest-first and include structured fields; SMS messages also carry an extracted six-digit code when present. This avoids device-side tail/grep, which reads the wrong end of providers that return newest rows first and fails when grep finds no match.

  • Accessibility dumps use /data/local/tmp/phone_harness_dump.xml, writable on a wider range of Android builds than /sdcard/....

Verified on

  • Huawei JLN-LX1 (JLN-LX1), Android 12, 1080×2388, ADB serial U4YYD22415503298.

  • Two devices attached simultaneously: the JLN-LX1 over USB is selected while an MXQ Pro S500 at 192.168.1.22:3222 stays connected over Wi-Fi.

  • Mock GPS provider oc-mock confirmed through dumpsys location.

  • Screen recording produced a 2.67 s / 254 KB MP4 at 3 fps, verified with ffprobe.

Known limitations

  • phone_wait_for_settle and phone_wait_stable use UI-hierarchy stability, not perceptual image diff.

  • phone_save_screenshot writes a raw framebuffer PNG; the SoM overlay is not implemented. Windows marked FLAG_SECURE (banking/payment apps, some lock screens) return no pixels, so neither screenshot nor the OCR fallback can read them.

  • uiautomator retry handles transient idle/empty dumps only; a permanently broken accessibility service still yields an error. OCR needs a local Tesseract binary with eng data and writable temp space, is opt-in inside phone_observe, and is slower than the hierarchy path.

  • phone_set_orientation changes the user_rotation setting; it does not physically rotate the device, and some real devices ignore the setting.

  • phone_set_location installs a mock location provider; it does not override GNSS hardware.

  • phone_replay_trace and phone_crawl_app are simplified versions of their Python counterparts.

  • phone_get_clipboard may return empty on Android 12; phone_set_clipboard works.

  • phone_wake wakes the screen but does not unlock it; a secured lock screen still blocks observation of the app underneath.

Registry identity

  • MCP Registry name: mcp-name: io.github.ZachDreamZ/phone-harness-rust

Research credits

Capability ideas came from mobile-next/mobile-mcp, CursorTouch/Android-MCP, and the original universal-phone-harness. MCP transport is the official Rust SDK rmcp.

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables controlling an Android device from an MCP client via ADB, including wireless debugging discovery, UI-tree inspection, and performing taps, swipes, typing, app actions, and shell commands without relying on screen coordinates.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants and test suites to drive real Android devices or emulators through MCP, executing natural-language automation and testing workflows while collecting screenshots, Logcat output, and device state.
      Apache 2.0
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP-compatible AI assistants to see and control Android devices through ADB and a fast device-control protocol, including screenshots, touch input, typing, app management, UI inspection, file transfer, shell commands, and audio/video streaming.
      1,154 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to control an Android phone by reading the screen, taking screenshots, tapping, typing, swiping, opening apps, and running multi-step tasks. It also supports on-device Android app testing and optional adb commands.
      1,381 npm
      2
      MIT