Skip to main content
View as Markdown

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​

ToolDescription
mobilenext_list_available_devicesList 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_devicesList the devices you have allocated, with the serial and session ID of each
mobilenext_allocate_deviceReserve 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_allocationKeep waiting for a device that mobilenext_allocate_device returned as allocating. Also reports failed or expired allocations
mobilenext_release_deviceRelease a device back to the fleet
mobilenext_get_accountShow 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.

ToolDescription
mobilenext_create_fileStart 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_fileFinish 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_fileGet one stored file: status, platform, bundle ID, version, build info and expiry
mobilenext_list_filesList stored files, newest first. Pass sha256 to check whether a build is already stored
mobilenext_update_fileRename a stored file or change when it expires
mobilenext_delete_fileDelete a stored file. Cannot be undone
mobilenext_get_file_download_urlGet a short-lived URL to download a stored file
mobilenext_list_stored_appsList the apps in app storage (one per platform and bundle ID), with their latest file
mobilenext_list_app_filesList the stored files (builds) of one app

Apps on the device​

ToolDescription
mobilenext_install_appInstall 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_uploadCreate 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_appUninstall an app and its data. Use it when an install fails with INSTALL_FAILED_UPDATE_INCOMPATIBLE
mobilenext_list_appsList the apps installed on the device
mobilenext_launch_appLaunch an app
mobilenext_terminate_appStop and terminate an app
mobilenext_get_foreground_appGet the app in the foreground, to tell whether the app under test is still open or crashed
mobilenext_list_crashesList the crash reports on the device
mobilenext_get_crashGet a crash report, including its stack trace
mobilenext_get_device_logsRead 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​

ToolDescription
mobilenext_list_elements_on_screenList 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_coordinatesTap an element by its ref, or at x,y coordinates
mobilenext_double_tap_on_screenDouble-tap an element by its ref, or at x,y coordinates
mobilenext_long_press_on_screen_at_coordinatesLong press an element by its ref, or at x,y coordinates
mobilenext_swipe_on_screenSwipe on the screen
mobilenext_type_keysType text into the focused element, keystroke by keystroke
mobilenext_fill_textReplace the focused text field's value in one call. Faster and more reliable than mobilenext_type_keys for forms
mobilenext_press_buttonPress 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_urlOpen a URL in the device's browser
mobilenext_get_screen_sizeGet the screen size in pixels
mobilenext_set_orientationChange the screen orientation
mobilenext_get_orientationGet the screen orientation
mobilenext_batch_commandsRun 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​

ToolDescription
mobilenext_take_screenshotTake a screenshot and show it to the agent. JPEG, at most 1024 pixels on its longest side unless told otherwise
mobilenext_save_screenshotTake a screenshot and return a temporary download URL. Pass persist: true to keep it in the session as an artifact
mobilenext_start_screen_recordingStart recording the screen
mobilenext_stop_screen_recordingStop an active screen recording
mobilenext_list_artifactsList the files kept in a session, newest first, with a link to the session's page
mobilenext_get_artifactGet 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:

  1. Compute the file's SHA-256 and size, and call mobilenext_create_file.
  2. If it returns an upload URL, PUT the bytes there with the returned headers, then call mobilenext_complete_file. If your organization already had the build, skip this step.
  3. Use the returned fileId.

Then install it:

  • Android: pass the fileId to mobilenext_allocate_device to start a device with the app, or to mobilenext_install_app on a device you already hold.
  • iOS: a running iPhone cannot take a new app. Pass the fileId to mobilenext_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 new fileId.

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.