Tap

tap-agent commands

Every command of tap-agent, the CLI and MCP server an AI agent uses to drive an Android device through the Tap server. Each one lists its options, the MCP tool that does the same, and what it prints.

Experimental: commands and output may change in any release. Generated from the CLI parser for Tap 0.3.0; tap-agent <command> --help prints the same options.

Targets

A ref from the latest snapshot, such as @e3, or key=value terms joined by commas, all of which must match: id=pay, text=Pay, text~=Pay (contains), desc=, hint=, class=, pkg=, index=1.

An action needs exactly one matching node. With none or several it is refused before anything is sent to the device.

Options on every step

-s NAME picks the session (default $TAP_AGENT_SESSION, else agent). -d SERIAL picks the device when the session holds several.

Steps that act also take --settle (wait for the screen to stop changing and print what changed), --events KINDS (print the device events seen during the step), --expect KIND[:TEXT] (require one, such as toast:saved), --event-timeout and --expect-death (the step must crash a watched app).

Exit codes
  • 0done
  • 1the step failed; the reason is on stderr
  • 2the command line is wrong
  • 3no Tap server is running (tap start)
  • 4a watched app crashed or stopped responding during the step

Sessions and devices

A session is a held connection on the server: it outlives each CLI call, is shared by the CLI and the MCP server, and ends on release or after 15 idle minutes. --session NAME (or TAP_AGENT_SESSION) keeps several apart. A device is held by one session at a time, exactly as a test holds it.

tap-agent devices #

List devices, properties and who holds them; or unquarantine SERIAL: put a checked quarantined device back in service (retries its cleanup first).

tap-agent devices [--json] [{unquarantine}] [serial]
actionomit to list; one of unquarantine; optional
serialunquarantine: the device's serial; optional
--jsonlist: the devices as JSON, each with held_by

MCP: devices(as_json), unquarantine(serial)

Examples

tap-agent devices
85e49002  FREE  API 29  samsung SM-J810G  physical
emulator-5554  LEASED  API 34  Google sdk_gphone64_x86_64  emulator  held by 'agent'
tap-agent devices unquarantine 85e49002
85e49002 is not quarantined; nothing to do

tap-agent attach #

Attach a device to the session (created if needed).

tap-agent attach [--driver-start {auto,cold}] [--idle IDLE]
    [--wait-for-device DURATION] [--quarantined] serial
serial—
--driver-start DRIVER_STARTcold: start fresh instrumentation; detach an existing attachment first; one of auto, cold; default auto
--idle IDLEend the session after this long unused (default 15m)
--wait-for-device DURATIONwait this long for a device another session holds
--quarantinedattach a quarantined device to inspect and fix it (it stays quarantined until unquarantine)

MCP: attach(serial, idle_minutes, wait_for_device_seconds, inspect_quarantined, driver_start)

Examples

tap-agent attach emulator-5554
attached emulator-5554 to session 'agent', idle timeout 15m
tap-agent attach 85e49002 --wait-for-device 2m --idle 30m
attached 85e49002 to session 'agent', idle timeout 30m

tap-agent sessions #

List sessions with their devices.

tap-agent sessions [--json]
--jsonthe SDK connections as JSON

MCP: sessions(as_json)

Example

tap-agent sessions
agent  idle 2s of 15m  emulator-5554
ci  idle 4m of 15m  85e49002

tap-agent detach #

Detach one device without ending its session.

tap-agent detach

No options of its own.

MCP: detach(device)

Example

tap-agent detach -d 85e49002
detached 85e49002 from session 'agent'

tap-agent release #

End the session and detach its devices.

tap-agent release

No options of its own.

MCP: release()

Example

tap-agent release
released session 'agent' (detached emulator-5554)

tap-agent server-info #

Daemon version, compatibility and configuration.

tap-agent server-info [--json]
--jsonstructured JSON instead of text

MCP: server_info(as_json)

Example

tap-agent server-info
daemon version     0.3.0
protocol version   5.3
adb executable     adb
state dir          /home/me/.tap
driver available   yes
defaults           action 10, wait 10, lifecycle 30, idle_stable 0.2, acquire 300
api compatibility  2

tap-agent device-info #

The whole device state: display, screen and keyguard, keyboard, conditions, top activity.

tap-agent device-info [--json]
--jsonstructured JSON instead of text

MCP: device_info(as_json, device)

Example

tap-agent device-info
api-level            34
model                sdk_gphone64_x86_64
display-width        1080
display-height       2400
display-rotation     NATURAL
current-package      com.shop
screen-on            yes
keyguard-locked      no
keyboard-shown       no
foreground-activity  com.shop/com.shop.CheckoutActivity
animations           on
dark-mode            off
font-scale           1
density              420 dpi
…

tap-agent capabilities #

Read SDK operation support and prerequisites; no device changes.

tap-agent capabilities [--json]
--jsonstructured capability entries

MCP: capabilities(as_json, device)

Example

tap-agent capabilities
TAP  SUPPORTED  Execution-time checks and Android acceptance still apply.
DISMISS_KEYGUARD  CONDITIONAL  Only a keyguard without a PIN, pattern or password can be dismissed. …
KEYBOARD_IME_ACTION  CONDITIONAL  Requires Android API 30; device API 34. …
RECORD_AUDIO_PLAYBACK  CONDITIONAL  Requires Android API 33; device API 34. …
…

