Skip to main content

mobilerun-core-local is the slim async local-driver core of mobilerun.
No CLI, no agent, no LLM providers — just local Android/iOS drivers for higher-level tools such as mobilerun-core.


  • 📱 Drive local devices — Android over ADB with optional Portal, Android Portal HTTP-only, or iOS Portal HTTP.
  • ⚡ TCP-with-content-provider fallback — fast Android HTTP path over adb forward, transparent fallback to content-provider RPC.
  • 🔌 HTTP-only drivers — connect to already-running Android/iOS portals without taking over setup.
  • 🛠 Portal lifecycle — download, install, accessibility enablement, auto-upgrade.
  • 🪶 Slim — a small async driver package with four runtime deps (async_adbutils, httpx, requests, rich).
  • 🔌 Embeddable — designed to be wrapped by sync facades (e.g. mobilerun-core) or used directly.
  • 🤝 In sync with upstream — verbatim slice of droidrun/mobilerun; behaviour and API track upstream.

📦 Installation

Note: Python >=3.11,<3.14. The Android ADB driver requires ADB on PATH and a device with USB debugging enabled. HTTP-only drivers require an already-running portal URL.

uv pip install mobilerun-core-local

🚀 Quick usage

import asyncio
from async_adbutils import adb
from mobilerun_core_local import AndroidDriver
from mobilerun_core_local.driver.android import ensure_portal_ready


async def main():
    # 1. Optional: make sure Portal is installed + accessibility is on for
    #    Portal-enhanced state/text paths. AndroidDriver still works over ADB
    #    without this step.
    device = await adb.device()
    await ensure_portal_ready(device)

    # 2. Drive the device.
    driver = AndroidDriver(serial=device.serial, use_tcp=True)
    await driver.connect()

    await driver.tap(540, 1200)
    await driver.swipe(540, 1600, 540, 400, duration_ms=300)
    await driver.input_text("hello", clear=True)
    png_bytes = await driver.screenshot()
    tree = await driver.get_ui_tree()


asyncio.run(main())

HTTP-only Android:

import asyncio
from mobilerun_core_local import AndroidPortalHttpDriver


async def main():
    driver = AndroidPortalHttpDriver(
        url="http://127.0.0.1:18080",
        token="...",
    )
    await driver.connect()
    await driver.tap(540, 1200)


asyncio.run(main())

iOS with mobilerun-ios --local:

Follow the Connect an iPhone guide to set up and start the iOS portal.

import asyncio
from mobilerun_core_local import IOSPortalHttpDriver


async def main():
    driver = IOSPortalHttpDriver("http://127.0.0.1:8080")
    await driver.connect()
    await driver.start_app("com.apple.Preferences")


asyncio.run(main())

🧱 Layout

Platform-specific code is namespaced under driver/<platform>/ and transport/<platform>/. Adding a new backend (e.g. iOS over USB, a new Android transport) does not pollute the package root.

mobilerun_core_local/
├── __init__.py                       Re-exports the public driver surface
├── driver/
│   ├── base.py                       DeviceDriver ABC, DeviceDisconnectedError
│   ├── android/
│   │   ├── adb.py                    AndroidDriver — ADB-backed driver
│   │   ├── http.py                   AndroidPortalHttpDriver — HTTP-only driver
│   │   └── portal.py                 Portal APK lifecycle + content-provider helpers
│   └── ios/
│       └── http.py                   IOSPortalDriver — ios-portal HTTP driver
└── transport/
    └── android/
        └── portal_client.py          PortalClient — TCP-with-content-provider fallback

📚 Public API

Re-exported from mobilerun_core_local:

Symbol What it is
AndroidDriver ADB-first Android driver with optional Portal enhancement. Async methods: tap, swipe, input_text, press_button, press_key_code, start_app, stop_app, install_app, uninstall_app, push_file, pull_file, clear_app_data, grant_permission, open_deep_link, screenshot, get_ui_tree, get_apps, list_packages, get_date, and (with Portal) get_clipboard, set_clipboard, get_deep_links, resolve_deep_link.
AndroidPortalHttpDriver HTTP-only Android Portal driver. Requires url and bearer token; does not use ADB at runtime. Adds open_deep_link, get_clipboard, set_clipboard, get_date, get_deep_links and resolve_deep_link on top of the input, app and state verbs.
IOSPortalHttpDriver mobilerun-ios --local driver. Same verbs as AndroidPortalHttpDriver plus install_app and uninstall_app.
IOSPortalDriver / IOSDriver iOS Portal HTTP driver. Requires an already-running ios-portal URL.
DeviceDriver Abstract base for drivers. supported: set[str] declares which verbs a subclass implements. get_ui_tree(filter=False) asks the server for the unfiltered tree.
DeviceDisconnectedError Raised when the device drops mid-call.
validate_android_portal_url(url) / validate_ios_portal_url(url) Normalize + sanity-check portal URLs.
discover_ios_portal(...) Scan localhost for a reachable ios-portal HTTP endpoint.

