Credentials per profile
Run one server with different API keys or sign-ins for different profiles, without adding it twice.
A server's API key normally lives in the server's own settings, in its env or headers, and every profile that uses the server shares it. That breaks down when profiles need different accounts of the same service: your company's GitHub token for work, your own for personal, a client's Linear workspace for client-acme.
Give a profile its own credentials for a server instead. You define the server once; each profile that needs other keys gets a separate account of it.
"servers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
}
},
"profiles": {
"work": {
"servers": ["github", "linear"],
"credentials": {
"github": { "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "secret://github-work" } }
}
},
"personal": {
"servers": ["github"],
"credentials": {
"github": { "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "secret://github-personal" } }
}
}
}From the terminal:
switchboard secret set github-work
switchboard secret set github-personal
switchboard profile credentials work github --env GITHUB_PERSONAL_ACCESS_TOKEN=secret://github-work
switchboard profile credentials personal github --env GITHUB_PERSONAL_ACCESS_TOKEN=secret://github-personalIn the web UI, open the profile, find the server under Credentials and turn on Use a separate account for this profile.
How it works
- A profile's
env(for servers that run a command) orheaders(for remote servers) are merged over the server's own. Anything the profile does not set, likeLOG_LEVELor the command itself, comes from the server. - Each account runs as its own process, named
<server>.<account>, such asgithub.work. Accounts have their own tool catalog, logs, restarts and OAuth sign-in, and a key never reaches a profile it was not given to. - The account is named after the profile unless you set
account. Profiles that name the same account share it: one process, one sign-in. They must then give it the same credentials, or the config is rejected. - Profiles without credentials for a server share its default instance, which runs with the server's own settings. If every profile that uses the server has its own account, no default instance runs.
- Tool names stay the same. A client sees
github__create_issuewhichever account serves it, so switching a client fromworktopersonalkeeps its tools and changes only whose GitHub they act on. - Changing one profile's credentials restarts only that account. A call made just after a client switches profile waits for the new account to start instead of failing.
Store keys as secrets (secret://NAME) or, when hosted, environment variables (env://NAME), so they stay out of config.json. switchboard doctor reports credentials that refer to secrets that are not stored.
Sharing an account
Two profiles that should use the same company token can name one account:
"work": { "servers": ["linear"], "credentials": { "linear": { "account": "acme", "headers": { "Authorization": "Bearer secret://linear-acme" } } } },
"acme-readonly": { "servers": ["linear"], "credentials": { "linear": { "account": "acme", "headers": { "Authorization": "Bearer secret://linear-acme" } } } }Both run against linear.acme.
OAuth servers
For a remote server that signs in with OAuth, give the profile credentials with no headers. The profile then has its own account with its own sign-in:
switchboard profile credentials work notion
switchboard server auth notion --profile work # or: switchboard server auth notion.workEach account keeps its tokens under oauth.<server>.<account>.* in the secret store. In the web UI, the server's page lists its accounts with a Sign in button for each.
Seeing accounts
switchboard server lslists each server's accounts, andswitchboard statusshows one row per running account.switchboard profile credentials <profile>lists the servers a profile has its own credentials for.switchboard server test github --profile workstarts the accountworkuses and lists its tools.- On a server's page in the web UI, Accounts shows each account, the profiles it serves, its state and errors.
To go back to the server's own credentials, run switchboard profile credentials work github --remove or turn the switch off in the profile.