Reading the screen

snapshot is the main way to see the screen: text, one node per line, grouped by window, each with a ref (@e12) to act on. A ref names a selector the server found to match exactly that node, and keeps naming it while it stays on screen. Prefer it to screenshot, which an agent has to look at. elements reads a collection, one line per match, in one bulk call, without a diagnostic snapshot; --texts projects raw text. Snapshots and settle append unread historical toasts; toast reads retained toasts without consuming them, and toast --wait waits for one. Gaps/resets are explicit; history is not current UI.

tap-agent snapshot #

Print the screen, one node per line with its ref.

tap-agent snapshot [-i | --all] [--json] [--package PACKAGE] [--window WINDOW]
    [--keyboard {collapse,show,omit}] [--system-bars {collapse,show,omit}]
-i, --interactiveinteractive controls with descendant context and labeled groups
--allevery node, layout containers too
--jsonthe complete structured snapshot with selector candidates; no view level or filter
--package PACKAGEonly windows rooted in this package
--window WINDOWonly this one-based window ordinal from the snapshot header
--keyboard KEYBOARDthe keyboard window: one header line with a count (collapse, the default), its nodes (show), or nothing (omit); one of collapse, show, omit
--system-bars SYSTEM_BARSthe status and navigation bars, as --keyboard; the shade and system dialogs always show; one of collapse, show, omit; default collapse

MCP: snapshot(view, as_json, package, window, keyboard, system_bars, device)

Examples

tap-agent snapshot
# com.shop · window 1
@e1  [TextView]  "Checkout"
@e2  [EditText]  empty  hint="Email"  id=email  accepts=tap,long-tap,edit
@e3  [CheckBox]  "Save card"  accepts=tap
@e4  [Button]  "PAY $12.40"  id=pay  accepts=tap
# com.android.systemui · window 2 · status bar (6 nodes, collapsed)
tap-agent snapshot -i --package com.shop
# com.shop · window 1
@e2  [EditText]  empty  hint="Email"  id=email  accepts=tap,long-tap,edit
@e3  [CheckBox]  "Save card"  accepts=tap
@e4  [Button]  "PAY $12.40"  id=pay  accepts=tap
  • accepts= says what the node takes: tap, long, check, edit, scroll, or actions for accessibility actions only (see action).
  • The keyboard and the status and navigation bars collapse to one header line each; --keyboard show and --system-bars show list their nodes, omit drops them, and --window N shows one window in full.

tap-agent inspect #

Read one node's complete state.

tap-agent inspect [--timeout TIMEOUT] [--json] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--timeout TIMEOUTread budget, at most 120s
--jsonstructured JSON instead of text

MCP: inspect(target, timeout_seconds, as_json, device)

Example

tap-agent inspect @e2
[EditText]  empty  hint="Email"  id=email
package   com.shop
bounds    [63,126][1017,244]
state     enabled clickable long-clickable focusable
actions   show-on-screen, select, clear-selection, focus

tap-agent exists #

Whether any node matches now.

tap-agent exists [--timeout TIMEOUT] [--json] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--timeout TIMEOUTread budget, at most 120s
--jsonstructured JSON instead of text

MCP: exists(target, timeout_seconds, as_json, device)

Examples

tap-agent exists text~=Pay
yes
tap-agent exists text=Receipt
no

tap-agent count #

Count matching nodes now.

tap-agent count [--timeout TIMEOUT] [--json] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--timeout TIMEOUTread budget, at most 120s
--jsonstructured JSON instead of text

MCP: count(target, timeout_seconds, as_json, device)

Example

tap-agent count class=EditText
2

tap-agent elements #

Read all matching nodes in one bulk read, one line each.

tap-agent elements [--timeout TIMEOUT] [--json] [--texts] target
targetwritten selector with optional pkg and relations; no refs, first or index
--timeout TIMEOUTcommand budget, at most 120s
--jsonthe SDK snapshots (or texts) as a JSON array
--textsreturn raw text values instead of element state; preserve nulls and empty strings

MCP: elements(target, texts, timeout_seconds, as_json, device)

Examples

tap-agent elements class=EditText
[EditText]  "me@example.com"  hint="Email"  id=email
[EditText]  empty  hint="Card number"  id=card
tap-agent elements class=Button --texts
"PAY $12.40"
"CANCEL"

tap-agent settle #

Wait for the screen to stop changing, then print what changed.

tap-agent settle [--full] [--package PACKAGE] [--stable-for STABLE_FOR]
    [--signal {tree,pixels,all}] [--timeout TIMEOUT]
--fullalso print unchanged nodes (=)
--package PACKAGEexplicit package; otherwise use the focused app
--stable-for STABLE_FORquiet period, 1ms..30s, no greater than timeout; default 0.5
--signal SIGNALwhat must stop changing; one of tree, pixels, all; default tree
--timeout TIMEOUTat most 120s; default 10s

MCP: settle(full, timeout_seconds, package, stable_for, signal, device)

Examples

tap-agent settle
# com.shop · window 1
+ @e6  [TextView]  "Paid. Receipt #4471"
+ @e7  [Button]  "DONE"  id=done  accepts=tap
# removed
- @e4  [Button]  "PAY $12.40"  id=pay  accepts=tap
tap-agent settle --signal pixels --stable-for 1
(no change)

