Skip to main content
Glama

PreviewAPK — a phone for your AI agent

Your agent builds an Android app, and then… neither of you can see it run. No emulator on the machine, no device on the desk, and the Play Store is not a feedback loop.

PreviewAPK gives your agent a real cloud Android phone. Push an APK, it boots in the browser in seconds. The agent drives it — taps, types, screenshots, logs — and verifies its own work before you ever look. You watch the same phone through a link, take the wheel whenever you want, and every session gets a share link you can hand to a client or paste into a PR.

  • $19/month per device, unlimited runs. One device runs one app at a time; swap apps freely.

  • Links are view-only, always. Only the owner's key (agent) or the owner in the portal drives — one driver per session, switchable mid-session with an explicit handoff.

  • No Google Play services on the phones. Apps that need Google sign-in, Maps, or FCM will hit that wall; everything else just runs.

This repo is the open client: the CLI and the MCP server (both single-file, Python standard library only). The PreviewAPK service itself is hosted — you bring an API key from your account at previewapk.dev. PreviewAPK is currently in waitlist beta; join there.

Quick start — CLI

curl -O https://previewapk.dev/cli/previewapk.py
export PREVIEWAPK_API_KEY=pvk_…        # from your portal's Developers card

python3 previewapk.py devices          # see your devices
python3 previewapk.py use "Device 1"   # pick the working device (like cd)
python3 previewapk.py push app.apk --run
python3 previewapk.py tree             # the screen as an element tree
python3 previewapk.py tap --text "Log in"
python3 previewapk.py text "demo@example.com"
python3 previewapk.py shot             # a screenshot you can open
python3 previewapk.py logs --errors    # the app's logcat, noise filtered
python3 previewapk.py relaunch         # app back in front, ~2s, no reboot
python3 previewapk.py handoff user     # hand the human the wheel
python3 previewapk.py links            # the share link for the live session

Pushing to a running device hot-swaps the app in — installed and relaunched in the same session, no reboot.

Coordinates are fractions (0–1), never pixels; the CLI and API reject out-of-range values instead of silently tapping the wrong place, and text refuses when no field is focused instead of typing into the void. Signals an agent can trust: errors say what happened and what to do instead.

Related MCP server: Droidline

Quick start — MCP server

Hosted (zero install): point your MCP client at the remote server — same 27 tools, your API key as a Bearer token, nothing to download or keep current. Claude Code:

claude mcp add --transport http previewapk https://previewapk.dev/mcp \
  --header "Authorization: Bearer pvk_…"

The server issues a session id at connect and your working-device selection rides on it, exactly like the local server. Hosted differences: previewapk_push_apk takes apk_b64 (base64) instead of a local path; file/record downloads return data_b64.

Local (stdio): download previewapk_mcp.py from this repo, then register it with your MCP client. Claude Code:

claude mcp add previewapk \
  --env PREVIEWAPK_API_KEY=pvk_… \
  -- python3 /path/to/previewapk_mcp.py

Cursor / Claude Desktop / other MCP clients (JSON config):

{
  "mcpServers": {
    "previewapk": {
      "command": "python3",
      "args": ["/path/to/previewapk_mcp.py"],
      "env": { "PREVIEWAPK_API_KEY": "pvk_…" }
    }
  }
}

27 tools: list/use devices, push (hot-swaps a running device), start, stop, links, tap by coordinates, by label, or by snapshot ref, swipe, key, type text, relaunch, screenshot (returns a real image, from the framebuffer — it agrees with the hierarchy), UI hierarchy, observe (a compact numbered screen snapshot), act (batched actions), wait_for (elements — or the handback, with condition "driver"), request_human (ask the human for a step only a human should do: a password, a 2FA code, a payment approval — and get back the exact message to relay), finish (file the session wrap-up; the counts in its message — duration, actions, errors — are composed by the server, and finishing does not stop the session unless asked), session logs, handoff, a field-report tool, screen recording (start/stop/download an MP4 of the session), and device controls (timezone, per-app locale, mock GPS location, file push/pull in shared storage, reboot).

