
Mobile Agent Harness
io.github.Aelindrav0.5.0更新於 Oct 4, 2026
Android device automation for AI agents: MCP server, CLI, and plugin runtime over adb.
概覽
讓 AI 助理透過 adb 觀察與操作 Android 裝置,使用無障礙樹選擇器、截圖、OCR 與應用程式流程。
- 功能
- 這是一個 MCP 伺服器、CLI 與外掛執行環境,透過可自我修復的 uiautomator2 橋接驅動 Android 裝置,不需要在裝置端安裝應用程式。觀察類工具包括 ui.snapshot、ui.dump、ui.find、vision.screenshot、vision.ocr 與 vision.diff;操作類工具包括 ui.click、ui.set_text、ui.scroll、input.tap 與 input.swipe。另外提供應用程式生命週期工具(app.launch、app.probe、app.wait_idle)、Shell 與資料工具(shell.run、state.prefs、state.db、file.push、file.pull、net.http)、事件擷取,以及知識與任務輔助工具。選擇器依據即時無障礙樹解析,而非座標,工具會回傳 ok/error 信封。
- 適用情境
- 當助理需要檢查或操作真實 Android 裝置或模擬器時使用:重現介面流程、讀取畫面狀態、執行應用程式層級檢查,或在自己的裝置上為開發與測試建立依應用程式劃分的自動化 harness。
- 執行需求
- 以本機 Python 程序執行(Python 3.9+),需要 adb 位於 PATH 中,且目標裝置已啟用 USB 偵錯。裝置序號透過 AGENT_SERIAL_DEFAULT、AGENT_SERIAL_USB 或 --serial/ANDROID_SERIAL 設定。選用視覺功能使用 MAH_FRAME_STREAM、MAH_VISION_MODE 與 MAH_VLM_URL/MAH_VLM_MODEL;OCR 功能需要安裝 ocr 附加項目。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mobile Agent Harness,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
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.
來源:README.md,提交 a05ec97
工具
0版本歷史
1- v0.5.0最新Oct 4, 2026