tap-agent wait #

Wait until a target is visible (or gone, or exactly one node).

tap-agent wait
    [--gone | --one | --state {visible,gone,one,enabled,disabled,checked,unchecked,focused,text,text-contains,count} | --until CONDITION]
    [--value VALUE] [--timeout TIMEOUT] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--gone—
--one—
--state STATEvisibility, state, text, or count condition; one of visible, gone, one, enabled, disabled, checked, unchecked, focused, text, text-contains, count
--until CONDITIONuntil the target's node satisfies CONDITION, in the target grammar: enabled=true,text=Pay or a JSON selector
--value VALUEexpected text or count for --state text/text-contains/count
--timeout TIMEOUTat most 120s; default 10s

MCP: wait_for(target, state, timeout_seconds, value, until, device)

Examples

tap-agent wait text~=Receipt
text~=Receipt is visible
tap-agent wait text=Loading --gone
text=Loading is gone
tap-agent wait id=pay --state enabled
id=pay is enabled
tap-agent wait id=pay --until enabled=true,text~=Pay
id=pay satisfies enabled=true,text~=Pay

tap-agent activity #

Print the activity on top of the screen (package/class).

tap-agent activity [--json]
--jsonpackage_name and class_name, or null

MCP: foreground_activity(as_json, device)

Example

tap-agent activity
com.shop/com.shop.CheckoutActivity

tap-agent screenshot #

Save a PNG and print its path.

tap-agent screenshot [-o OUT]
-o, --out OUTfile (default .tap/agent/<serial>-<time>.png)

MCP: screenshot(device, path)

Example

tap-agent screenshot -o checkout.png
checkout.png

tap-agent capture #

