Canonfig
How-to Guides

Share MCP credentials

Give authenticated MCP servers shared credentials without putting values in harness configs.

Use a Source and Followers on the same Canonfig release line, with a working native credential store. Only followers enrolled in canonfig:secrets receive shared secrets. Every authorized follower receives the shared collection, not just secrets referenced by its selected MCP servers.

Store the credential on the Source

Store the value under a name you will reference in the MCP definition:

canonfig secrets set github-token

At a terminal, Canonfig prompts with input hidden. For a remote server whose Authorization header requires a bearer token, store the complete header value, including Bearer , not just the token. References do not interpolate prefixes. Do not paste values into JSONC, command arguments or shell history.

Reference it in the folder

Add the server to ~/.canonfig/canonfig.jsonc on the Source:

{
  "version": 1,
  "harnesses": ["claude-code", "codex"],
  "mcp": {
    "github": {
      "transport": "streamable-http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": { "Authorization": { "fromSecret": "github-token" } }
    }
  }
}

For a stdio server, put the reference under env instead:

"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": { "fromSecret": "github-token" } }

Use the credential format the server expects. The stdio example typically needs the raw token rather than an HTTP bearer header. Use separate secret names when servers need different formats.

An allowed machine-local MCP definition in local/local.jsonc can also use fromSecret. Replacing a published name requires an explicit local overlay.

Publish and sync

Review and publish on the Source:

canonfig source publish --reviewer dana

Enroll Followers with an invitation that includes --group canonfig:secrets. On an authorized Follower, apply the revision and shared secrets:

canonfig sync --apply
canonfig secrets list

Restart the MCP server in your harness. Canonfig's projected command launches the installed CLI with absolute Node and CLI paths. The launcher resolves the named secret from this machine's credential store only when the server starts. Rotation takes effect on the next server start after syncing secrets.

Remote servers use pinned mcp-remote@0.16.6. The first launch needs npm registry access unless that version is cached, and npm must be installed beside Node. Headers pass through private child environment variables, never command-line values. The launcher adds Node's directory to the bridge's PATH, so a GUI-launched macOS harness does not need your shell's PATH to find Node or npm. Your own stdio server command still needs an absolute path or a usable PATH.

Resolve a failed start

Run canonfig mcp run github from the same login session as the harness to see launcher errors on stderr. Its stdout is an MCP protocol stream, not a status report. Stop it when finished.

  • Exit 20 names a missing secret. Check canonfig secrets list, the follower's canonfig:secrets authorization, and canonfig secrets sync.
  • Exit 21 names a secret that could not be read. Unlock the native credential store in the harness's session. A macOS GUI session or a Windows interactive logon may have access that an SSH session does not.
  • Exit 22 means the child could not start or the launcher failed. Check the server command, working directory, and npm installation beside Node.
  • Exit 2 means the folder, server name or required environment is invalid.

The child server's own exit code passes through unchanged. See the CLI reference for the full launch contract.

On this page