# simulator_batch

> The MCP tool that runs a list of taps, waits, typing and other steps on the Team's Simulator in order, in one call.

Source: https://air.build/docs/mcp-tools/simulator_batch/

`simulator_batch` runs 1 to 1000 steps on the Team's running Simulator in order, in one call. Use it for a known flow, such as filling in a form and pressing Next. Every step that names an element reads the screen fresh. The whole list is checked before the first step runs, so a mistyped step fails the call without touching the device. While it runs, the batch stops at the first step that fails. The steps already done stay done. The failure is reported in the result (`ok: false`, `failedStep`), not as a tool error. Keep the waits and sleeps of one batch well under 30 seconds in total; split a longer flow into several calls, or the call can fail with a dropped connection.

| Read-only | Destructive | Idempotent |
| --- | --- | --- |
| No | No | No |

## Steps

Each step is an object with an `action` and only the fields of that action; any other field is refused. A `selector` is an object with the fields in [Selectors](https://air.build/docs/mcp-tools/simulator_find/#selector): `text`, `id`, `value`, `role`, `exact`, `strict`, `nodeId`. Points use [screen coordinates](https://air.build/docs/mcp-tools/simulator_screen/#coordinates).

| `action` | Fields | What it does |
| --- | --- | --- |
| `tap` | `selector`; `timeoutMs` (0 to 600000, default 10000); `duration` (0 to 60 seconds, optional) | Waits for the element and taps it, as [simulator_tap](https://air.build/docs/mcp-tools/simulator_tap/) with a selector |
| `find` | `selector` | Lists the matches, as [simulator_find](https://air.build/docs/mcp-tools/simulator_find/), without waiting |
| `wait-visible` | `selector`; `timeoutMs` (0 to 600000, default 10000) | Waits until the element is there and usable |
| `wait-hidden` | `selector`; `timeoutMs` (0 to 600000, default 10000) | Waits until no usable element matches |
| `slider` | `selector`; `percent` (0 to 100) | As [simulator_slider](https://air.build/docs/mcp-tools/simulator_slider/) |
| `adjust` | `selector`; `steps` (whole number, not 0) | As [simulator_adjust](https://air.build/docs/mcp-tools/simulator_adjust/); a partial adjustment fails the step |
| `drag` | `start` and `end` (each `x`, `y`); `duration` (0.05 to 60 seconds); `steps` (2 to 1000). All required | As [simulator_drag](https://air.build/docs/mcp-tools/simulator_drag/) |
| `input` | `event` | One input event, as in [simulator_input](https://air.build/docs/mcp-tools/simulator_input/) |
| `sleep` | `ms` (0 to 60000) | Pauses |

## Inputs

| Input | Type | Required | Default | What it does |
| --- | --- | --- | --- | --- |
| `teamId` | string (UUID) | Yes | — | The Team, from [list_teams](https://air.build/docs/mcp-tools/list_teams/) |
| `simulator` | string | No | The Team's default device | Which device, by `id` from [list_simulators](https://air.build/docs/mcp-tools/list_simulators/#result) |
| `steps` | list of 1 to 1000 objects | Yes | — | The [steps](https://air.build/docs/mcp-tools/simulator_batch/#steps), in order |

## Result

| Field | What |
| --- | --- |
| `ok` | `true` when every step succeeded |
| `results` | One entry per step that ran, in order |
| `results[].step` | The step's index, from 0 |
| `results[].ok` | Whether it succeeded |
| `results[].elapsedMs` | How long it took, in milliseconds |
| `results[].result` | What the step returned: for `tap` and `wait-visible`, the element, `point`, `exact`, `matchCount` and `excluded`, as in [simulator_tap](https://air.build/docs/mcp-tools/simulator_tap/#result); for `find`, `matches` and `excluded`; for `slider` and `adjust`, their tools' results; otherwise empty |
| `results[].error` | Why the step failed, when it failed with a message |
| `failedStep` | The index of the step that failed; only when `ok` is `false` |

```json
{
  "ok": false,
  "results": [
    { "step": 0, "ok": true, "elapsedMs": 412, "result": { "element": { "label": "Next", "identifier": "next", "role": "AXButton" }, "point": { "x": 201, "y": 780 }, "exact": true, "matchCount": 1, "excluded": [] } },
    { "step": 1, "ok": false, "elapsedMs": 10004, "error": "no usable element matching id=\"done\" within 10.0s" }
  ],
  "failedStep": 1
}
```

## Errors

These come back as tool errors, before any step runs:

| Message | When | What to do |
| --- | --- | --- |
| steps is a list of 1 to 1000 `{"action": …}` objects. | `steps` is missing, empty, too long, or has an entry without an `action` | Send 1 to 1000 step objects |
| Failed to deserialize the JSON body into the target type: _…_ | An unknown `action`, a missing or extra field, or a field of the wrong type | Fix the step the message names |
| selector needs `nodeId`, `text`, `id`, `value`, or `role` | A step's `selector` names nothing | Add a field |
| batch timeoutMs exceeds 600000 | A `timeoutMs` is over 600000 | Send at most 600000 |
| batch sleep exceeds 60000 ms | A `sleep` is over 60000 | Send at most 60000, or several sleeps |
| invalid tap duration | A `tap` `duration` is outside 0 to 60 | Send 0 to 60 |
| invalid slider percent | A `slider` `percent` is outside 0 to 100 | Send 0 to 100 |
| adjust steps must be nonzero | An `adjust` has `steps: 0` | Send a non-zero number |
| drag requires finite coordinates, duration 0.05..=60 seconds and steps 2..=1000 | A `drag` is out of range | Fix `duration` or `steps` |

Plus the errors every Simulator tool can return: see [start_simulator](https://air.build/docs/mcp-tools/start_simulator/#device-errors).

## Example

```json
{"name": "simulator_batch", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "steps": [
  {"action": "tap", "selector": {"id": "title-field"}},
  {"action": "input", "event": {"type": "type", "text": "Groceries"}},
  {"action": "tap", "selector": {"text": "Save", "exact": true}},
  {"action": "wait-hidden", "selector": {"id": "title-field"}, "timeoutMs": 5000}
]}}
```
