# Connect your agents

URL: https://swb.one/docs/connect

## Add SwB to an agent [#add-swb-to-an-agent]

For an app on the SwB computer, choose [owner access or pairing](/docs/setup/mcp-client). For an app that runs on a server, add SwB as a remote MCP server. Use your public MCP address, for example `https://swb.example.com/mcp`. Approve the app's [OAuth sign-in](/docs/owner-login#agent-sign-in) on the SwB page.

| App | Where to add SwB |
| - | - |
| [Local MCP client](/docs/setup/mcp-client) | Use an owner key or pair with a code. Use `http://localhost:8870/mcp` on the SwB computer. |
| Claude and Claude Projects | Customize → Connectors → Add → Add custom connector |
| ChatGPT | [chatgpt.com/plugins](https://chatgpt.com/plugins) → Add a custom MCP server |
| Grok | [grok.com](https://grok.com) → Connectors → New Connector → Custom |
| Capy | Settings → MCP & plugins → Add a custom MCP server |
| Claude Code | `claude mcp add --transport http --scope user swb https://swb.example.com/mcp` |
| Codex, Gemini CLI and other coding agents | `swb connect coding-agent --choose agent=codex` |

For a coding agent, run `swb connect coding-agent` to list the supported names. Replace `codex` with the name from that list.

## Ask your agent [#ask-your-agent]

An agent with owner access can set up the other connections. With a paired key, the agent gives you a terminal command for each owner-only step.

Owner access needs an owner-approved OAuth sign-in or a key from `SWB_KEY_<NAME>`. Use a credential with full access to scopes, tools and targets. The settings `auth.key_scopes`, `auth.key_tools` and `auth.key_targets` limit this access.

| Ask | The agent does |
| - | - |
| How do I connect my Claude Projects? | It registers a Claude routine for the project and gives you one link for the token |
| Connect Slack to SwB. | It points you to the YAML manifest in [Slack setup](/docs/setup/slack#app-manifests) and gets a claim link when needed |
| Connect my Discord bot. | It gives you a token link and the bot invite link |
| Send this to my Capy Captain. | It sends the task and waits for the answer |
| What can you send to? | It lists the targets the agent can reach |

The agent calls the `connect` tool. SwB answers with the next step for that platform. When a step needs a token, SwB gives a one-time claim link. Open the link and paste the token there. [Credentials](/docs/credentials) explains claim links.

## Connect from the terminal [#connect-from-the-terminal]

Run `swb connect PLATFORM` in the SwB instance folder. Replace `PLATFORM` with the platform name, such as `slack`. The command uses the owner key from `.env`. It uses the local SwB address by default. Use `--dir` to select an instance folder. Use `--url` to set the SwB address. Run `swb login-link` for a one-time owner sign-in link.

```bash
swb connect mcp-client
swb connect capy-captain
swb connect grok
```

## Connect with a pairing code [#connect-with-a-pairing-code]

Pairing gives a new agent its own key. Ask an agent signed in as the owner to call `connect_code`. Give it the name of the new agent. The code works one time for ten minutes. The new agent uses `POST /connect` to exchange the code for its own key. See [MCP client](/docs/setup/mcp-client) for the full pairing procedure.

To make a code in the console, open **Tokens**. Open **Pairing code**. Enter the agent name. Select **Create code**. SwB sends the form to `POST /pairing/code`.

Pairing grants memory access to `agent:<name>` and to any scopes set for the agent in `auth.key_scopes`. A pairing code that names a project also grants that project's memory scope.

`POST /connect` returns the named project in `project`. Use it as the client's default project. Pass it in `project` when a tool needs the project.

The key can read messages its agent sends or receives within its [conversation scopes](/docs/security#keys-with-limits).

With a paired key, `tools/list` shows the tools for the paired agent role. The `auth.key_tools` setting can narrow the list. Use the owner's sign-in for owner tools. See [Paired keys](/docs/tools#paired-keys).

## Inbox event stream [#inbox-event-stream]

`POST /connect` returns `inbox_events_url`, the URL for `GET /inbox/events`. Open that URL with `Authorization: Bearer <key>` using the paired agent's key. SwB sends that agent's inbox messages within the key's access. These server-sent events (SSE) arrive while the connection stays open. Read Watch digests and context items with `inbox` instead.

The stream starts with a `ready` event. Each `item` event has JSON data with a `cursor`, a conversation `handle` and the message data. The event ID is the cursor, which marks a position in the stream.

The stream starts at the latest position by default. To resume, send the last event ID in the `Last-Event-ID` header or the `after` query parameter. See [Messages](/docs/tools#messages) for the inputs to `reply` and `get_message`.

## Setup prompts [#setup-prompts]

Agents can read setup text as an MCP prompt or resource. A prompt is text to give the agent. A resource is text the agent can read at an address. The `connect` tool gives both names in `guide` when a platform has a setup prompt.

| Prompt | Resource | Guide |
| - | - | - |
| `setup-capy-captain` | `swb://setup/capy-captain` | [/docs/setup/capy-captain](/docs/setup/capy-captain) |
| `setup-chatgpt` | `swb://setup/chatgpt` | [/docs/setup/chatgpt](/docs/setup/chatgpt) |
| `setup-claude` | `swb://setup/claude` | [/docs/setup/claude](/docs/setup/claude) |
| `setup-claude-project` | `swb://setup/claude-project` | [/docs/setup/claude-project](/docs/setup/claude-project) |
| `setup-coding-agent` | `swb://setup/coding-agent` | [/docs/setup/coding-agent](/docs/setup/coding-agent) |
| `setup-companion` | `swb://setup/companion` | [/docs/companion](/docs/companion) |
| `setup-coordinator` | `swb://setup/coordinator` | [/docs/connect](/docs/connect) |
| `setup-deploy` | `swb://setup/deploy` | [/docs/deploy](/docs/deploy) |
| `setup-discord` | `swb://setup/discord` | [/docs/setup/discord](/docs/setup/discord) |
| `setup-dots` | `swb://setup/dots` | [/docs/setup/dots](/docs/setup/dots) |
| `setup-github` | `swb://setup/github` | [/docs/setup/github](/docs/setup/github) |
| `setup-grok` | `swb://setup/grok` | [/docs/setup/grok](/docs/setup/grok) |
| `setup-grok-bot` | `swb://setup/grok-bot` | [/docs/setup/grok-bot](/docs/setup/grok-bot) |
| `setup-mcp-client` | `swb://setup/mcp-client` | [/docs/setup/mcp-client](/docs/setup/mcp-client) |
| `setup-muse` | `swb://setup/muse` | [/docs/setup/muse](/docs/setup/muse) |
| `setup-slack` | `swb://setup/slack` | [/docs/setup/slack](/docs/setup/slack) |
| `setup-telegram` | `swb://setup/telegram` | [/docs/setup/telegram](/docs/setup/telegram) |

## Companion [#companion]

Use the [Companion guide](/docs/companion) to pair a device and choose the features your agents can use.
