# Capy Captain

URL: https://swb.one/docs/setup/capy-captain

A Capy Captain is a Capy agent that directs a group of threads. SwB sends tasks to the Captain and returns each reply to the sender.

## Before you start [#before-you-start]

You need a Capy account, a project and a Captain in the same organization. A service user is a Capy account for software.

Enable the `capy` block. In Capy, add SwB under **Settings** → **MCP & plugins**. Use a SwB client with full owner access.

## Copy the setup prompt [#copy-the-setup-prompt]

https://swb.one/prompts/capy-captain.md

```
Read the setup guide at https://swb.one/docs/setup/capy-captain.

Help me connect my Capy Captain to SwB. A Capy Captain directs a group of Capy threads. SwB carries messages between my agents and channels.

Use a SwB client with owner access to set up the Captain. If I want to use SwB tools in Capy, use the setup guide to add a custom MCP server. Use my public MCP address, such as `https://swb.example.com/mcp`.

Call `connect(what="capy-captain")`. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step. Call `connect` again with the same choices to check progress.

Ask me to create a key that can list my Capy Captains. Ask me to save it through the first claim link. Ask me to restart SwB. When `connect` lists the Captains, ask me to choose one. Call `connect(what="capy-captain", choose={"captain":"<Capy Captain ID>"})`. For a project route, add `"project":"<project>"` to `choose`.

A service user is a Capy account for SwB. If `connect` asks for its key, open Capy's API settings. Ask me to create a key with read and write access. Ask me to give that user access to the project and the Captain. Ask me to share the device if the Captain runs on one. Ask me to save the key through the claim link. Ask me to restart SwB.

Ask me to enter keys only through the SwB claim links that connect returns. Keep keys out of this chat and tool arguments.

When `connect` reports `connected`, call `capy_captains`. Check the route with `routes_list`. Call `send` with a short test task and the chosen `project` if you set a project route. Use `wait` or `result` with the returned `conversation` to read the answer. Show me the answer.

Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.
```

Paste the prompt into your SwB owner client.

## Set up the Captain route [#set-up-the-captain-route]

### Open API settings [#open-api-settings]

In Capy, open **Settings** → **API**. Check that the right organization is open.

### Create the read key [#create-the-read-key]

Create a personal API key with access to your Captain. Copy the key while Capy shows it.

### Save the read key [#save-the-read-key]

Open the claim link from your agent. Paste the key in **Token**. Select **Save token**.

### Restart SwB [#restart-swb]

Restart SwB when your agent asks. SwB then loads the key.

### Make a Capy Captain [#make-a-capy-captain]

Create a Capy Captain if you need one. Choose the project and the machine on which the Captain runs.

### Choose the Capy Captain [#choose-the-capy-captain]

Tell your agent which Capy Captain gets the work.

### Create the send key [#create-the-send-key]

In **Settings** → **API**, create a service user with the role `read_write`. Grant it access to the project. Create a key for the service user.

### Share the Capy Captain [#share-the-capy-captain]

Open the Capy Captain menu. Select **Share**. Grant access to the service user. For a Captain on a paired device, grant the service user access to the device too. 

### Save the send key [#save-the-send-key]

Open the second claim link. Paste the key in **Token**. Select **Save token**.

### Restart SwB again [#restart-swb-again]

Restart SwB. Then tell your agent that you are done.

## What the agent does [#what-the-agent-does]

From a client with full owner access, call `connect(what="capy-captain")`. If SwB needs the read key, it returns a claim link. A claim link is a private page for entering a credential.

After the restart, `connect` lists the available Captains. Confirm which Captain should receive the work. Call `connect(what="capy-captain", choose={"captain":"<Capy Captain ID>"})`. For a project route, add `"project":"<project>"` to `choose`. A route tells SwB where to send work.

SwB asks for a service key if the agent needs one to send. Use `capy_captains`, `routes_list` and `routes_resolve` to check the route.

If your app supports MCP events, subscribe to `switchboard.message.created`. For on-demand reads, call `wait` or `inbox`.

## Credentials [#credentials]

| Token | Where it is shown | Format | Where it goes |
| - | - | - | - |
| Read key | **Settings** → **API**, one time | `capy_` and 43 random characters | **Token** on its SwB claim link |
| Send key | **Settings** → **API**, one time | `capy_` and 43 random characters | **Token** on its SwB claim link |

## Check the connection [#check-the-connection]

Ask your agent to call `connect(what="capy-captain")` again. Check for `connected`. Send a short test task to the route. Check for the task in the Captain thread. Read the reply with `result` or `inbox`. Use `/healthz` as the owner to check the name and status of the configured send key.

## Fix problems [#fix-problems]

A Capy key uses the permissions of its account. If `connect` asks for a new read key, create one with access to the Captain.

If a send fails with an access error, check the service user’s access to the project, Captain and paired device.

A value in the server environment wins over a claimed value. Change it in the server environment and restart SwB.

To replace a lost key, revoke it in **Settings** → **API**. Create a new key. Each claim link works once and expires after 30 minutes.