The working-device model mirrors the CLI: an agent session selects a device once (previewapk_use_device or previewapk_start), then works on it without repeating its name. Nothing has a default device — an action with no device selected refuses, so a build can never land on the wrong phone by assumption.

How agents should drive

Navigate and assert with the hierarchy (element tree: class, label, center, state flags) — fast, cheap, exact. Verify visuals with a screenshot. Read the logs after actions; a crash's exact reason lives there. Emulator noise (graphics-stack spam from the virtual GPU) is tagged and kept out of errors-only views; copies and downloads are always the full raw log.

Full documentation: previewapk.dev/docs (guides for the API, CLI, MCP, and CI recipes). Agent briefing: previewapk.dev/agents

License

The client tools in this repo are MIT-licensed (see LICENSE). The PreviewAPK service is a separate, hosted product.

Available Tools

27 tools
previewapk_actAInspect

Run a batch of up to 20 actions in order on the device: tap (x/y fractions, or target {text|id|desc, nth}, or target {ref, snapshot_id}), swipe {x1,y1,x2,y2}, long_press, double_tap, type {text, clear, submit}, key {key: back|home|recents|enter|delete or code}, open_app {package}, close_app {package}, open_url {url}, notifications, wait {ms}, wait_for {text|id|desc, present, timeout_s}. Stops at the first failure — earlier actions stay done — and returns per-action results with timing and error envelopes. NEVER replay a batch whose outcome you don't know; observe first. observe='ui'|'screenshot'|'both' attaches the screen after the batch.

Inputs: actions (required), device, observe.

previewapk_deviceAInspect

Device controls for realistic QA. action='set_timezone' (IANA tz, e.g. America/New_York) — verified on the device. action='set_locale' (BCP 47 tag, e.g. de-DE; package optional, defaults to the session app) — per-app language, Android 13+ style; relaunch the app if it doesn't switch live. action='set_location' (lat, lon) — GPS reports a mock fix until cleared. action='clear_location'. action='push_file' (local_path on this machine, remote_path under /sdcard, max 10 MB) — test fixtures, seed files. action='pull_file' (remote_path, local_path, max 10 MB). action='list_files' (remote_path folder, default Download). action='delete_file' (remote_path). action='reboot' — restarts the phone (same phone, same data: app, files and settings survive; ~a minute; a running recording is saved first). There is NO clipboard control: not available on these phones.

Inputs: action (required), tz, lat, lon, +5 more.

previewapk_feedbackAInspect

File a field report about THIS tool — you are one of the few who actually use it, and your report is read and tallied by the team that builds it. Say what broke or behaved unexpectedly (broke), what worked well (worked), what feature you wished it had for your task (wish), and anything you had to work around (workaround). One call, any subset of fields. File it before you stop the session, while the details are fresh — the wishes of working agents are the roadmap.

Inputs: wish, broke, device, rating, +2 more.

previewapk_finishAInspect

File the wrap-up when your work on this session is done, and get back message_for_human — relay it to the human VERBATIM. The counts in it (session duration, actions taken, errors) are composed by the SERVER from the session's real record — never state counts from your own memory instead. The report is also stored on the session (visible in the portal, kept in the session archive after the session ends). end_session defaults to FALSE: finishing does not stop the phone — it stays live at the portal link and idle-stops on the normal 15-minute rule. Pass end_session=true only when the human should get the session-record wording and the phone should stop now. File your previewapk_feedback field report too — finish is the human's summary, feedback is the tool team's.

Inputs: summary (required), device, verdict, end_session.

previewapk_get_logsAInspect

Read the attached app's debug log (logcat) from this session — its prints, warnings, errors and crash traces. Check it after actions and whenever something misbehaves: a crash's exact reason is here. Works after the session ends too (the saved tail of the last session).

Inputs: lines, device, contains, errors_only, +1 more.

previewapk_handoffAInspect

