<!-- https://qasignoff.com/docs/core-features/mcp-and-cli/ -->
# MCP & CLI

Headless entry points for the same execution engine behind Runner: **`npm run runner`** (`run` + `load`), **`npm run mock`**, and the **MCP server** for AI coding agents. No cloud relay — everything is local stdio/process.

Working directory examples assume the `qasignoff-backend` package.

---

### Collection runner (`npm run runner -- run`)

* **Platform Availability:** Full Parity (CLI)
* **Overview:** Execute a Signoff `*.signoff.json` or Postman v2.1 collection with environments, dotenv, data files, iterations, workers, retries, and reporters (`json`, `html`, `pdf`, `junit`, `csv`).
* **How It Works (Windows App):** Export or save collection/env files from the workspace, then run from PowerShell/terminal. UI Runner remains available for interactive plans.
* **How It Works (VS Code Extension):** Same CLI from the integrated terminal; optional UI Runner while developing.

![Runner execution plan and run options](/docs/assets/screenshots/app/runner-plan.webp)

* **Code / Configuration Examples:**

| Flag | Description | Default |
|------|-------------|---------|
| `-c, --collection <path>` | Collection file (Signoff or Postman v2.1) | **required** |
| `-e, --environment <path>` | Environment JSON (Signoff or Postman) | — |
| `--env-file <path>` | Dotenv file merged after environment JSON | — |
| `-d, --data <path>` | Data file (CSV/JSON) | — |
| `-o, --output <dir>` | Report output directory | `cwd` |
| `--reporters <formats>` | `json,html,pdf,junit,csv` (comma-separated) | `json` |
| `-i, --iteration <n>` | Iteration count | `1` |
| `--delay <ms>` | Delay between requests | `0` |
| `--retry <n>` | Retry count | `0` |
| `-w, --workers <n>` | Parallel workers (`1` = sequential) | `1` |
| `--timeout <ms>` | Per-request timeout | `30000` |
| `--bail` | Stop on first failure | `false` |
| `-v, --verbose` | Verbose logging | `false` |
| `--var <pair...>` | `key=value` overrides (highest precedence) | — |
| `--folder <nameOrId>` | Run a single folder | — |
| `--request <nameOrId...>` | Run one or more requests | — |

```bash
npm run runner -- run \
  -c ./signoff-studio-starter.signoff.json \
  -e ./signoff-studio-starter.httpbingo.signoff.env.json \
  --reporters json,html,junit \
  -o ./reports \
  --bail -v
```

Exit codes: **0** ok · **1** failures (including assertions) · **2** usage/load/validation.

* **Edge Cases, Troubleshooting & Pro-Tips:**
  - PDF needs Chrome or Edge (if one writes no PDF, the next installed browser is tried) or `SIGNOFF_CHROME_PATH` (otherwise prefer `html`).
  - `--var` wins over env JSON and dotenv — use for CI secrets injection.
  - Scope with `--folder` / `--request` for fast PR checks.

---

### Load testing (`npm run runner -- load`)

* **Platform Availability:** Full Parity (CLI)
* **Overview:** Process-local VU sessions with ramp, think time, and optional p95 / error-rate gates. See [Load testing](/docs/core-features/load-testing/) for UI parity.
* **How It Works (Windows App):** Use Load panel or CLI; CLI preferred for automation.
* **How It Works (VS Code Extension):** Same.

![Load panel with virtual users, duration and limits](/docs/assets/screenshots/app/runner-load.webp)

* **Code / Configuration Examples:**

| Flag | Description | Default |
|------|-------------|---------|
| `-c, --collection <path>` | Collection file | **required** |
| `-e, --environment <path>` | Environment JSON | — |
| `--env-file <path>` | Dotenv merged after env JSON | — |
| `-o, --output <dir>` | Load JSON report directory | `cwd` |
| `--vus <n>` | Virtual users | `10` |
| `--users <n>` | Alias for `--vus` | — |
| `--duration <ms>` | Steady-state duration | `30000` |
| `--duration-ms <ms>` | Alias for `--duration` | — |
| `--ramp-up <ms>` | Ramp 0→N | `0` |
| `--ramp-down <ms>` | Drain after duration | `0` |
| `--think-time <ms>` | Pause between iterations per VU | `0` |
| `--p95 <ms>` | Fail if p95 exceeds | — |
| `--error-rate <rate>` | Fail if error rate exceeds (0–1) | — |
| `--max-vus <n>` | Soft VU cap (hard 200) | `50` |
| `-v, --verbose` | Verbose progress | `false` |
| `--var <pair...>` | `key=value` overrides | — |
| `--folder <nameOrId>` | Load one folder | — |
| `--request <nameOrId...>` | Load specific requests | — |

```bash
npm run runner -- load -c ./Pets.signoff.json --vus 20 --duration 60000 --p95 500 --error-rate 0.01 -v
```

Exit codes: **0** thresholds pass · **1** fail · **2** usage.

* **Edge Cases, Troubleshooting & Pro-Tips:**
  - Not distributed — one process, one machine.
  - Soft-capped by `--max-vus` (default 50).