Save one evidence bundle (the screen, hierarchy, device/driver logs and activity/window state now, and the device's history as text and JSON); or list, show or clean the bundles taken.

tap-agent capture [--name NAME] [-o OUT] [--last DURATION | --from TIME]
    [--newer-than DURATION | --since TIME] [-L] [--older-than DURATION]
    [--all] [--json] [{list,show,clean}] [NAME|ID]
actionomit to take a bundle; list, show NAME|ID or clean NAME|ID manage the ones taken; one of list, show, clean; optional
NAME|IDshow/clean: the bundle's name, or its id (as capture list -L shows it); optional
--name NAMEtaking: label the new bundle (1..80 letters, digits, dots, dashes, underscores)
-o, --out OUTnew private directory, never overwrite (default .tap/agent/capture-<serial>[-NAME]-<time>)
--last DURATIONtaking: only the last DURATION of history (default: all that is kept)
--from TIMEtaking: history from this ISO time with a time zone
--newer-than DURATIONlist: bundles taken in the last DURATION
--since TIMElist: bundles taken since this ISO time with a time zone
-L, --longlist: id, folder, parts and failed parts
--older-than DURATIONclean: every bundle taken longer ago than DURATION
--allclean: every bundle
--jsonlist/show: structured JSON instead of text

MCP: capture(action, name, device, path, last, start, newer_than, since, long, older_than, all_captures, as_json)

Examples

tap-agent capture --name checkout-bug
capture checkout-bug saved to .tap/agent/capture-emulator-5554-checkout-bug-20261121-215915-931
.tap/agent/capture-…/emulator-5554.screenshot.png
.tap/agent/capture-…/emulator-5554.hierarchy.xml
.tap/agent/capture-…/emulator-5554.snapshot.txt
.tap/agent/capture-…/emulator-5554.device-info.json
.tap/agent/capture-…/emulator-5554.logcat.txt
.tap/agent/capture-…/emulator-5554.history.txt
…
tap-agent capture list
2026-11-21T19:59:18.401Z  checkout-bug  emulator-5554  2.6MiB
tap-agent capture clean checkout-bug
cleaned capture checkout-bug (.tap/agent/capture-emulator-5554-checkout-bug-20261121-215915-931)
  • screenshot saves only the image and snapshot saves nothing; capture is the bundle to attach to a bug. -o DIR must be a new directory: nothing is overwritten.

tap-agent deaths #

App crashes and ANRs since the device was attached (watched apps; --all for every app).

tap-agent deaths [--package PACKAGE] [--all] [--trace SEQ] [--json] [--wait]
    [--timeout TIMEOUT]
--package PACKAGEonly this app's
--allalso apps the session did not start or target
--trace SEQprint one death's full stack trace
--jsonstructured entries
--waitblock until a watched app dies (exit 4), the session ends or --timeout (exit 0); run it in the background to be told; keeps no idle session alive
--timeout TIMEOUTwith --wait: give up after this long (default: until the session ends)

MCP: deaths(package, all_apps, trace, as_json, device)

Examples

tap-agent deaths
#1 com.shop crashed (pid 23554): java.lang.IllegalStateException: Out of stock
tap-agent deaths --trace 1
com.shop crashed (pid 23554): java.lang.IllegalStateException: Out of stock

java.lang.IllegalStateException: Out of stock
	at com.shop.Cart.pay(Cart.kt:88)
	at com.shop.CheckoutActivity.onPay(CheckoutActivity.kt:41)
  • Any step that makes a watched app crash exits with code 4 and prints the crash under its output.

tap-agent media-record #

Explicit bounded video/audio recording; save bytes privately on stop.

tap-agent media-record [--no-video] [--audio-source {output,playback,mic}]
    [--for DURATION] [-o OUT] {start,stop}
actionone of start, stop
--no-videostart: audio only
--audio-source AUDIO_SOURCEstart: output mutes speakers; mic captures microphone; one of output, playback, mic
--for DURATIONstart: stop after this long, whole seconds: 1s..30s with video, 1s..60s audio only
-o, --out OUTstop: additional new output; a private canonical copy is retained

MCP: media_record(action, video, audio_source, duration_seconds, path, device)

Examples

tap-agent media-record start --for 20s
recording started
tap-agent media-record stop -o checkout.mp4
saved recording to checkout.mp4

Acting on elements

Every action takes a target and needs exactly one matching node: zero is NOT_FOUND, several is AMBIGUOUS, and both fail before anything touches the device. A tap whose point another window covers (a dialog, the shade) fails as NOT_INTERACTABLE / OBSCURED. With --settle, the command then waits for the screen to stop changing and prints what changed, which is usually enough to pick the next step.

tap-agent tap #

Tap a node.

tap-agent tap [--long | --double | --outside-panel] [--allow-reach-below]
    [--count COUNT] [--interval INTERVAL] [--duration DURATION]
    [--timeout TIMEOUT] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--longlong-press instead
--doubledouble-tap instead
--outside-paneltap outside the dialog, menu, drawer or sheet the target is in
--allow-reach-belowwith --outside-panel: send the touch even onto the screen under a panel that lets touches through
--count COUNTtap this many times, 1..100; default 1
--interval INTERVALrelease-to-press gap for counted taps, 40ms..1s (default 100ms)
--duration DURATIONhold the finger down for this duration, 1ms..30s (implies --long)
--timeout TIMEOUTcommand budget, at most 120s; must cover the whole gesture

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: tap(target, long, double, count, interval, duration, timeout, outside_panel, allow_reach_below, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent tap @e4
tapped @e4
tap-agent tap id=pay --settle
tapped id=pay
# com.shop · window 1
+ @e6  [TextView]  "Paid. Receipt #4471"
# removed
- @e4  [Button]  "PAY $12.40"  id=pay  accepts=tap
tap-agent tap id=save --expect toast:saved
tapped id=save
events:
✓ toast "Card saved" (com.shop)
tap-agent tap text=Item --long
long-tapped text=Item
  • With --settle the step waits for the screen to stop changing and prints the difference: + added, - removed.
  • A refusal says what to do next, for example several nodes match; use a ref from snapshot or a narrower selector. Nothing is sent to the device.

tap-agent fill #

Replace a field's text (no key events).

tap-agent fill [--timeout TIMEOUT] [--sensitive] target text
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
text—
--timeout TIMEOUTcommand budget, at most 120s
--sensitivea secret: the session log and export never hold the text

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: fill(target, text, timeout_seconds, sensitive, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent fill id=email me@example.com
filled id=email
tap-agent fill id=card 4111111111111111 --sensitive
filled id=card

tap-agent type #

Type into the focused field, or into TARGET after tapping it and waiting for its focus.

tap-agent type [--no-await-focus] [--timeout TIMEOUT]
    [--focus-timeout FOCUS_TIMEOUT] [--sensitive] [target] text
targetoptional, first as for fill: a ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes); optional
textthe characters to type (alone: into the focused field)
--no-await-focuswith a target: explicitly skip its SDK focus wait
--timeout TIMEOUTper tap/type budget, at most 120s (not an overall deadline)
--focus-timeout FOCUS_TIMEOUTtarget focus wait budget; SDK default 10s, at most 120s
--sensitivea secret: the session log and export never hold the text

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: type_text(text, target, await_focus, timeout_seconds, focus_timeout_seconds, sensitive, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent type id=email ' extra'
typed 6 characters
tap-agent type 1234
typed 4 characters
  • The target comes first, as for fill: type [TARGET] TEXT; alone, TEXT goes to the focused field. fill TARGET TEXT replaces the field's text instead.

tap-agent clear #

Clear a field's text.

tap-agent clear [--timeout TIMEOUT] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--timeout TIMEOUTcommand budget, at most 120s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: clear(target, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent clear id=email
cleared id=email

tap-agent submit #

Run a focused field's keyboard action (Search, Go, Send, Done, …); API 30+.

tap-agent submit [--timeout TIMEOUT] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--timeout TIMEOUTcommand budget, at most 120s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: submit(target, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent submit id=search
submitted id=search

tap-agent action #

List a node's accessibility actions, or perform one as a screen reader does (no touch).

tap-agent action [--timeout TIMEOUT] [--custom] [--json] target [name]
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
namea standard action (expand, collapse, dismiss, scroll-forward, ...) or, with --custom, a label; optional
--timeout TIMEOUTcommand budget, at most 120s
--customNAME is a custom action's label (e.g. 'Archive')
--jsonlist: actions, custom_actions and range as JSON

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: accessibility_action(target, name, custom, as_json, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent action @e9
@e9 offers: expand, focus, 'Archive', 'Mark as read'
tap-agent action @e9 expand
performed expand on @e9
tap-agent action @e9 Archive --custom
performed 'Archive' on @e9
  • Click is not an action here: use tap. An action the node does not offer is refused before anything happens.

tap-agent progress #

Set a slider (SeekBar, Slider, RatingBar) to a value in its own units.

tap-agent progress [--timeout TIMEOUT] target value
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
value—
--timeout TIMEOUTcommand budget, at most 120s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: set_progress(target, value, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent progress id=volume 40
set progress 40 on id=volume

tap-agent keyboard #

Whether a soft keyboard shows, or hide it.

tap-agent keyboard [--json] [{hide}]
actionomit to read whether a soft keyboard shows; one of hide; optional
--jsonread: {"shown": bool}

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: keyboard(action, as_json, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent keyboard
keyboard shown
tap-agent keyboard hide
keyboard hidden
  • hide sends one Back key only when a keyboard shows, then waits up to 2 s for it to go.

Gestures

Gestures run on one node, sized relative to it, never at screen coordinates.

tap-agent scroll #

Scroll a node towards a content edge (down reveals content below).

tap-agent scroll [--timeout TIMEOUT] [--percent PERCENT] target
    {up,down,left,right}
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
directionthe content to reveal (down: what is below; the finger moves up); one of up, down, left, right
--timeout TIMEOUTcommand budget, at most 120s
--percent PERCENTdistance across the node, 1..100; default 80

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: scroll(target, direction, percent, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent scroll id=feed down
scrolled down (finger up) id=feed

tap-agent scroll-until #

Bounded SDK scroll until a descendant target exists.

tap-agent scroll-until [--direction {up,down,left,right}]
    [--max-scrolls MAX_SCROLLS] [--percent PERCENT] [--timeout TIMEOUT] target
    destination
targetscroll container: a ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
destinationdescendant to find: a ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--direction DIRECTIONone of up, down, left, right; default down
--max-scrolls MAX_SCROLLS1..1000; also bounded by the SDK deadline; default 20
--percent PERCENTscroll distance, 1..100; default 80
--timeout TIMEOUToverall SDK loop budget, at most 120s

MCP: scroll_until(target, destination, direction, max_scrolls, percent, timeout_seconds, device)

Example

tap-agent scroll-until id=feed text~=Receipt
found text~=Receipt inside id=feed

tap-agent swipe #

Swipe across a node, the finger moving towards --finger.

tap-agent swipe --finger {up,down,left,right} [--timeout TIMEOUT]
    [--percent PERCENT] target
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--finger FINGERwhere the finger moves (up reveals what is below); one of up, down, left, right
--timeout TIMEOUTcommand budget, at most 120s
--percent PERCENTdistance across the node, 1..100; default 80

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: swipe(target, finger, percent, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent swipe id=card --finger left
swiped finger left id=card

tap-agent fling #

Fling a node towards a content edge, as for scroll; content may keep moving.

tap-agent fling [--timeout TIMEOUT] target {up,down,left,right}
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
directionthe content to reveal (down: what is below; the finger moves up); one of up, down, left, right
--timeout TIMEOUTcommand budget, at most 120s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: fling(target, direction, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent fling id=feed down
flung down (finger up) id=feed

tap-agent drag #

Long-press a node, move it onto another node and drop it.

tap-agent drag [--timeout TIMEOUT] target destination
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
destinationwhere to drop it: a ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
--timeout TIMEOUTcommand budget, at most 120s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: drag(target, destination, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent drag text=Milk id=basket
dragged text=Milk onto id=basket

tap-agent pinch #

Pinch a node open (fingers apart, zoom in) or closed.

tap-agent pinch [--percent PERCENT] [--timeout TIMEOUT] target {open,close}
targeta ref (@e3), comma-joined selector terms, or a JSON selector (all/any, relations, flags, text modes)
howone of open, close
--percent PERCENThow far across the node, 1..100 (default 80)
--timeout TIMEOUTcommand budget, at most 120s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: pinch(target, how, percent, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent pinch id=map open --percent 60
pinched open 60% id=map

Keys, system panels and the display

Target the shade's and quick settings' nodes with pkg=com.android.systemui; key back closes them (twice from quick settings on newer Android). A rotation is kept until release, which restores the device's own setting.

tap-agent key #

Press a key: any Android key name (back, home, enter, volume-up, media-play-pause, …) or code:N.

tap-agent key [--list] [--long] [--duration DURATION] [--count COUNT]
    [--interval INTERVAL] [name]
namea key name (--list prints them all; 0 .. 9 are the digit keys) or code:N for an Android key code; optional
--listprint every key name with its code (no device needed)
--longhold each press for the device's long-press timeout (Android's long press)
--duration DURATIONhold each press this long, 1ms..30s, repeating as a held key does (implies --long)
--count COUNTpress this many times, 1..100; default 1
--interval INTERVALrelease-to-press gap for counted presses, 40ms..1s (default 100ms)

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: press_key(key, list_keys, long, duration, count, interval, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent key back
pressed back
tap-agent key volume-up --count 2
pressed volume-up x2
tap-agent key volume-down --duration 2s
long-pressed volume-down for 2s
tap-agent key power --long
long-pressed power
tap-agent key --list
soft-left  1
soft-right  2
home  3
back  4
…
  • As for tap: --long holds for the device's long-press time, --duration for a time you give (and implies --long); --count N repeats with --interval between presses.

tap-agent panel #

Open the notification shade or quick settings (key back closes it).

tap-agent panel {notifications,quick-settings}
nameone of notifications, quick-settings

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: open_panel(panel, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent panel notifications
opened notifications

tap-agent rotate #

Rotate the display and keep it there (auto: back to the sensor).

tap-agent rotate {portrait,landscape,natural,left,upside-down,right,auto}
howone of portrait, landscape, natural, left, upside-down, right, auto

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: rotate(how, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Example

tap-agent rotate landscape
rotated landscape: display landscape, left (2400x1080)

tap-agent screen #

Screen state, or turn it on/off, or wake it and dismiss a keyguard without a PIN.

tap-agent screen [--json] [{on,off,unlock}]
actionomit to read the screen and keyguard state; one of on, off, unlock; optional
--jsonread: screen_on, keyguard_locked, keyguard_secure

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: screen(action, as_json, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent screen
screen on, keyguard not showing
tap-agent screen unlock
screen on, keyguard not showing

Apps and permissions

app <action> <package> [argument] covers the app lifecycle. permission handles the runtime-permission dialog an app shows, whatever app shows it.

tap-agent app #

App lifecycle: launch, cold-launch, foreground, background, open-link, stop, clear, install, uninstall, grant, revoke, granted, running, locale, installed, process, visible (visible waits until the app owns the focused window).

tap-agent app [--any-app] [--json] [--timeout TIMEOUT]
    [--extra KEY[:TYPE]=VALUE]
    {launch,cold-launch,foreground,background,open-link,stop,clear,install,uninstall,grant,revoke,granted,running,locale,installed,process,visible}
    package [argument]
actionone of launch, cold-launch, foreground, background, open-link, stop, clear, install, uninstall, grant, revoke, granted, running, locale, installed, process, visible
packagethe app's package name, e.g. com.example.app
argumentactivity (launch), URI (open-link), APK path (install), permission (grant, revoke, granted) or languages (locale: fr-FR,en or system); optional
--any-appopen-link: let any app handle the link, not only this one
--jsonreads (granted, running, locale, installed, process): the value as JSON
--timeout TIMEOUTsupported lifecycle/visibility/process actions: at most 120s
--extra KEY[:TYPE]=VALUElaunch/cold-launch: an intent extra; TYPE is string (default), int, long, float or bool; repeat for more

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: app(action, package, argument, any_app, timeout_seconds, as_json, settle, extras, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent app cold-launch com.shop
cold-launched com.shop (pid 4242)
tap-agent app launch com.shop .ui.ItemActivity --extra item:long=42
launched com.shop
tap-agent app grant com.shop android.permission.CAMERA
granted android.permission.CAMERA to com.shop
tap-agent app running com.shop
com.shop is running

tap-agent permission #

List the permission dialog's buttons, or press one.

tap-agent permission [--timeout TIMEOUT] [--accuracy {precise,approximate}]
    [--json]
    [{allow,allow-foreground-only,allow-one-time,allow-always,allow-selected,allow-all,deny,deny-and-dont-ask-again,keep-foreground-only,keep-one-time}]
choicethe button to press (omit to list them); one of allow, allow-foreground-only, allow-one-time, allow-always, allow-selected, allow-all, deny, deny-and-dont-ask-again, keep-foreground-only, keep-one-time; optional
--timeout TIMEOUTdialog wait/action budget, at most 120s (default 10s)
--accuracy ACCURACYpick Precise or Approximate first (location dialog, Android 12+); one of precise, approximate
--jsonlist: package_name, choices and accuracies

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: permission(choice, timeout_seconds, accuracy, as_json, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent permission
permission dialog (com.android.permissioncontroller) offers: allow-foreground-only, allow-one-time, deny
tap-agent permission allow-one-time
pressed allow-one-time

Debuggable app data

app-data <action> <package> [path] [local] probes run-as, lists/reads/writes/deletes private files and exports/imports SQLite bundles (database plus WAL/journal, never SHM). Except the probe, stop the app explicitly first. No SQL, root, printed contents, implicit restart or restore on release. Read outputs are owner-only and new; database export needs a new directory. Use --overwrite explicitly for remote replacement. After interrupted import, repair/clear data before launch; do not retry blindly.

tap-agent app-data #

Debuggable-app private files and SQLite bundles; stop the app explicitly first.

tap-agent app-data [--overwrite]
    {capabilities,list,read,write,delete,export-db,import-db} package [path]
    [local]
actionone of capabilities, list, read, write, delete, export-db, import-db
packagethe debuggable app's package name
pathrelative private path, or database basename; list defaults to root; optional
localread/write: local file; export-db/import-db: local bundle directory; optional
--overwritewrite/import-db: explicitly replace existing remote data

MCP: app_data(action, package, path, local, overwrite, device)

Examples

tap-agent app-data list com.shop databases
file 20480 "shop.db"
file 8192 "shop.db-wal"
tap-agent app-data export-db com.shop shop.db ./shop-db
saved database bundle to ./shop-db (keep database and sidecars together)

Device conditions and location

Everything changed here is restored on release: animations, dark mode, font scale, density, the network switches, the languages and the accessibility display settings, and the mocked location.

tap-agent condition #

Device conditions (animations, dark mode, font scale, density, network switches, languages, stay awake, accessibility display): print or change until release.

tap-agent condition [--json]
    [{animations,dark-mode,font-scale,density,airplane-mode,wifi,mobile-data,locale,stay-awake,ime-with-hard-keyboard,high-contrast-text,color-inversion,bold-text}]
    [value]
nameomit to print all; one of animations, dark-mode, font-scale, density, airplane-mode, wifi, mobile-data, locale, stay-awake, ime-with-hard-keyboard, high-contrast-text, color-inversion, bold-text; optional
valueanimations/dark-mode/airplane-mode/wifi/mobile-data/stay-awake/ime-with-hard-keyboard/high-contrast-text/color-inversion/bold-text: on|off; font-scale: 0.5..2.0; density: dpi or reset; locale: comma-separated BCP-47 tags, e.g. fr-FR,en (omit to print); optional
--jsonread: an object keyed by name (switches as booleans)

MCP: condition(name, value, as_json, device)

Examples

tap-agent condition
animations on
dark-mode off
font-scale 1
density 420 dpi
airplane-mode off
wifi on
mobile-data on
locale en-US
stay-awake on
ime-with-hard-keyboard on
high-contrast-text off
color-inversion off
bold-text off
tap-agent condition locale --json
{
  "locale": [
    "en-US"
  ]
}
tap-agent condition dark-mode on
dark-mode on (restored on release)

tap-agent location #

Mock the device location until release.

tap-agent location [--accuracy ACCURACY] [--altitude ALTITUDE] latitude
    longitude
latitude-90..90
longitude-180..180
--accuracy ACCURACYin meters (default 5)
--altitude ALTITUDEin meters

MCP: set_location(latitude, longitude, accuracy_m, altitude_m, device)

Example

tap-agent location 52.37 4.89
location mocked at 52.37, 4.89 (ends on release)

Notifications, toasts and the clipboard

Notifications are read as data: the shade stays closed. Toasts are caught when shown in the last 3.5 s or while waiting.

tap-agent notification #

List the device's notifications, --wait for one, or open or dismiss one (read as data; the shade stays closed).

tap-agent notification [--wait] [--json] [--title TITLE] [--text TEXT]
    [--contains] [--package PACKAGE] [--button BUTTON] [--timeout TIMEOUT]
    [{open,dismiss}]
actionomit to list (or --wait); one of open, dismiss; optional
--waitwait until one matches and print it
--jsonlist/--wait: the SDK notifications as JSON
--title TITLEthe notification's title
--text TEXTthe notification's text
--containstitle/text are only part of it
--package PACKAGEonly this package's notifications
--button BUTTONopen: press the action button with this title instead
--timeout TIMEOUTcommand/wait budget, at most 120s; default 10s

Also takes the options every step takes: --settle, --events, --expect, --expect-death.

MCP: notification(action, wait, title, text, contains, package, button, as_json, timeout_seconds, settle, expect_death, events, expect_events, event_timeout_seconds, device)

Examples

tap-agent notification
com.shop: 'Order shipped' - 'Arrives Tuesday' [Track, Dismiss]
com.android.systemui: 'Virtual SD card' - 'For storing photos, videos, music and more' [Explore, Eject]
tap-agent notification open --title 'Order shipped' --button Track
pressed 'Track' on the notification

tap-agent toast #

Read retained toasts (oldest first, never consumes), or --wait for one.

tap-agent toast [--exact] [--package PACKAGE] [--wait] [--after CURSOR]
    [--json] [--timeout TIMEOUT] [text]
textpart of the toast's text, any case (omit for any toast); optional
--exacttext is the whole toast, case included
--package PACKAGEonly this package's toasts (default: any app's)
--waitwait for a matching toast (one shown in the last 3.5 s counts)
--after CURSORread: the toasts after the cursor a previous read printed after next:
--jsonread: structured observations and cursor metadata
--timeout TIMEOUTwith --wait only: at most 120s; default 10s

MCP: toast(text, exact, package, wait, after, as_json, timeout_seconds, device)

Examples

tap-agent toast
#1 1795275040120 toast 'Card saved' from 'com.shop'
next: --after 6793fef1-…:1
tap-agent toast saved --wait
toast 'Card saved' from com.shop

tap-agent clipboard #

Print the device clipboard, or set it.

tap-agent clipboard [--json] [text]
textput this on the clipboard (omit to print it); optional
--jsonread: the text as a JSON string

MCP: clipboard(text, as_json, device)

Examples

tap-agent clipboard SAVE20
clipboard set (6 characters)
tap-agent clipboard
SAVE20

Turning a session into a test

The server keeps every call, crash, ANR and device-log line after release; history shows them with this agent's own steps, page by page, as text or JSON on stdout. history keep start / history keep stop keep a named range past the server's retention; read it with history --kept NAME. See History and kept ranges.

tap-agent history #

What happened: calls, crashes, ANRs and (with --logs) device logs, with this agent's steps; or mark/redact held devices, or keep a named range past retention.

tap-agent history [-L] [-d SERIAL] [--kept NAME] [--from TIME]
    [--last DURATION] [--since-marker NAME] [--step STEP] [--last-action]
    [--after POSITION] [--until TIME] [--until-marker NAME] [--logs]
    [--package PACKAGES] [--priority PRIORITY] [--tag TAGS] [--grep REGEX]
    [--no-actions] [--driver-lines] [--details] [--limit N] [--json]
    [{read,mark,redact,keep}] [value] [name]
actionone of read, mark, redact, keep; optional; default read
valuemark NAME, redact REGEX, or keep start|stop|list|clean; optional
namekeep start/stop/clean: the kept range's name (or its id, as history keep list -L shows it); optional
-L, --longkeep list: state, id, connection, times and disk use
-d, --device SERIALonly these devices (repeatable); for mark/redact, these held devices
--kept NAMEonly a kept range (history keep start), also after its session ended
--from TIMEfrom this ISO time with a time zone, e.g. 2026-11-21T12:00:00Z
--last DURATIONeverything in the last DURATION, e.g. 30s or 5m
--since-marker NAMEfrom the newest marker NAME (history mark)
--step STEPone step, by the cursor or id history prints, with its device-log span
--last-actionfrom the start of the newest step
--after POSITIONthe next page: the position a previous history printed after next: or older:
--until TIMEup to this ISO time (excluded)
--until-marker NAMEthrough the newest marker NAME
--logsadd the device logs (any log filter below implies it)
--package PACKAGESonly this app's log lines (repeatable)
--priority PRIORITYlog lines at least this severe: verbose, debug, info, warn, error, fatal
--tag TAGSonly log lines with this tag (repeatable)
--grep REGEXonly log lines whose message matches (Java regex)
--no-actionsleave Tap's own action entries out of the logs
--driver-lineskeep the Tap driver's own logcat lines
--detailsshow crash and ANR stack traces
--limit Nat most N server entries per page, 1 to 5000 (default 200); a step's calls print as its one line
--jsonJSON (tap-history/2) instead of text, on stdout; keep list: the kept ranges

MCP: history(action, value, devices, kept, start, last, since_marker, step, last_action, after, until, until_marker, logs, packages, priority, tags, grep, actions, driver_lines, details, limit, as_json), history_keep(action, name, long, as_json)

Examples

tap-agent history --last 1m
2026-11-21T19:56:42.242Z  emulator-5554  step 93: fill res("email") me@example.com → succeeded
2026-11-21T19:56:51.096Z  emulator-5554  step 97: tap res("pay") settle → succeeded
2026-11-21T19:56:51.610Z  emulator-5554  CRASH com.shop (pid 23554): java.lang.IllegalStateException: Out of stock
2026-11-21T19:58:56.721Z  emulator-5554  step 98: wait res("receipt") → failed (WAIT_TIMEOUT)
tap-agent history mark checkout
mark emulator-5554 'checkout' at d01dda20-5b45-4b6e-847b-b51d15b486d5:3959
tap-agent history keep start checkout
keeping 'checkout' (devices attached later join it)
tap-agent history keep stop checkout
stopped keeping 'checkout'
tap-agent history --kept checkout
kept range checkout (stopped)
2026-11-21T19:56:42.242Z  emulator-5554  step 93: fill res("email") me@example.com → succeeded
…
  • A window that ends now (--last, --last-action) shows the newest page and ends with older: --after POSITION; --from, --since-marker and --step read forward.
  • Missing evidence is never silent: a GAP: line where capture stopped, or a WARNING: line.

Device events

Android reports toasts, window changes, clicks, scrolls, text edits and content changes as they happen. Supported verbs take --events KINDS to print events observed during the step and --expect KIND[:TEXT] to require one (see each verb's options; not scroll-until). Capture is finite and observations do not prove causality. watch KIND --until-first waits for the next one, and watch streams them (run it in the background to be told when something happens). Events are hints: read the screen again before acting on one.

tap-agent watch #

Print device events as they happen, one per line, until stopped (Ctrl-C), --for ends or the device is detached; or --until-first KIND.

tap-agent watch [--package PACKAGE] [--for DURATION] [--json]
    [--until-first KIND] [--text TEXT] [--timeout TIMEOUT] [KIND ...]
KINDevent kinds, each or comma lists: toast, window, content, click, scroll, text (none with --until-first)
--package PACKAGEonly this package's events (default: any app's)
--for DURATIONstop after this long (default: until stopped)
--jsonone JSON object per line
--until-first KINDwait for the first event of this kind from now on, print it and stop (exit 1 on --timeout); one of toast, window, content, click, scroll, text
--text TEXTwith --until-first: part of the event's text, any case: a toast's message, a window's title or class, a click's label, an edit's text
--timeout TIMEOUTwith --until-first: at most 120s; default 10s

MCP: watch(kinds, duration_seconds, package, until_first, text, timeout_seconds, device)

Examples

tap-agent watch toast window --for 10s
toast "Card saved" (com.shop)
window state com.shop.ReceiptActivity "Receipt" (com.shop)
tap-agent watch --until-first window --package com.shop --timeout 5s
window state com.shop.ReceiptActivity "Receipt" (com.shop)

Agent setup

Register the MCP server with your agent, or give it the CLI with the skill text.

tap-agent mcp #

Run the MCP server on stdio (same sessions as the CLI).

tap-agent mcp

No options of its own.

MCP: none, CLI only.

Example

tap-agent mcp
  • Serves MCP on stdin and stdout until the client disconnects. CLI and MCP share sessions and history.

tap-agent skill #

Print the agent skill (SKILL.md).

tap-agent skill

No options of its own.

MCP: none, CLI only.

Example

tap-agent skill
---
name: tap-agent
…