# MCP and CLI

> A reference card of the MCP tools, the CLI commands and their exit codes.

Source: https://docs.screwbugs.dev/screw-bugs/mcp-and-cli

Coding agents use the MCP server (`screw-bugs mcp`, over stdio); people and CI use the CLI. Both run the same operations.

## MCP tools

Five tools, four of which work today (screw-bugs `src/cli/mcp.ts`). Replies are 1–2 sentences plus file paths or URLs.

| Tool              | Needs                           | Optional                                                                     | What it does                                                                    |
| ----------------- | ------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `doctor`          | none                            | none                                                                         | Check this machine can run screw-bugs: Node, a browser, disk, updates           |
| `start_run`       | `url`, `summary`                | `cases`, `title`, `instructions`, `device`, `account`, `waitSeconds` (0–600) | Start a job in a headless browser; returns a job ID right away                  |
| `run_status`      | `jobId`                         | `waitSeconds` (0–60)                                                         | State and case results; an ended run gives its evidence, report and walkthrough |
| `submit_findings` | `jobId`, `findings`             | none                                                                         | Submit the agent's write-up of an ended run; the report is re-rendered          |
| `answer_question` | `jobId`, `questionId`, `answer` | none                                                                         | Answer a waiting run's question. (Not implemented)                 |

- Without `cases`, a job runs one "page loads" case. The case format: [Cases and steps](/screw-bugs/cases-and-steps.md).
- `run_status` waits at most 60 seconds per call: call it again until the run ends.
- Signing in a test account takes two `start_run` calls: see [Test accounts](/screw-bugs/cases-and-steps.md#test-accounts).

### Run states

`run_status` and `status` report one of: `queued`, `running`, `waiting_for_answer`, `finished`, `errored`. Each case is `passed`, `failed`, `blocked` (a step couldn't run) or `not_verified` (the run ended first).

## CLI commands

Run with `npx -y screw-bugs@latest <command>`. Commands that print a result accept `--json`.

| Command                                                 | What it does                                                                                            |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `setup [--agent <name>] [--url <url>] [--no-downloads]` | Set up this project: MCP config, `screw-bugs.json`, browser and ffmpeg downloads                        |
| `doctor`                                                | Check Node, browser, video, disk, Tailscale and updates                                                 |
| `init [--url <url>] [--force]`                          | Write `screw-bugs.json`                                                                                 |
| `run [--spec job.json] [--url <url>]`                   | Run cases and wait; exit 1 unless all passed. Also `--title`, `--instructions`, `--summary`, `--device` |
| `status <job-id>`                                       | State and case results of a run                                                                         |
| `findings <job-id> <file\|->`                           | Submit an agent's write-up of an ended run                                                              |
| `report <job-id> [--format markdown]`                   | Write the report, or print a PR summary                                                                 |
| `report <job-id> --serve [--port N]`                    | Serve the report at a local or tailnet URL                                                              |
| `walkthrough <job-id> [--serve]`                        | Write (or serve) the run's video walkthrough                                                            |
| `runs [--limit N]`                                      | List recent runs                                                                                        |
| `accounts`                                              | List test accounts                                                                                      |
| `accounts sign-in <label> --url <url> [--about <text>]` | Sign in to a test account in a live view                                                                |
| `accounts remove <label>`                               | Remove a test account and its saved session                                                             |
| `schema <job\|findings>`                                | Print the JSON Schema of a job or write-up                                                              |
| `mcp`                                                   | Serve the MCP server over stdio                                                                         |
| `analytics`                                             | Show whether analytics are on (off by default). `analytics on\|off` (Not implemented)      |
| `answer <job-id> <question-id> <answer>`                | Answer a question a waiting run asked. (Not implemented)                                   |
| `share <job-id>`                                        | Share a report through Cloud. (Not implemented)                                            |

> **Note: Sharing**
>
> There is no agent or CLI path to share. A person shares with the **Share** button in a report
>   opened over the report server; see [Share a report](/get-started/share-a-report.md).

## Exit codes

Stable, so CI scripts may branch on them (screw-bugs `src/cli/exit-codes.ts`).

| Code | Meaning                                                         |
| ---- | --------------------------------------------------------------- |
| 0    | OK                                                              |
| 1    | A case did not pass                                             |
| 2    | Bad arguments                                                   |
| 3    | `screw-bugs.json` missing or invalid                            |
| 4    | `doctor` found something missing (or no ffmpeg to record a run) |
| 5    | Not implemented yet                                             |
| 6    | Findings do not fit the run                                     |
| 7    | Upload files missing or unusable                                |
| 8    | `setup` left an agent's config alone                            |
| 9    | A test account needs a sign-in first                            |
| 70   | Internal error (please report it)                               |
| 130  | Stopped by Ctrl+C or SIGTERM                                    |

## Environment variables

| Variable                    | Effect                                                                                     |
| --------------------------- | ------------------------------------------------------------------------------------------ |
| `SCREW_BUGS_SERVE=0`        | No report server; replies give paths                                                       |
| `SCREW_BUGS_REPORT_HOST`    | Where the report server listens: `127.0.0.1`, `tailnet`, a MagicDNS name or a Tailscale IP |
| `SCREW_BUGS_SIGN_IN_HOST`   | The same, for the sign-in live view only                                                   |
| `SCREW_BUGS_CLOUD_URL`      | Where Cloud is (default `https://screwbugs.dev`)                                           |
| `SCREW_BUGS_UPDATE_CHECK=0` | No daily update check                                                                      |
| `SCREW_BUGS_ANALYTICS=1`    | Opt in to analytics (nothing is collected yet)                                             |

Full reference: the "CLI" section of the screw-bugs README.

**Next:** [Report sharing](/cloud/report-sharing.md)