Pass the wheel mid-session: to='user' lets the human drive in the portal (e.g. after you've verified a feature); to='agent' gives control back to you.

Inputs: to (required), device.

previewapk_hierarchyAInspect

Get the current screen as a UI element tree (class, text, content-desc, resource id, bounds, center coordinates, state flags) instead of pixels. Much faster and cheaper than a screenshot for navigation and assertions: find elements, read values, check state. Use previewapk_screenshot for visual checks (layout, overlap, images).

Inputs: device.

previewapk_list_devicesAInspect

List the devices on this account: name, id, profile, Android version, status, attached app. Call this FIRST when the account may have more than one device, then pass the chosen device's name (or id) as the 'device' argument to the other tools.

Inputs: no named parameters.

previewapk_observeAInspect

Read the current screen as a compact numbered snapshot: foreground app, keyboard state, screen size, and the useful elements (ref, type, text, desc, id, pixel bounds/center, state flags) in reading order — plus the same snapshot as compact text. Much cheaper than a screenshot and cheaper than the full hierarchy. Keep the snapshot_id: previewapk_tap with ref + snapshot_id taps an element from it safely (stale_snapshot if the screen changed). Set screenshot=true to also get the frame as an image.

Inputs: scale, device, screenshot.

previewapk_press_keyCInspect

Send an Android keycode: 4=Back, 3=Home, 187=Recents, 66=Enter, 67=Delete.

Inputs: keycode (required), device.

previewapk_push_apkAInspect

Upload an APK file from this machine to the device. If the device is OFF it becomes the attached app (then call previewapk_start). If the device is RUNNING and you hold the wheel, the new app is hot-swapped in live — installed and relaunched with no reboot. Returns the parsed app info (swapped=true on a hot swap; deduped=true when identical bytes were already stored). Installing an OLDER versionCode over the app in a live session is refused (version_downgrade) unless replace=true, which uninstalls the installed app first — its data is deleted.

Inputs: path (required), device, replace.

previewapk_record_downloadAInspect

Download a finished recording's MP4 to a local file path on this machine (resumable — a cut transfer picks up where it stopped). Omit rec_id to get the session's latest finished recording.

Inputs: path (required), device, rec_id.

previewapk_record_startAInspect

Start recording the device screen to an MP4 (screenrecord; one recording caps at 180s). Stop it with previewapk_record_stop, then download with previewapk_record_download. A recording in progress is stopped and saved automatically if the session ends or the phone reboots.

Inputs: name, device.

previewapk_record_stopAInspect

Stop the running recording. The MP4 is pulled off the device to the server and indexed (rec_id, size, duration) — download it with previewapk_record_download. Recordings stay downloadable after the session ends.

Inputs: device.

previewapk_relaunchAInspect

Bring the session's app back to the foreground — after Back exits to the launcher, or the app crashed or was closed. Takes about 2 seconds; no reboot.

Inputs: device.

previewapk_request_humanAInspect

Ask the human for a step only a human should do: a password or 2FA code typed on the phone itself, a payment or consent approval, a CAPTCHA, anything sensitive or irreversible. Records the request in the portal (the device card shows 'Your agent needs you') and returns message_for_human — relay it to the human VERBATIM in chat, then park on previewapk_wait_for with condition='driver' until the wheel comes back (the handback note rides that result). Never ask the human to paste a password or code into chat for you to type — the human types it on the phone. Requires a live session you are driving.

Inputs: reason (required), device.

previewapk_screenshotAInspect

Capture the device's current screen as an image you can see (the real screen — it agrees with the hierarchy). Use it to verify your changes look right. The download resumes automatically if the connection is cut; pass scale=0.5 on weak networks for a quarter-size transfer.

Inputs: scale, device.

previewapk_startAInspect

Start a preview session for the device's attached app. driver='agent': you drive and screenshot; the human watches. driver='user': the human drives in the portal; your input is refused. Returns links info — share the session_url from previewapk_get_links with the human.

Inputs: device (required), driver.

previewapk_statusAInspect

State of the owner's PreviewAPK device(s): attached app, session status, driver, links. Also carries the handoff block (a pending request for the human: reason + when), the agent's finish_report once filed, and — exactly once, on the first status read after the human hands the wheel back — handback_note + resumed:true: that is how you learn the handback happened, no chat message needed.

Inputs: device.

previewapk_stopCInspect

Stop the session. The session link dies with it. (previewapk_feedback files a field report about the tool — what broke, what worked, what you wish it had; reports directly shape what gets fixed and built next.)

Inputs: device.

previewapk_swipeBInspect

Swipe from (x1,y1) to (x2,y2), 0..1 fractions. duration_ms optional (default 300).

Inputs: x1 (required), x2 (required), y1 (required), y2 (required), +2 more.

previewapk_tapAInspect

Tap the screen. Either coordinates (0..1 fractions of the screen, resolution-independent) or a ref from previewapk_observe: pass ref + snapshot_id and the server re-finds that exact element on the current screen first — if it moved or changed, the call fails with stale_snapshot instead of tapping the wrong thing. Requires an agent-driven session.

Inputs: x, y, ref, device, +1 more.

previewapk_tap_textAInspect

Tap the element whose visible text matches (exact match preferred, else substring; use index to pick among matches). If several elements match at the same level and no index is given, the call returns an ambiguous_target result with the candidates instead of guessing. Resolves the element's center from the UI hierarchy — prefer this over coordinate taps whenever the target has text.

Inputs: text (required), index, device.

previewapk_type_textAInspect

Type text into the currently focused field on the device. The field must be focused first (tap it) — the call fails honestly when nothing is focused, instead of typing into the void.

Inputs: text (required), device.

previewapk_use_deviceAInspect

Select your working device — the 'cd' of PreviewAPK. After selecting, every other tool talks to this device until you select another or start one (starting also selects). Pass the device NAME (e.g. 'Device 1') or its id, from previewapk_list_devices.

Inputs: device (required).

previewapk_wait_forAInspect

Wait until an element is present on screen (or gone, with present=false), polling the UI. Returns {found, waited_ms} — found=false at the timeout is a result, not an error. Use after actions that load content instead of sleeping blind. With condition='driver' instead of an element: wait until the human hands the wheel back to you (after previewapk_request_human or any takeover) — the result carries the handback note (handback_note, resumed) when there is one. Driver waits default to timeout_s=300 (max 600): a human step takes human time.

Inputs: id, desc, text, device, +3 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 27 tools

    Disambiguation4/5

    Most tools target distinct actions/resources, and descriptions actively steer agents between similar tools (hierarchy vs observe vs screenshot, tap vs tap_text vs act). A few boundaries still blur: status vs get_links both expose session/driver state, and finish vs stop vs feedback all relate to ending or wrapping up work.

    Naming Consistency4/5

    The previewapk_ snake_case prefix is used consistently across all tools, with most names following a verb_noun or clear resource pattern. Minor deviations exist where noun-only names (hierarchy, device, status) sit alongside action names, but the convention remains readable.

    Tool Count3/5

    27 tools is heavy for a single MCP server and sits in the borderline-overloaded range. Many tools are justified by the broad mobile QA domain, but some consolidation is possible—particularly around recording, observation, and session lifecycle tools.

    Completeness4/5

    The surface covers the full mobile QA lifecycle: device selection, session start/stop, UI observation, gestures, text input, app relaunch, logs, recording, file transfer, device settings, and APK hot-swap. Minor gaps exist, such as standalone long-press/double-tap (only via act) and app-data/network-condition controls, but workarounds are available.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Lets AI agents see and use a real Android phone over Wi-Fi: read the screen, find elements by text or ID, tap, type, swipe, take screenshots and read notifications, without ADB or root.
      519
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Lets AI agents drive real iPhones and Androids hosted in the cloud over HTTPS — taking screenshots, inspecting on-screen elements, tapping, typing, swiping, and launching apps — with no pairing, adb, or Mac required. It can run locally over stdio or as a hosted streamable HTTP endpoint supporting API keys and OAuth sign-in.
      15
      782
      MIT