Keep tokens out of config files
For anyone whose MCP servers need API keys or tokens and who doesn't want
them sitting in plain text in ~/.claude.json, mcp.json or Surjection's
store. At the end, each server refers to its secret by an alias, and the
value lives in the OS keyring, in 1Password, or in an environment variable
you control.
How it works
A server never holds the value. It holds a reference such as
${secret:GITHUB_TOKEN}, and the alias points at one of three places:
| Where the value lives | Reference | Good for |
|---|---|---|
| OS keyring (Windows Credential Manager, macOS Keychain, Secret Service on Linux) | keyring://surjection/GITHUB_TOKEN | One machine, no extra tools; the default |
| 1Password | op://vault/item/field | Values you already keep in 1Password, shared across machines |
| Environment variable | env:GITHUB_TOKEN | Values another tool already sets, CI, or a shell profile |
When a client starts the server, the value is fetched at that moment (for
example by surject exec or a command the client runs) and never written
into the client's file. A server whose secret can't be found on this
machine is blocked for its clients instead of being written without
it.
Before you start
- Surjection is installed (Install and bring in your existing setup).
- For 1Password: the 1Password CLI
(
winget install AgileBits.1Password.CLIon Windows) with the desktop app's CLI integration turned on (1Password, Settings > Developer).
Steps
Tokens usually come in through one of these, and all of them already keep the value out of the files:
- Importing servers your clients have: each literal token goes to the OS keyring by default (Install and bring in your existing setup).
- Pasting a setup page's snippet: the token goes where you choose before you save (Add an MCP server from a README or setup page).
To set or change where a secret lives, and to fill in one that is missing:
-
Open Settings and scroll to Secrets. It lists the providers this machine has, and the aliases with their reference and the servers that use them. Used but not defined names aliases a server needs that have no reference yet.

-
Choose Check all. The Secrets checklist resolves every alias (it never shows a value) and marks each one Resolved, Missing, Locked: sign in or approve or another status; Blocks apply marks those an enabled server needs.
-
For a missing alias, pick where its value goes:
- Enter value into keyring: type or paste the value in Value.
- Choose a 1Password item: an
op://vault/item/fieldreference. - Use environment variable: the variable's name.
This machine only keeps the choice on this machine, so another machine can use 1Password for the same alias while this one uses the keyring. Choose Save.

-
Choose Review and apply to write the servers that were blocked.
To move an existing alias to another provider, use the same fix on its row, or the command line below. Map a 1Password Environment... maps every variable of a 1Password Environment to aliases at once.
On the command line
# PowerShell 7: keyring (the value is read from stdin, not typed on the command line)
Read-Host -MaskInput | surject secrets set GITHUB_TOKEN --keyring
# 1Password
surject secrets set GITHUB_TOKEN --ref 'op://Developer/GitHub PAT/credential'
# An environment variable
surject secrets set GITHUB_TOKEN --ref env:GITHUB_TOKEN
# Only on this machine
surject secrets set GITHUB_TOKEN --ref env:GITHUB_TOKEN --this-machine
# bash or zsh: keyring
read -rs VALUE && printf %s "$VALUE" | surject secrets set GITHUB_TOKEN --keyring; unset VALUE
A server uses the alias in a field: --env 'GITHUB_PERSONAL_ACCESS_TOKEN=${secret:GITHUB_TOKEN}'
or --header 'Authorization=Bearer ${secret:GITHUB_TOKEN}' (single
quotes, so the shell leaves ${...} alone). A literal value there is
refused with leak_detected.
Check that it worked
surject secrets checkreports every alias as resolved (exit code 5 when one isn't); it may ask for 1Password approval.surject secrets lsshows each alias, this machine's reference and the servers using it.- Open a client file Surjection wrote, for example
~/.claude.json: it holds a reference or asurject execcommand, not the value.
Undo
- A reference change is a store commit: History, select it, Restore
this version on the commit before it, or
surject restore <REV> --path secrets(see Undo a change or restore a client file). surject secrets clear GITHUB_TOKENdeletes the keyring value on this machine (the reference stays).- After an import moved tokens out of a client file, the backup taken
before that write still holds the old values: Remove those backups
now in the import result, or
surject import --remove-old-backups=<APPLY-ID>.
More detail
- User guide, Secrets: providers, delivery
modes,
surject exec, 1Password service accounts and Environments - Security
- Troubleshooting