Tools & Prompts
The mobilenext server exposes the tools below. Every device tool takes a device argument: the
serial (device.id) that mobilenext_allocate_device returns. There is no implicit "current
device", and the allocation id or session id is never the device.
Devices and sessions
| Tool | Description |
|---|---|
mobilenext_list_available_devices | List the devices you can allocate. Filter by platform. Devices that need an account upgrade are left out, and the response says how many were hidden |
mobilenext_list_allocated_devices | List the devices you have allocated, with the serial and session ID of each |
mobilenext_allocate_device | Reserve a device and wait for it to come online. Pass a stored app's fileId to start the device with that app installed. See How allocation works |
mobilenext_get_allocation | Keep waiting for a device that mobilenext_allocate_device returned as allocating. Also reports failed or expired allocations |
mobilenext_release_device | Release a device back to the fleet |
mobilenext_get_account | Show the signed-in user, the plan, and the device minutes left in the current billing period |
App storage
Store an .apk or .ipa once in your organization's app storage, then install it by
its fileId as often as you need.
| Tool | Description |
|---|---|
mobilenext_create_file | Start storing a build. Pass its SHA-256 and size; if your organization already has the same bytes, the existing file is returned and nothing is uploaded. Otherwise it returns a presigned PUT URL and headers |
mobilenext_complete_file | Finish a stored upload after the bytes were PUT. Verifies size and checksum, and reads the app's name, bundle ID, version and icon |
mobilenext_get_file | Get one stored file: status, platform, bundle ID, version, build info and expiry |
mobilenext_list_files | List stored files, newest first. Pass sha256 to check whether a build is already stored |
mobilenext_update_file | Rename a stored file or change when it expires |
mobilenext_delete_file | Delete a stored file. Cannot be undone |
mobilenext_get_file_download_url | Get a short-lived URL to download a stored file |
mobilenext_list_stored_apps | List the apps in app storage (one per platform and bundle ID), with their latest file |
mobilenext_list_app_files | List the stored files (builds) of one app |
Apps on the device
| Tool | Description |
|---|---|
mobilenext_install_app | Install an app on a running device. Pass exactly one of a stored fileId (preferred), an uploadId from mobilenext_create_upload, or a URL to a .apk/.ipa hosted at github.com/mobile-next. Android only; see Installing your own app for iOS |
mobilenext_create_upload | Create a one-off presigned upload URL. PUT the file to it, then pass the uploadId to mobilenext_install_app. Prefer app storage for builds you install more than once |
mobilenext_uninstall_app | Uninstall an app and its data. Use it when an install fails with INSTALL_FAILED_UPDATE_INCOMPATIBLE |
mobilenext_list_apps | List the apps installed on the device |
mobilenext_launch_app | Launch an app |
mobilenext_terminate_app | Stop and terminate an app |
mobilenext_get_foreground_app | Get the app in the foreground, to tell whether the app under test is still open or crashed |
mobilenext_list_crashes | List the crash reports on the device |
mobilenext_get_crash | Get a crash report, including its stack trace |
mobilenext_get_device_logs | Read the device's system log (logcat on Android, unified log on iOS). Take a cursor before an action and read from it afterwards to see what the action logged |
Reading and driving the screen
| Tool | Description |
|---|---|
mobilenext_list_elements_on_screen | List elements on screen, after waiting up to 2 seconds for it to stop changing. Each element has a ref (such as @e5), coordinates, and its text or accessibility label |
mobilenext_click_on_screen_at_coordinates | Tap an element by its ref, or at x,y coordinates |
mobilenext_double_tap_on_screen | Double-tap an element by its ref, or at x,y coordinates |
mobilenext_long_press_on_screen_at_coordinates | Long press an element by its ref, or at x,y coordinates |
mobilenext_swipe_on_screen | Swipe on the screen |
mobilenext_type_keys | Type text into the focused element, keystroke by keystroke |
mobilenext_fill_text | Replace the focused text field's value in one call. Faster and more reliable than mobilenext_type_keys for forms |
mobilenext_press_button | Press a device button. Android: HOME, BACK, ENTER, BACKSPACE, APP_SWITCH, POWER, VOLUME_UP, VOLUME_DOWN, and D-pad buttons. iOS: HOME, ENTER, LOCK, VOLUME_UP, VOLUME_DOWN |
mobilenext_open_url | Open a URL in the device's browser |
mobilenext_get_screen_size | Get the screen size in pixels |
mobilenext_set_orientation | Change the screen orientation |
mobilenext_get_orientation | Get the screen orientation |
mobilenext_batch_commands | Run several device tools in order in one call, such as tap, type, tap. Each step's result is returned in order |
Coordinates are native device pixels, the same space as element rects, not the scaled screenshot.
Taps, long presses, typing and swipes accept listElementsAfter: true or screenshotAfter: true
to return the next screen in the same call.
Screenshots, recordings and evidence
| Tool | Description |
|---|---|
mobilenext_take_screenshot | Take a screenshot and show it to the agent. JPEG, at most 1024 pixels on its longest side unless told otherwise |
mobilenext_save_screenshot | Take a screenshot and return a temporary download URL. Pass persist: true to keep it in the session as an artifact |
mobilenext_start_screen_recording | Start recording the screen |
mobilenext_stop_screen_recording | Stop an active screen recording |
mobilenext_list_artifacts | List the files kept in a session, newest first, with a link to the session's page |
mobilenext_get_artifact | Get a kept file's details and a temporary download link. The link lasts 15 minutes unless you choose another expiry |
Responses that concern a session include webUrl, the session's page in the
web app. It is a stable link for members of your organization, where
you can review kept screenshots and device logs after the run.
How allocation works
mobilenext_allocate_device waits up to 45 seconds for the device to come online and returns its
serial. Android is usually ready within that time; iOS takes 90 to 120 seconds. If the result is
still allocating, call mobilenext_get_allocation with its allocationId to keep waiting. Do not
allocate again and do not poll mobilenext_list_allocated_devices: a second allocate reserves a
second device.
Allocating a device creates a session (or joins the session ID you pass in). Keep the returned
session ID: mobilenext_release_device needs it, and the artifact tools take it.
If an allocation is refused, for example because the account is out of minutes or the device needs
a plan upgrade, the tool returns guidance for the agent instead of an error. Check the balance with
mobilenext_get_account.
Session duration
A device allocation can stay open for up to 120 minutes. Allocations still open after that are released automatically. This is a safety net for sessions that were never released (for example, an agent that crashed or disconnected), not a budget to plan around — release devices explicitly with mobilenext_release_device as soon as you're done.
Installing your own app
Store the build first:
- Compute the file's SHA-256 and size, and call
mobilenext_create_file. - If it returns an upload URL,
PUTthe bytes there with the returned headers, then callmobilenext_complete_file. If your organization already had the build, skip this step. - Use the returned
fileId.
Then install it:
- Android: pass the
fileIdtomobilenext_allocate_deviceto start a device with the app, or tomobilenext_install_appon a device you already hold. - iOS: a running iPhone cannot take a new app. Pass the
fileIdtomobilenext_allocate_device, which starts a new iPhone with the app installed. To test another build, release the device and allocate a new one with the newfileId.
A device allocated with a fileId launches the app once installed, unless you pass
launchAfterInstall: false. Otherwise open it with mobilenext_launch_app rather than through the
launcher.
For iOS, IPA files may be unsigned or ad hoc signed — Mobile Next re-signs them automatically before installation, so you don't need a device-provisioned signing profile. Simulator builds do not install on real devices. For Android, use an APK, not an App Bundle (.aab).
New personal accounts start with the Milliways demo app in app storage, so
mobilenext_list_stored_apps returns a build you can try without uploading anything. On Android,
mobilenext_install_app also accepts a direct URL to an .apk hosted at github.com/mobile-next.