# Config

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

SwB can run with environment variables alone. The MCP block starts by default. Some blocks start when you set their variables. Use a YAML file for more settings. YAML is a text format for settings.

## Instance [#instance]

| Variable | Use |
| - | - |
| `SWB_KEY_OWNER` | Owner key for SwB tools and commands |
| `SWB_PUBLIC_URL` | Public address for sign-in and MCP. Use HTTPS for a remote server, for example `https://swb.example.com`. |
| `SWB_HOST` | Address for incoming connections. The default is `127.0.0.1`. |
| `SWB_DATA_DIR` | The data folder. The image uses `/data`. |
| `SWB_OWNER_EMAILS` | Owner email addresses for OpenID Connect (OIDC) and Cloudflare Access. Separate addresses with commas |
| `SWB_KEY_<NAME>` | Key for agent `<name>`. The agent sends it as a bearer key in the `Authorization` header |
| `SWB_CONFIG` | The path of the base YAML file |
| `SWB_OVERLAY` | The path of a private overlay file |
| `SWB_PORT` | HTTP port. The default for `swb up` is `8870`. |

Set `SWB_PORT` in the shell or the instance `.env` file. If your hosting platform sets a different port, use `--url` to select the running server for client commands.

Use `swb up --public-url https://swb.example.com` to set the public URL on the command line. For this run, the option takes priority over YAML `public_url`. YAML takes priority over `SWB_PUBLIC_URL`.

Use `--host` to override `SWB_HOST`. Set a public URL before you use `--host 0.0.0.0` or an address on your local network.

Use `swb up --dir ./my-swb` to read `.env` and `config/switchboard.yaml` from that folder. Use the same `--dir` with `swb init`. With plain `swb up`, use `SWB_CONFIG` to select a different config file.

`swb status`, `swb login-link`, `swb connect` and `swb claim` use `--dir` to find `.env`. They use `--url` to select the server address.

The server commands accept `--dir`. They are `swb serve`, `swb export`, `swb log`, `swb config migrate`, `swb blocks` and `swb targets`. SwB reads `.env` and the config from the selected folder. It also uses that folder to find the instance data for commands that use the database.

With plain `swb serve`, SwB reads the shell and the config file. The other server commands use the current folder by default.

Use `swb config migrate [file]` to print a config in version 2 format. Pass `file` to select a specific config. Otherwise, SwB uses the config from `--dir`, `SWB_CONFIG` or the default path.

## Data folder [#data-folder]

`swb up` and `swb init` create a `data/` folder for a new instance. SwB uses that folder by default. Use `swb up --dir` to select a different instance folder.

Set `data_dir` in the config or overlay to change the path. That setting takes priority. SwB then checks `SWB_DATA_DIR` and `SWB_DATA` in that order. The default applies when all three settings are empty.

Plain `swb up` keeps existing config files. If the instance has a config file, SwB checks for the old database in `~/.local/share/switchboard` when `data/` is absent. SwB logs a notice once if it uses that database.

On Linux and macOS, SwB sets the data folder to private mode `0700`. It sets database files to private mode `0600`.

## Blocks [#blocks]