---

### Mock server (`npm run mock`)

* **Platform Availability:** Full Parity (CLI)
* **Overview:** Serve a local mock from workspace collection, collection file, or OpenAPI/Swagger. Details in [Mocks & OpenAPI](/docs/core-features/mocks-openapi/).
* **How It Works (Windows App):** CLI or UI mock actions.
* **How It Works (VS Code Extension):** CLI from terminal; UI mock from tree.

![Import window on the Collections tab](/docs/assets/screenshots/app/import-collections.webp)

* **Code / Configuration Examples:**

| Flag | Description | Default |
|------|-------------|---------|
| `-w, --workspace <path>` | Absolute Signoff workspace folder | — |
| `-c, --collection <id\|name\|file>` | Collection id/name or file | — |
| `--folder <id\|name>` | Folder when using a workspace | — |
| `-o, --openapi <path>` | OpenAPI/Swagger JSON or YAML | — |
| `-p, --port <n>` | Port (`0` = ephemeral) | `0` |
| `--quiet` | Less request logging | `false` |

```bash
npm run mock -- --openapi ./petstore.yaml --port 0
npm run mock -- -w C:/abs/workspace -c Pets --folder smoke
```

* **Edge Cases, Troubleshooting & Pro-Tips:**
  - Require workspace+collection, collection file, or `--openapi`.
  - Absolute workspace paths only; `..` rejected.

---

### MCP server for AI coding agents

* **Platform Availability:** Full Parity. The Windows app, the VS Code extension and the npm package all ship the same local stdio server.
* **Overview:** Lets Claude Code, Cursor, VS Code Copilot agent mode and Gemini CLI call your APIs with checks (`http_request`), query databases read-only (`db_query`, `db_assert`), verify an API call and its database effect in one step (`verify_api_effect`), and save those checks into the workspace (`save_request`, `save_db_check`). 19 tools, secrets redacted by value, read-only SQL enforced by the driver.
* **How It Works (Windows App):** **Help → Connect AI agents…** registers the server with each agent, or adds it to a project folder (previewed, merge-only). The app runs the server itself (`QaSignOff.exe --mcp-stdio`), so no Node is needed.
* **How It Works (VS Code Extension):** The extension registers the server with Copilot agent mode automatically (VS Code 1.101+). **SignOff Studio: Connect AI Agents** sets up the other agents.

![Connect AI agents window with setup options for four agents](/docs/assets/screenshots/app/connect-ai-agents.webp)

**Connect AI agents** also has an **Activity** tab. It lists the tool, target, outcome and time, but never request bodies, SQL or secrets.

* **Database access:** agents can always read through a read-only transaction. Writes need **Allow AI agent writes** on the connection, are tested first by default (dry run), and are never allowed in production.
* **Shared environments:** MCP server 26.8.46 and later asks for confirmation before sending POST, PUT, PATCH or DELETE requests to staging, pre-production or production. Use `http.protectedHosts` in `.signoff/agent-policy.json` to protect more hosts.
* **Saved checks:** when an agent saves requests, environments or checks, SignOff Studio shows what changed. Click **Reload workspace** to load them. Your unsaved edits are saved first.
* **Feedback:** agents can send short product feedback with `send_feedback`. Reports with URLs, hostnames, emails, tokens, SQL, code, file paths or workspace secrets are refused. To turn it off, use **Preferences → Let agents suggest improvements** or set `SIGNOFF_AGENT_FEEDBACK=0`.
* **Usage data:** the server sends anonymous usage counts, but never URLs, SQL, data or names. To turn this off, set `SIGNOFF_TELEMETRY=0` or `DO_NOT_TRACK=1`, or turn off **Help improve Signoff Studio**.

To set it up from a terminal (Node 22 or later):

```bash
npx -y @signoff-studio/mcp init
```

**Full guide** (per-agent setup, every tool, safety and privacy): [testapilocally.com/mcp](https://testapilocally.com/mcp/).

* **Edge Cases, Troubleshooting & Pro-Tips:**
  - The server finds the workspace from the agent's open folder; `--workspace <dir>` overrides it.
  - Database passwords kept only in the vault are provided by the running app while the vault is unlocked; otherwise set the connection's password env key in the workspace `.env`.
  - Point requests at `npm run mock` for fully local agent loops.

---

### Workspace normalize (related CLI)

* **Platform Availability:** Full Parity (CLI utility in backend package)
* **Overview:** `workspace:normalize` (package script) repairs/normalizes on-disk workspace layout for Git-friendly collections. Use when migrating legacy state or after manual file edits.

```bash
npm run workspace:normalize -- --workspace C:/absolute/path/to/workspace
```

* **Edge Cases, Troubleshooting & Pro-Tips:** Commit after normalize so teammates share the same layout.

---

## Related

- [Runner](/docs/core-features/runner/)
- [Load testing](/docs/core-features/load-testing/)
- [Mocks & OpenAPI](/docs/core-features/mocks-openapi/)
- [AI assist](/docs/core-features/ai-assist/)
