# Flows API

> AI end-to-end tests in plain language, recorded and replayed with no model in CI, and a live browser to write them.

Source: https://bareci.com/docs/api/flows

AI end-to-end tests in plain language, recorded and replayed with no model in CI, and a live browser to write them.

Each tool below is an MCP tool on `https://api.bareci.com/mcp` and, unless it is marked local, a route of the `https://api.bareci.com/v1` JSON API. The `bareci` CLI calls the same routes.

| Tool | What it does |
| --- | --- |
| [`flows_run`](#flows_run) | Run the repository's Flows (AI end-to-end tests, `*.flow.ts`) on a BareCI machine against a base URL, usually the PR's preview. |
| [`browser_start`](#browser_start) | Open a real browser for writing a flow: answers with the page's accessibility tree. |
| [`browser_act`](#browser_act) | Do something on the live page: an `instruction` in plain language (kind do, or check to assert without acting), or one exact `action` ({type, target, value}). |
| [`browser_snapshot`](#browser_snapshot) | The live page's URL, title and accessibility tree, and a screenshot when asked. |
| [`browser_stop`](#browser_stop) | Close a live browser; answers with the model tokens it used. |
| [`browser_sessions`](#browser_sessions) | The live browsers open in this MCP server, with how long each has been idle. |

## `flows_run`

**Run flows.** Run the repository's Flows (AI end-to-end tests, `*.flow.ts`) on a BareCI machine against a base URL, usually the PR's preview. Strict replays recordings with no model call, as CI does; record re-records with the model. A run like run_create: upload the worktree, then read run_logs; the report and JUnit come back as artifacts.

- HTTP: `POST /v1/runs`
- Scope: `run`
- Changes state

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | Repository as owner/name, e.g. acme/web |
| `baseUrl` | string | yes | URL the flows open, e.g. the preview's |
| `mode` | `strict`, `auto`, `record` | no | strict (default, as CI), auto or record |
| `files` | string[] | no | Flow files; every *.flow.ts by default |
| `label` | string | no | Pool label, bareci-4 by default |
| `branch` | string | no | Branch the worktree is on |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `run` | object | no | The run |
| `upload` | object | no | Where to PUT the worktree |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "flows_run",
    "arguments": {
      "repo": "acme/web",
      "baseUrl": "<baseUrl>"
    }
  }
}
```

**Next:** PUT the worktree to upload.url, run_logs until done, then run_artifacts for report.json.

## `browser_start`

**Open a live browser.** Open a real browser for writing a flow: answers with the page's accessibility tree. Then browser_act in plain language or with exact actions; each answer gives the flow line that repeats it. Served by the local MCP server (`bareci mcp`), where the browser runs.

- Local only: served by `bareci mcp` on the machine with the browser, not by the hosted `/mcp`
- Scope: any token
- Changes state

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `baseUrl` | string | no | Base URL for relative paths, such as a preview URL |
| `url` | string | no | First page: a URL or a path under baseUrl |
| `headless` | boolean | no | Headless (default true) |
| `viewport` | object | no |  |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sessionId` | string | no | Session |
| `url` | string | no | URL |
| `title` | string | no | Title |
| `tree` | string | no | Accessibility tree |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "browser_start",
    "arguments": {}
  }
}
```

**Next:** browser_act with an instruction.

## `browser_act`

**Act in the browser.** Do something on the live page: an `instruction` in plain language (kind do, or check to assert without acting), or one exact `action` ({type, target, value}). Answers with the page after it, the actions taken, `flowLine` (paste into the flow) and `code` (Playwright lines).

- Local only: served by `bareci mcp` on the machine with the browser, not by the hosted `/mcp`
- Scope: any token
- Changes state

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `sessionId` | string | yes | From browser_start |
| `instruction` | string | no | A goal, e.g. 'add the blue mug to the cart' |
| `kind` | `do`, `check` | no | do (default) or check |
| `action` | object | no | One exact action {type, target?, value?} instead of an instruction |
| `screenshot` | boolean | no | Include a PNG screenshot |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `flowLine` | string | no | Flow line that repeats the step |
| `code` | string[] | no | Playwright lines |
| `tree` | string | no | Page after it |
| `actions` | any[] | no | Actions taken |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "browser_act",
    "arguments": {
      "sessionId": "<sessionId>"
    }
  }
}
```

**Next:** browser_act again, or browser_stop when the flow is written.

## `browser_snapshot`

**Look at the page.** The live page's URL, title and accessibility tree, and a screenshot when asked.

- Local only: served by `bareci mcp` on the machine with the browser, not by the hosted `/mcp`
- Scope: any token
- Reads only

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `sessionId` | string | yes | From browser_start |
| `screenshot` | boolean | no | Include a PNG screenshot |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | no | URL |
| `title` | string | no | Title |
| `tree` | string | no | Accessibility tree |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "browser_snapshot",
    "arguments": {
      "sessionId": "<sessionId>"
    }
  }
}
```

**Next:** browser_act.

## `browser_stop`

**Close the browser.** Close a live browser; answers with the model tokens it used.

- Local only: served by `bareci mcp` on the machine with the browser, not by the hosted `/mcp`
- Scope: any token
- Ends or removes something

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `sessionId` | string | yes | From browser_start |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `stopped` | boolean | no | True |
| `tokens` | object | no | Tokens used |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "browser_stop",
    "arguments": {
      "sessionId": "<sessionId>"
    }
  }
}
```

**Next:** record the flow: bareci-flows run --record.

## `browser_sessions`

**Live browsers.** The live browsers open in this MCP server, with how long each has been idle.

- Local only: served by `bareci mcp` on the machine with the browser, not by the hosted `/mcp`
- Scope: any token
- Reads only

No arguments.

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sessions` | any[] | no | [{sessionId, url, idleMs}] |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "browser_sessions",
    "arguments": {}
  }
}
```

**Next:** browser_stop the ones you are done with.
