Learn · MCP
How do I let an AI agent use a secret without putting it in the prompt?
Not by asking it politely to forget. By never handing it the value: a local MCP server injects the secret into a child process's environment and returns only that process's output. The model gets the result. It never gets the credential.
What actually happens when you paste a key into a chat
Three things, none of them reversible:
- It is in the transcript. The conversation is stored, cached, and often exported. Deleting the message does not delete the copies already sent.
- It is in the context window on every turn. Every subsequent request re-sends it. A key pasted at message two is re-transmitted dozens of times before the session ends.
- It has left your machine. Whatever the provider's logging and retention policy is, you now depend on it. For a credential that talks to production, that is a decision made in five seconds and hard to undo for a year.
The usual mitigation — "rotate it afterwards" — is the tell that the workflow is broken. A credential you rotate after every use is a credential you cannot use casually, which is the entire point of having agents do the work.
The pattern that avoids it
Keep the secret in a local vault. Give the agent a way to ask for a command to be run with the secret in its environment, and return only that command's stdout. The model writes the command; the vault provides the value; the value never enters the conversation.
agent → run_with_secret(secret: "OPENAI_API_KEY", cmd: "curl", args: ["-sS", "https://api.openai.com/v1/models"])
vault → spawns curl with OPENAI_API_KEY in its environment
agent ← the HTTP response body, and nothing else
Four properties follow, and they are worth separating because vendors routinely merge them into one vague claim:
- The value is not in the tool's return payload. Structural: no code path builds a success response containing the secret.
- There is no tool that reveals it. Not a permission flag, not an admin mode — the tool is not registered, so a call to it returns JSON-RPC
-32601 Method not found. - Output is redacted as a second layer. Whatever the child process prints is passed through a filter that replaces strings matching known secret fingerprints before the text reaches the model.
- The audit is local. Usage is recorded on the machine that holds the vault, so "which agent used which secret" is answerable without a remote log.
The four tools, and the one that does not exist
Bitcoffer exposes exactly four read-only tools. The list is short on purpose: every tool added to this surface is another path by which a value could leak.
| Tool | Returns | Never returns |
|---|---|---|
list_secret_names | Names, optionally filtered by vault | Values |
list_secrets | Metadata: name, id, category, updated timestamp | Values |
get_secret_metadata | Read-only metadata for one item, plus the login username when the item has one | Values |
run_with_secret | The child process's stdout, after redaction | The value, and any of the child's other file descriptors |
There is no reveal_secret, no get_password, no dump_vault, no export_all_secrets. This is the part of the design that is easiest to verify and hardest to fake: unregistered tools return -32601, so you can check the surface yourself by sending tools/list and counting what comes back.
The run_with_secret schema is deliberately small — secret, cmd, optional env_name, args, cwd. There is no shell flag, so the command is not passed through /bin/sh and cannot be a pipeline with a second command hidden behind a semicolon.
The limitation, stated plainly
Redaction is a filter over text, and a filter is not a boundary. Once a child process holds the secret in its environment, its own output is outside Bitcoffer's control. If the agent runs sh -c 'echo $OPENAI_API_KEY', the value goes to stdout and the redactor may or may not catch it — the filter looks for known fingerprints, which is a heuristic, not a guarantee.
So the guarantee has an exact shape, and it is worth stating in the form you can defend:
The value is never returned by the vault. Whether it appears in a child process's output depends entirely on what that child does with it.
In practice this means the command you allow matters more than the filter. Running a client that reads the variable and sends it to an API is safe. Running a shell that prints its environment is not, and no amount of filtering makes it safe. Treat run_with_secret as "use this credential in a tool that needs it", not as "run anything with the credential available".
How the transport is protected
A local server that hands out credentials invites an obvious question: which local process gets to talk to it? Over a Unix domain socket Bitcoffer applies four checks, and the second one is the interesting one:
| Check | Mechanism |
|---|---|
| Single connection lifetime | The listener accepts once; EOF closes the server cleanly |
| Peer identity | The connecting process's PID must equal the PID of the process that spawned the server (LOCAL_PEERPID plus getpeereid on macOS, SO_PEERCRED on Linux). A different process, even the same user, is refused |
| Session challenge | A random value passed in the spawn environment and echoed back on initialize, so a process that merely finds the socket path cannot use it |
| Replay | Message ids must be monotonically increasing, as with stdio |
The socket file is mode 0600 and its directory 0700. Missing handshake material is a configuration error, not a permissive default: the server exits rather than serving without it.
Wiring it up
The CLI ships inside the app bundle and must run from there — the signature is bound to the bundle, so a copied binary will not work:
claude mcp add --scope user bitcoffer \
-e BITCOFFER_VAULT_DIR=/path/to/vault \
-- "/Applications/Bitcoffer.app/Contents/Helpers/bitcoffer.app/Contents/MacOS/bitcoffer" mcp --provider bitcoffer
For a client that launches the server itself, bitcoffer mcp --uds /path/to/socket switches the transport from stdio to a Unix socket without changing the protocol frames. The MCP surface is opt-in, and it is read-only: it can list, describe and run-with, but it cannot create, edit or delete a vault item.
What this does not fix
- An unlocked machine. Any process running as you can ask the vault for a command to be run with a secret. The MCP layer protects the value from the model, not from malware.
- A model that writes a bad command.
curl -H "Authorization: Bearer $KEY" https://example.comsends the credential wherever the URL says. Injection protects the context window; it does not audit intent. - Secrets that must be typed into a UI. The pattern works for command-line tools. A login form in a browser still needs the password, and a password manager's autofill is a different mechanism with different exposure.
An encrypted vault, Touch ID unlock, and a local MCP server with four read-only tools. Secret values are injected into a child process and never returned to the model.
Download Bitcoffer Pricing