Overview

The Allternit Android Bridge is a local HTTP service that exposes a real Android device to the Allternit runtime. It wraps the phone-harness-android ADB harness and lets agents and sidecars send SMS, read messages, take screenshots, tap elements, type text, and press hardware keys — all through a small REST API. The bridge is typically consumed by the Open Connector sidecar so that agents can interact with mobile apps and messaging workflows without handling ADB directly.
The Android Bridge runs on a host with an authorized Android device attached over USB or ADB-over-network. Screenshots, messages, and device state stay on that host.

How it works

  1. An Android device is connected to a host machine and authorized for ADB.
  2. The phone-harness-android harness provides low-level ADB helpers such as screenshot, tap_text, and _adb.
  3. The Android Bridge exposes those helpers as FastAPI endpoints on 127.0.0.1.
  4. The Allternit runtime or sidecar calls the bridge over HTTP to perform mobile actions remotely.

Installation

Requirements

  • Python 3.10+
  • ADB installed and on the host PATH
  • An Android device with USB debugging enabled and authorized
  • The phone-harness-android harness checked out on the host

Install dependencies

Start the service

By default the service binds to 127.0.0.1:8020 and looks for the harness at /Users/joe/phone-harness-android.

Configuration

The harness directory must contain a harness.py module with at least the following helpers:
  • check_device() — returns True when an authorized Android device is connected
  • press_home() — presses the home key
  • wait_stable(seconds) — waits briefly for the UI to settle
  • _adb(args, **kwargs) — runs an adb command and returns the result
  • screenshot(path) — writes a PNG screenshot to path
  • tap_text(text, screenshot_path) — OCR-taps the first matching text on screen

Endpoints

Health check

Response:
ready is true only when the harness loaded successfully and an authorized device is connected.

Send an SMS

Response:
The endpoint opens the default SMS app, focuses the message body, types the text, and presses send. The device must have an active SMS plan.

Read messages

Response:
Reading SMS uses the content://sms/inbox provider. Some devices require root access for this query to succeed.

Screenshot

Response:
The image is returned as a base64-encoded PNG and can be passed directly to vision-capable agents or saved to disk.

Tap

Tap by OCR text:
Tap by absolute coordinates:
Response:
When text is provided, the bridge takes a screenshot and uses the harness to locate and tap the first matching text. If the text is not found, the endpoint returns HTTP 404.

Type text

Response:
Spaces are escaped for ADB input (%s) before the command is sent.

Press a key

Supported keys: home, back, recent, power, menu.
Response:

Error handling

Integrating with the runtime

The Android Bridge is normally consumed through the Open Connector sidecar as an action or MCP tool. A minimal tool registration maps each bridge endpoint to a typed function:
For local-only use, you can also call the bridge directly from a custom tool or workflow step.

Security considerations

  • The bridge binds to 127.0.0.1 by default and has no built-in authentication. Only run it on trusted hosts or behind a gateway that enforces auth.
  • ADB authorization is handled by the Android device itself. An unauthorized device cannot be controlled until the RSA key dialog is accepted on the device.
  • SMS and screenshots contain sensitive data. Keep the bridge on the same host as the device and avoid exposing it to untrusted networks.