# Setup commands

> Choose the workspace, project and app a repository works on, and give a coding agent the tools.

Source: https://rehearsal.dev/docs/reference/cli-setup

`rehearsal init` asks which workspace, project and app this repository works on. It skips a question that has one answer, and saves the choice in `rehearsal.config.json`. Other commands then find the workspace and project without `--workspace` and `--project`. Run `init` again to change the choice, and `rehearsal whoami` shows what is in use. The `mcp` commands give a coding agent the same sign-in and project through MCP. [Find and fix bugs with your coding agent](https://rehearsal.dev/docs/cli/coding-agents.md) shows how to set them up.

## rehearsal init

Choose the workspace, project and app this folder works on.

Asks which workspace, project and app, and saves them in `rehearsal.config.json`. A question with one answer is skipped. Run it again to change the choice. The file holds names and IDs, never a sign-in. It also offers to add a note for coding agents to `AGENTS.md`, or to `CLAUDE.md` when only that exists. The note tells them to check each change with Rehearsal.

```sh
rehearsal init [flags]
```

| Flag | Description |
| --- | --- |
| `--workspace <workspace>` | The workspace, by name or ID. |
| `--project <project>` | The project, by name, slug or ID. |
| `--app <app>` | The app, by name or ID. Left out in a script, no app is saved when there are several. |
| `--platform <platform>` | With `--app`, which kind of app: web, electron, ios or android. Needed only when two apps share a name. |
| `--suite <suite>` | The suite `rehearsal run` offers first, by name or ID. |
| `--agent-note <yes\|no>` | Whether to add the note for coding agents. The default is no. |
| `--yes` | Replace what `rehearsal.config.json` already holds without asking. A script needs it. |

Needs a saved sign-in.

```sh
# Choose for this folder
rehearsal init

# Choose from a script
rehearsal init --workspace <workspace-id> --project parcel --app <app-id> --yes --json

# Choose, and add the note for coding agents
rehearsal init --workspace <workspace-id> --project parcel --agent-note yes --yes
```

## rehearsal mcp setup

Print MCP configuration for Claude Code, Codex and Cursor.

Prints what to add to Claude Code, Codex or Cursor so it starts `rehearsal mcp`. Sign in and run `rehearsal init` first. You add the settings yourself; this command changes none.

```sh
rehearsal mcp setup
```

```sh
# Show the snippets
rehearsal mcp setup

# Read the snippets as JSON
rehearsal mcp setup --json
```

## rehearsal mcp

Give a coding agent Rehearsal's tools over MCP.

Starts an MCP server for a coding agent to run, on standard input and output. Stdout contains protocol messages only. The server uses the CLI's saved sign-in and this repository's workspace and project.

Its tools read projects, tests, runs and explorations, and start runs, explorations and crawls; the ones that start work can spend paid usage. A call waits at most 60 seconds, and `wait_run` 30 seconds unless it asks for up to 60. Cancelling a call stops the wait, never the work it started. Run `rehearsal mcp setup` for the settings Claude Code, Codex and Cursor need.

```sh
rehearsal mcp [flags]
```

| Flag | Description |
| --- | --- |
| `--workspace <id>` | The workspace a call uses when it names none, by ID. |
| `--project <project>` | The project a call uses when it names none, by slug or ID. |

Ctrl+C stops the server and the calls in progress. Runs and explorations they started keep going.

> [!NOTE]
> This command can start paid work. This command has no JSON output, and it stops with an error when you pass `--json`. MCP uses its own JSON-RPC stream. Start `rehearsal mcp` without `--json`.

```sh
# Start the MCP server
rehearsal mcp

# Choose the default project
rehearsal mcp --workspace <workspace-id> --project parcel
```
