# Set up Review Router from an AI coding session

Review Router can create a GitHub-to-Slack routing plan from a GitHub Action, MCP client, CLI, or direct API call. The agent returns one short-lived browser link. A Tenpace team admin opens the exact repository, Slack workspace, channel, routing preset, and mention policy, then signs in to continue. Sign-in claims and locks that exact plan; there is no separate approval step.

The agent never receives GitHub App credentials, Slack OAuth tokens, or the user's Tenpace session.

## Fastest path: GitHub Action

Add this workflow to the repository that you want to route:

```yaml
name: Set up Review Router

on:
  workflow_dispatch:

permissions:
  contents: read
  id-token: write

jobs:
  setup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: Patrax/review-router-setup@v1
        with:
          slack-channel: pull-requests
          preset: repo-watch
          reviewer-mentions: all
```

The Action verifies the repository with GitHub Actions OIDC, creates an inert setup session, masks the setup token, and writes the human authorization link to the job summary. Because summaries and logs are public in public repositories, this Action link contains no claim secret: Tenpace binds it to the GitHub actor ID in the signed OIDC token. That same GitHub user must open the link and be a Tenpace team admin. OIDC proves where and for whom the workflow ran; it does not authorize GitHub or Slack changes.

## Optional config as code

Commit `.tenpace/review-router.yml`:

```yaml
version: 1
route:
  slack-channel: pull-requests
  preset: repo-watch
  reviewer-mentions: all
```

Action inputs override values from the file. Supported presets are `repo-watch`, `full-coverage`, and `team-activity`. Reviewer mentions can be `all`, `connected-only`, or `none`.

## Direct REST API

Create a rate-limited, inert session from any agent:

```bash
curl --request POST https://api.tenpace.com/v1/review-router/setup-sessions \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: your-stable-request-key' \
  --data '{
    "source": "cli",
    "intent": {
      "repository": "OWNER/REPOSITORY",
      "slackChannel": "pull-requests",
      "preset": "repo_watch",
      "reviewerMentions": "all"
    }
  }'
```

The creation response contains:

- `setupUrl`: give this link to the human admin. For direct API, CLI, and MCP creation, its claim secret is in the URL fragment, so it is not sent in HTTP requests or normal server logs. GitHub Action links have no claim secret and are bound to the OIDC workflow actor instead.
- `agentToken`: store it as a secret. Use `Authorization: Bearer rr_setup_...` to get status, update the proposal before a human claims it, apply the locked intent, send the verification test, or cancel.
- `id`: the public setup-session ID.

Poll status:

```bash
curl https://api.tenpace.com/v1/review-router/setup-sessions/SETUP_ID \
  --header 'Authorization: Bearer AGENT_TOKEN'
```

Each response includes a structured `status`, `plan`, and `humanAction`. When status becomes `ready_to_apply`, call `POST /v1/review-router/setup-sessions/{id}/apply`. When it becomes `test_pending`, call `POST /v1/review-router/setup-sessions/{id}/test`. Both operations are idempotent.

## Authorization boundary

1. A machine creates a proposed intent. It has no provider authority.
2. A signed-in Tenpace team or organization admin claims the browser link. GitHub Action links additionally require the GitHub account that started the workflow. Claiming atomically locks the current intent version.
3. After claim, the machine token cannot edit the plan. An authenticated admin can edit it; that same save creates and locks the new version in one action.
4. GitHub and Slack OAuth stay in the human's browser. Provider tokens are encrypted server-side and never appear in setup responses. If the requested public Slack channel does not exist and the app has `channels:manage`, apply creates it idempotently. Private channels still require a human to invite @Review Router.
5. Tenpace reconciles the route idempotently, then posts one real Slack message through the production delivery path.

Setup links expire after one hour before claim and seven days after claim. Completed routes remain active; expiration applies to setup authority, not to the configured route.

## MCP

Connect an MCP client to `https://api.tenpace.com/mcp`. Available tools:

- `start_review_router_setup`
- `get_review_router_setup_status`
- `preview_review_router_setup`
- `apply_review_router_setup`
- `send_review_router_test`

The MCP facade uses the same REST domain service and authorization boundary. It does not have a separate privileged path.

## Machine-readable discovery

- OpenAPI 3.1: https://api.tenpace.com/openapi.json
- Agent descriptor: https://api.tenpace.com/.well-known/tenpace-agent.json
- MCP Registry metadata: https://github.com/Patrax/review-router-setup/blob/main/server.json
- Concise LLM index: https://review-router.tenpace.com/llms.txt
- Full LLM context: https://review-router.tenpace.com/llms-full.txt
- Raw guide: https://review-router.tenpace.com/docs/agent-setup.md
- GitHub Action and repository instructions: https://github.com/Patrax/review-router-setup

These files improve retrieval and make the integration legible to coding agents, but no single discovery convention guarantees that every LLM will load them. Conventional README, AGENTS.md, OpenAPI, GitHub Action metadata, linked HTML documentation, and examples are all published together for redundancy.
