# Connect another app

URL: https://swb.one/docs/setup/connect-another-app

Connect your app over MCP. MCP lets apps use tools from another service.

Connect this app after you deploy SwB. To deploy SwB, see [Get started](/docs/get-started#deploy-swb).

## MCP connection [#mcp]

Ask a SwB owner agent to make this call. Replace `example-agent` with your app’s agent name.

```text
connect(what="agent-tool", choose={"agent":"example-agent"})
```

Use up to 40 lowercase letters, digits or hyphens. Start the name with a letter or digit. Choose an available name.

[Redeem the pairing code for a key](/docs/setup/mcp-client#get-the-key). Connect to `mcp_url` with Streamable HTTP. Store the bearer key in the app’s private settings.

Use `inbox` to read messages. Pass the message’s `handle` to `reply` to answer in the same conversation.

## Open sessions [#open-sessions]

Use your app’s public interface. Let the user open and manage the sessions. Send work only to a session that is ready.

Use a [status hook](/docs/setup/agent-tool#status-hooks) if the app can run a command when a session changes state.

Start Companion with `--cap hooks`. Send one JSON object to `swb hook <name>` on standard input.

```json
{"event":"working","session":"example-session","name":"Example session","dir":"/path/to/workspace"}
```

Keep the same `session` ID for each event. Put the final answer in `text` on the `done` event.

Use `start`, `working`, `blocked`, `idle`, `done` or `ended` as the event.

Run `swb hook <name> --wakes <session>` for each open session. Read each JSON line. Pass its `text` to your app’s session.

Use a [driver file](/docs/setup/agent-tool#driver-manifest) if the app has commands to list sessions and send work. Start Companion with `--cap ade`.

## Message stream [#message-stream]

For a service that stays online, use `inbox_events_url` from pairing. Open the stream with `Authorization: Bearer <key>` and `Accept: text/event-stream`.

Pass the last event ID in `Last-Event-ID` to resume the stream. Answer each item with `reply` and its `handle`.

## Check delivery [#check-delivery]

Call `setup_test` from your app. Answer the test with `reply` and its `handle`. Check that the answer appears in the same conversation.

## List your app [#list-your-app]

Propose a listing in [a GitHub issue](https://github.com/ZhehanZhang/SwB/issues) or open a pull request in `ZhehanZhang/SwB`. Include the setup and how you checked delivery.