Some blocks can start from credentials in the environment. See [Blocks](/docs/blocks) for setup. The [release environment example](https://github.com/ZhehanZhang/SwB/blob/release/1.0/.env.example) shows the credential names for named workspaces and routines.

## The config file [#the-config-file]

`swb up` sets up a new instance in its folder. It stores the owner key in `.env` and saves a custom `SWB_PORT` there. It sets the file mode to `0600`.

Run `swb init` to create the files before you start SwB.

```bash
swb init
```

Both commands write `version: 2` to `config/switchboard.yaml` by default. Pass an address to `swb init --public-url` to save it there. On its first run, `swb up` saves the address from `--public-url` or `SWB_PUBLIC_URL`. Add `blocks` to choose which blocks to load. Replace `CAPTAIN_ID` with your Capy Captain ID.

```yaml
version: 2
public_url: https://swb.example.com
auth:
  owner_emails: [owner@swb.example.com]
blocks:
  mcp: {use: mcp}
  capy: {use: capy, identity: service}
targets:
  aliases: {}
routes:
  - {match: {}, to: capy:captain:CAPTAIN_ID}
```

SwB uses the `blocks` section in place of automatic block selection. Set `enabled: false` for the MCP block to turn it off. Block settings can still read credentials from the environment.

## Overlays [#overlays]

An overlay is a YAML file for settings specific to your instance. Save it as `local.yaml` next to the base config file, or set its path with `SWB_OVERLAY`. The overlay takes priority over the base file. The base file takes priority over environment defaults. Settings grouped by name merge. The overlay replaces lists.

In a key, `*` stands for an entry name or a list item.

## Core [#core]

| Key | Use |
| - | - |
| `version` | YAML format version. Use `2` for `blocks` |
| `public_url` | Public address for MCP and sign-in. OAuth lets an app sign in with your approval |
| `data_dir` | Path to the data folder. Set it here or with `SWB_DATA_DIR` |
| `timezone` | Time zone for daily counts and limits. Default `UTC` |
| `turn_cap` | Turns before SwB pauses a conversation. Default `200`. Set `null` to turn off the limit |
| `blocks` | Blocks to load, named by type or by your own label |
| `agents` | Agent definitions by name |
| `agents.*.label` | Display name for an agent |
| `targets` | Target names and their priority |
| `targets.aliases` | Map from a short name to a target name or address |
| `targets.priority` | Order to use when targets share a name. For example, `[capy:captain, agent, project]` |
| `routes` | Initial routes. SwB keeps routes that are already set |
| `routes.*.match` | Match an agent, a project or both. Use `{}` for the global route |
| `routes.*.to` | Address to send to when the route matches |

## Sign-in and keys [#sign-in-and-keys]

| Key | Use |
| - | - |
| `auth` | Sign-in and key settings |
| `auth.owner_emails` | Email addresses that can sign in as the owner through OIDC or Cloudflare Access |
| `auth.cloudflare_access` | Cloudflare Access sign-in settings. Supply both fields and set `auth.owner_emails` |
| `auth.cloudflare_access.team_domain` | Your Cloudflare Access team domain |
| `auth.cloudflare_access.aud` | Audience tag that identifies the Access application |
| `auth.redirect_uris` | Allowed OAuth return addresses. This list replaces the built-in set. Use `/*` to match a path and its subpaths |
| `auth.source_names` | Map from part of an OAuth host or client name to the agent name used for sign-in |
| `auth.key_scopes` | Access scopes by key or agent name, such as `[project:example]`. These scopes limit routes, messages and conversations. They also limit configured keys and OAuth clients when they use memory. For paired keys, SwB adds named memory scopes to the grants at pairing |
| `auth.key_tools` | Map from key name to allowed MCP tools, for example `[send]` |
| `auth.key_targets` | Allowed message targets by key name, for example `[agent:claude]`. A key with this limit must name an allowed target |
| `auth.inbox_keys` | Map from key name to the one agent whose inbox it can read. The built-in entry is `channel: claude-code` |

For Cloudflare Access sign-in, SwB uses the token from the `Cf-Access-Jwt-Assertion` header. If the header is empty or absent, SwB reads the token from the `CF_Authorization` cookie. A cookie is a value the browser sends with a request. SwB checks the RS256 signature with public keys from `team_domain`. The token issuer must match the HTTPS address of `team_domain`. The token must name `aud` as an audience. SwB checks the issue, start and expiration times when the token supplies them. SwB compares the email in lower case with `owner_emails`.

## Visibility [#visibility]

| Key | Use |
| - | - |
| `visibility` | Rules for who can access a resource. Tools stay private |
| `visibility.defaults` | Default rules by resource type. All types start as `private` |
| `visibility.defaults.channel` | Default rule for channels |
| `visibility.defaults.memory` | Default rule for memory scopes |
| `visibility.defaults.route` | Default rule for routes |
| `visibility.defaults.target` | Default rule for send targets |
| `visibility.resources` | Rules for specific resources such as `channel:home/#agents`. Each rule takes priority over its type default |

For Slack, `channel:home/#agents` is a channel rule. For GitHub, share both `channel:github/acme/app` and `target:beta` to let outside senders reach `agent:beta`. See [channel visibility](/docs/channel-modes#allow-outside-github-senders).

Use `private` for the owner and their agents. Use `shared` to open access. List user IDs or entries such as `workspace:home` to share with selected people. Changes made with `visibility_set` take priority over this file.

## GitHub sender trust [#github-sender-trust]

| Key | Use |
| - | - |
| `blocks.github.owner_ids` | Default list of numeric GitHub user IDs trusted as owners |
| `blocks.github.spaces.*.owner_ids` | List of numeric GitHub user IDs that replaces the default for this space |

GitHub uses `owner` and `external` trust. On Slack, Discord and Telegram, `known` helps SwB choose whose messages to accept. Messages from other senders keep `external` trust. See [Owner accounts](/docs/blocks/github#owner-accounts) for Work mode setup.

## MCP [#mcp]

| Key | Use |
| - | - |
| `blocks.mcp` | Settings for the block that serves MCP clients |
| `blocks.mcp.use` | Block type. Use `mcp` |
| `blocks.mcp.legacy_aliases` | Keeps older MCP tool names such as `agent_send`, `capy_delegate`, `capy_wait` and `capy_reply` available. Default `true` |
| `blocks.mcp.wait` | Limits for tool calls that wait for a reply |
| `blocks.mcp.wait.default_s` | Wait time in seconds when the caller leaves it blank. Default `60` |
| `blocks.mcp.wait.max_s` | Maximum wait in seconds. Default `200` |
| `blocks.mcp.wait.agents` | Map of wait limits by agent. Claude Code uses `45` seconds by default and at most `55` seconds |
| `blocks.mcp.wait.agents.*.default_s` | Default wait in seconds for this agent |
| `blocks.mcp.wait.agents.*.max_s` | Maximum wait in seconds for this agent |

## Memory and channel modes [#memory-and-channel-modes]

See [Channel modes](/docs/channel-modes) to bind a project route and set triage actions.

| Key | Use |
| - | - |
| `memory` | Settings for the Markdown copy of memory |
| `memory.mirror` | Controls the Markdown copy. Set `false` to stop updates |
| `memory.mirror_dir` | Folder for the Markdown copy |
| `memory.mirror_debounce_s` | Seconds to wait after a memory change before writing the copy. Default `2` |
| `memory.sync` | Lets agents copy their own memory into SwB with `memory_sync`. Default `true`. The **Memory sync** switch in the console overrides it |
| `memory.backup` | Settings for the Git backup of memory |
| `memory.backup.debounce_s` | Seconds to wait after a memory change before a backup commit. Default `30` |
| `memory.backup.max_delay_s` | Longest wait in seconds for a backup commit during many changes. Default `300` |
| `modes` | Settings for how SwB acts on incoming events |
| `modes.default` | Default mode. The default is `off` |
| `modes.projects` | Default mode for spaces assigned to each project |
| `modes.assist_max_chars` | Character limit SwB gives agents for an `assist` reply. Default `1500` |
| `modes.digest_minutes` | Minutes to collect `watch` events before a summary. Default `60`. SwB also sends a summary at `50` events |

## Branding [#branding]

```yaml
branding:
  display_name: SwB
  accent_color: "#64748b"
```

| Key | Use |
| - | - |
| `branding` | Settings for the name, icon and colors that SwB shows |
| `branding.display_name` | Display name. Default `SwB` |
| `branding.accent_color` | Accent color in `#RRGGBB` format |
| `branding.icon` | Custom icon |
| `branding.logo_assets_dir` | Folder for custom logo files |
| `branding.public_identity` | Internal field fixed at `swb` in this release |

## Full reference [#full-reference]

[config/switchboard.example.yaml](https://github.com/ZhehanZhang/SwB/blob/release/1.0/config/switchboard.example.yaml) has a YAML example with notes.
