
Mobile Agent Harness
io.github.Aelindrav0.5.0Updated Oct 4, 2026
Android device automation for AI agents: MCP server, CLI, and plugin runtime over adb.
Overview
Lets an AI assistant observe and control an Android device over adb, using accessibility-tree selectors, screenshots, OCR, and app flows.
- What it does
- An MCP server, CLI, and plugin runtime that drives Android devices through a self-healing uiautomator2 bridge, with no device-side app needed. Observation tools include ui.snapshot, ui.dump, ui.find, vision.screenshot, vision.ocr, and vision.diff; action tools include ui.click, ui.set_text, ui.scroll, input.tap, and input.swipe. It also exposes app lifecycle tools (app.launch, app.probe, app.wait_idle), shell and data tools (shell.run, state.prefs, state.db, file.push, file.pull, net.http), event capture, and knowledge/task helpers. Selectors resolve against the live accessibility tree rather than coordinates, and tools return an ok/error envelope.
- When to use it
- Use it when an assistant needs to inspect or operate a real Android device or emulator: reproducing UI flows, reading on-screen state, running app-level checks, or building per-app automation harnesses for development and testing on your own device.
- Requirements
- Runs locally as a Python process (Python 3.9+) with adb on PATH and USB debugging enabled on the target device. Device serial is set via AGENT_SERIAL_DEFAULT, AGENT_SERIAL_USB, or --serial/ANDROID_SERIAL. Optional vision features use MAH_FRAME_STREAM, MAH_VISION_MODE, and MAH_VLM_URL/MAH_VLM_MODEL; the OCR extras require installing the ocr extra.
Installation
In SourceWeft
- Open Mobile Agent Harness in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
mobile-agent-harness
Android device automation for AI agents. MCP server, CLI, and a hot-reloadable plugin runtime on top of a self-healing uiautomator2 bridge. No device-side app required.
中文文档:README.zh-CN.md
This is the base runtime only. Plugins live in the community catalog: awesome-mobile-agent-harness-plugin. App business knowledge for AI lives in app-knowledge-packs, which this repo's knowledge/ loader reads directly.
Install
Requires Python 3.9+ and adb on PATH with USB debugging enabled.
Quick start
- Point the bridge at your device:
- List the tool surface (works without a device) and run the offline tests:
- Call a tool:
- Attach to any MCP client:
All tools return a {"ok": bool, "error"?, ...} envelope. ok=false is a business result (e.g. error_type=selector_not_found) — adapt instead of retrying.
Tools
ui.snapshot returns a compact accessibility-tree listing with element handles (e0, e1, ...); ui.click_handle acts on a handle with drift detection. ui2.state fuses the accessibility tree with OCR for canvas-drawn UIs. ui2.screen_evidence collects measurable screen features (overlay level, motion, color, layout density) without interpreting them. app.probe returns deterministic side signals (package, version, orientation); ui2.timeline captures N frames of lightweight evidence in time order; ui2.orient probes context, routes to matching knowledge packs, and evaluates their state discriminators — returning matched states or ranked hypotheses with the missing evidence listed.
Selectors
Selectors resolve against the live accessibility tree. Coordinates are not used.
Harnesses and plugins
A harness file declares per-app flows as selector steps with pre/postconditions; distill drafts one by exploring an app, lint checks selector quality, and failed postconditions mark tools stale for re-distillation. See harnesses/com.android.settings/harness.json5 for the built-in example.
Plugins drop into plugins/ and register tools or capability providers at load time; registrations are reversible and hot-reloaded on file change. See the Plugin development guide in README.zh-CN.md and knowledge/README.md for the knowledge-pack format.
For business context on apps where model priors are unreliable, point agents at app-knowledge-packs — a community catalog of structural app surveys in the open Agent Skills format, split per feature module for complex apps. Mobile scenarios in particular are private-domain and underrepresented in training data, so agents benefit from loading the relevant survey before operating an unfamiliar app. The local knowledge/ directory remains this repo's runtime layer (packs, icon templates, state discriminators).
Configuration
How it compares
- vs mobile-mcp / agent-device: they are generic device toolsets; this project adds the layer above transport — per-app knowledge as files (harnesses), a hot-reloadable plugin runtime with capability seams, and an explicit adb/root privilege model.
- vs droidrun: droidrun requires a device-side accessibility app; this project is zero-install over adb.
- Root support is declarative: if the device already has
su, the shell seam gains a root provider gated by a command allowlist. This project does not provide root.
Known limitations
Messaging, banking, and e-commerce apps run active anti-automation risk control; the adb tier is unreliable on them. Target use is development, testing, and your own device workflows.
Contributing
Plugins are contributed to awesome-mobile-agent-harness-plugin; app business knowledge to app-knowledge-packs — see their contributing guides.
License
MIT.
Source: README.md at commit a05ec97
Tools
0Version history
1- v0.5.0LatestOct 4, 2026

