android

v1.2.1
io.github.martingeidobler/android Checked 2 days ago Published 8 months ago

Control Android devices and emulators via ADB — screenshots, UI automation, and logcat.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_devices

List connected Android devices and emulators

list_avds

List available Android Virtual Devices

start_emulator

Start an Android emulator. Waits up to 60s for it to come online.

ParameterTypeDescription
avd_name *stringName of the AVD to start (from list_avds)

screenshot

Take a screenshot of the Android device. Returns the image for visual analysis. Optionally saves to a file path.

ParameterTypeDescription
device_idstringDevice ID (optional if only one device)
save_pathstringLocal file path to save the screenshot PNG (optional)

get_ui_tree

Get the UI element hierarchy of the current screen. Returns interactive elements with their bounds, text, resource IDs, and state. Use this to find elements before tapping.

ParameterTypeDescription
device_idstringDevice ID (optional if only one device)

tap

Tap at specific screen coordinates

ParameterTypeDescription
x *numberX coordinate
y *numberY coordinate
device_idstringDevice ID (optional if only one device)

tap_element

Tap a UI element by its resource-id, text, or content-desc. Finds the element in the UI tree and taps its center.

ParameterTypeDescription
by *stringHow to find the element
value *stringValue to match
device_idstringDevice ID (optional if only one device)

tap_and_wait

Tap element then wait for UI to settle and return the new UI tree. Combines tap + wait + get_ui_tree into a single fast operation.

ParameterTypeDescription
by *stringHow to find the element to tap
value *stringValue to match
device_idstringDevice ID (optional if only one device)
wait_msnumberTime to wait for UI to settle after tap (default 1000ms)

type_text

Type text into the currently focused input field

ParameterTypeDescription
text *stringText to type
device_idstringDevice ID (optional if only one device)

press_key

Press a hardware/software key

ParameterTypeDescription
key *stringKey to press
device_idstringDevice ID (optional if only one device)

swipe

Perform a swipe gesture on the screen

ParameterTypeDescription
end_x *numberEnd X coordinate
end_y *numberEnd Y coordinate
start_x *numberStart X coordinate
start_y *numberStart Y coordinate
device_idstringDevice ID (optional if only one device)
duration_msnumberSwipe duration in ms (default 300)

scroll_to_element

Scroll down repeatedly until an element matching the given criteria is visible

ParameterTypeDescription
by *stringHow to find the element
value *stringValue to match
device_idstringDevice ID (optional if only one device)
max_scrollsnumberMaximum scroll attempts (default 10)

wait_for_element

Wait for a UI element to appear on screen. Polls every 500ms.

ParameterTypeDescription
by *stringHow to find the element
value *stringValue to match
device_idstringDevice ID (optional if only one device)
timeout_msnumberTimeout in ms (default 10000)

launch_app

Launch an Android app by package name

ParameterTypeDescription
package_name *stringApp package name (e.g., com.android.settings)
activitystringActivity to launch (optional - launches default if omitted)
device_idstringDevice ID (optional if only one device)

install_apk

Install an APK file on the device

ParameterTypeDescription
apk_path *stringLocal path to the APK file
device_idstringDevice ID (optional if only one device)

get_current_activity

Get the currently displayed app and activity

ParameterTypeDescription
device_idstringDevice ID (optional if only one device)

adb_shell

Run an arbitrary ADB shell command

ParameterTypeDescription
command *stringShell command to execute on the device
device_idstringDevice ID (optional if only one device)

get_logs

Get device logcat output. Use to find crashes, exceptions, and errors after reproducing a bug.

ParameterTypeDescription
device_idstringDevice ID (optional if only one device)
levelstringMinimum log level: V(erbose), D(ebug), I(nfo), W(arn), E(rror), F(atal)
linesnumberNumber of recent log lines to return (default 200)
package_namestringFilter logs by app package name (e.g., com.example.app)
sincestringShow logs since timestamp (e.g., '2024-01-15 10:30:00.000')

clear_logs

Clear the logcat buffer. Call this before reproducing a bug to get clean logs.

ParameterTypeDescription
device_idstringDevice ID (optional if only one device)

get_device_info

Get device details: model, manufacturer, Android version, API level, screen size, and DPI.

ParameterTypeDescription
device_idstringDevice ID (optional if only one device)

pull_file

Pull a file from the Android device to the local filesystem.

ParameterTypeDescription
local_path *stringLocal path to save the file to
remote_path *stringPath on the device (e.g., /sdcard/somefile.txt)
device_idstringDevice ID (optional if only one device)