# Pairing

One port and one token, pasted into the settings page once per Chrome profile.

## 1. Get a pairing

Ask the agent to run the `pair` tool, or do it yourself:

```bash
npx @page-scanner/mcp pair
```

It prints a port and a token and saves them to `~/.page-scanner/config.json`.

## 2. Paste it into Chrome

Open the Page Scanner settings page: the gear in the editor toolbar, or `chrome://extensions`,
then Details, then Extension options. Under **Local agents**:

- give the browser a name, so an agent can tell your profiles apart ("work", "personal"),
- paste the port and the token,
- press **Connect**.

Chrome runs a separate copy of the extension in every profile, so repeat that for each profile
you want reachable. They share the port and token and identify themselves by name.

## Checking and rotating

`page-scanner-mcp status` says whether a pairing exists and whether anything is connected.
`pair --rotate` issues a new token and invalidates the old one, which means re-pairing every
browser.

## A refused handshake says why

A token that does not match, or an extension and a server that disagree about the protocol
version, comes back as a message the settings page shows rather than a bare failure. The
extension then retries slowly rather than once a second: neither cause fixes itself.

## The pair tool puts a token in the transcript

The `pair` tool returns the token to the agent, so it lands in the conversation, and a transcript
is not a place for secrets. It exists because being told to install a second program before
anything works is a bad first five minutes. If that trade-off is wrong for you, run
`npx @page-scanner/mcp pair` in a terminal and paste the token into Chrome yourself; the agent
never needs to see it.