Android Portal helpers live under mobilerun_core_local.driver.android (not at the package root, since they're Android-specific):

Symbol What it is
setup_portal(device, debug=False, *, version=None, uninstall=True) Download + install + enable the Portal APK on a device. With version (your package version), installs the Portal pinned for it in the version map; without it, or when the map has no entry or can't be fetched, installs the latest release. uninstall=True clears Portal's settings first; uninstall=False updates in place unless the installed APK has a different signature or a higher version code, which Android only allows after an uninstall.
ensure_portal_ready(device, debug=False, *, version=None) Idempotent: install Portal and enable accessibility if needed. With version, also upgrades an installed Portal that is older than the pin, in place; a newer Portal is kept, and a failed upgrade keeps the installed one.
setup_keyboard(device) Switch the device to the Mobilerun IME.
ping_portal(device) Verify Portal is installed and reachable.
PORTAL_PACKAGE_NAME, A11Y_SERVICE_NAME Portal identifiers.
portal_content_uri(pkg, path) Build content://<pkg>/<path> URIs.
portal_a11y_service(pkg), portal_ime_id(pkg) Accessibility service / IME component names.

PortalClient (the TCP-with-content-provider transport) lives at mobilerun_core_local.transport.android.PortalClient — used internally by AndroidDriver, exposed for low-level access.

Connection probes and raw key codes

PortalClient exposes async enable_tcp(), find_existing_forward(), fetch_auth_token(), test_connection(), and tcp_request(client, method, url, extra_headers=None, **kwargs) for provisioning and connection probes. enable_tcp() updates the TCP connection fields and retains content-provider fallback on failure. fetch_auth_token() returns a token without caching it; read or set the cached token with auth_token. tcp_request() uses that token and refreshes it once on HTTP 401/403.

PortalHttpDriver.unwrap_response(response) (in mobilerun_core_local.driver.portal_http) checks HTTP status and unwraps Portal responses; it is also available on AndroidPortalHttpDriver and IOSPortalHttpDriver. AndroidDriver.portal_mode reports the configured auto, required, or disabled policy. Existing private equivalents remain available for compatibility.

With the optional cloud extra, CloudDriver (in mobilerun_core_local.driver.cloud) supports await driver.press_key_code(code) for raw Android KeyEvent codes. It routes to the configured display and sends each write once, using the same disconnect errors as other cloud writes.

AndroidDriver accepts:

  • serial: str | None — ADB serial; None picks the only connected device.
  • use_tcp: bool = False — when True, the underlying PortalClient port-forwards Portal's HTTP server (localhost:N → device:8080) and uses it instead of the content provider. Faster but requires a working forward; falls back transparently.

On devices with a secondary Android user in front, Portal calls go to the foreground user's Portal (am get-current-user). If a state read fails because the foreground user changed, the driver switches to the new user's Portal and retries once. ensure_portal_ready adds an installed Portal to the foreground user with pm install-existing and enables its accessibility service there.

🪵 Logging

All output goes through the "mobilerun_core_local" logger. Configure it yourself; the package attaches no handlers.

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("mobilerun_core_local").setLevel(logging.DEBUG)

🔗 Relationship to upstream mobilerun

This package owns local execution drivers. The full framework imports these drivers for CLI/agent flows; mobilerun-core wraps them behind a sync, backend-neutral API.

Use mobilerun-core-local when you need async local drivers directly. Use mobilerun when you want the full LLM-agent experience, CLI/TUI, and multi-platform support out of the box.

📄 License

MIT — see LICENSE.

Metadata

Release files for mobilerun-core-local 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mobilerun-core-local 0.7.3
File Size Uploaded Provenance Actions
mobilerun_core_local-0.7.3.tar.gz 88.6 kB With provenance Details for mobilerun_core_local-0.7.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mobilerun-core-local 0.7.3
File Interpreter ABI Platform Actions
mobilerun_core_local-0.7.3-py3-none-any.whl Python 3 none any Details for mobilerun_core_local-0.7.3-py3-none-any.whl

Total release size: 153.4 kB

Release files / mobilerun_core_local-0.7.3.tar.gz

Download URL mobilerun_core_local-0.7.3.tar.gz
Size 88.6 kB
Tags Source
SHA-256 checksum
How to use checksums
35afb599cbc476df9cd3e39cfbe20e18cd4c060838e24bd47ba3b1807b59b254
BLAKE2b-256 checksum
How to use checksums
20f3ff1b8502aa9d0eb9ee11dc82e57980fe2a93e86f24cf4e8b6c6cc03fe3cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / mobilerun_core_local-0.7.3-py3-none-any.whl

Download URL mobilerun_core_local-0.7.3-py3-none-any.whl
Size 64.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2a5931ea8fe65feee5b63b5e91e47ead867f816d8ecedca64cdbdb726a31cad
BLAKE2b-256 checksum
How to use checksums
c62679074c5363ab6400941ea51e3e67872fb8dc35eeb8bb270a9e4d8c7cf3df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for mobilerun-core-local 0.7.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mobilerun_core_local-0.7.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page