Worked Examples
Two end-to-end walkthroughs — an agent resolving a GitHub token to open an issue, and an agent resolving a Stripe key to create a charge.
Coming Soon — the Agent Vault is not yet generally available. This documentation describes the feature ahead of its release; details may change before launch.
Both walkthroughs follow the same shape: a config or prompt written with a placeholder, an agent that resolves the real value only at the moment it's needed, and a genuine authenticated API call made with it. Neither example ever writes the resolved secret to disk.
Example 1: Claude Code opens a GitHub issue
Goal: Claude Code, connected via MCP, resolves a GitHub token from the Agent Vault and uses it to open an issue on a real repository — without the token ever appearing in your prompt, your shell history, or a file.
Setup
- In SecretStash, store your GitHub personal access token as a variable named
GITHUB_PROD_TOKENin theproductionenvironment of the relevant application. - Create an agent of type Claude Code, authorize it for that environment, and connect it as described in MCP Integration → Claude Code.
- In your project, reference the credential by placeholder — for example, in a
NOTES.mdor your prompt itself:
Walkthrough
Claude Code recognizes the placeholder
Being connected to the agent-vault MCP server doesn't by itself teach Claude Code the __SECRETSTASH_*__ syntax — that's why the prompt above explicitly tells it to resolve the placeholder through the vault. With that instruction in place, Claude Code sees __SECRETSTASH_GITHUB_PROD_TOKEN__ and knows to call the MCP server for the real value instead of asking you for it.
The agent calls resolve_secret
The Agent Vault checks the agent's authorized environments, unseals the production DEK, decrypts the variable, and returns the plaintext token in the tool result — visible only within that single tool call's context.
The agent makes the real call
Claude Code uses the resolved token to call the GitHub API directly:
GitHub creates the issue and returns its number and URL.
The resolution is audited
SecretStash records a secret_resolved entry: which agent, which environment, which variable, and when. See Verification & Operations.
Nothing in this flow requires you to open the GitHub token yourself. If you inspect Claude Code's transcript, you'll see the placeholder and the tool call — the plaintext value only ever exists transiently inside the tool result.
Example 2: A script resolves a Stripe key to create a charge
Goal: A small Python script — not an MCP client — uses the REST fallback to resolve a Stripe secret key at runtime and creates a real charge, demonstrating the fallback path end-to-end.
Setup
- Store your Stripe secret key as a variable named
STRIPE_SECRET_KEYin theproductionenvironment. - Create an agent of type Custom, authorize it for that environment, and copy its API key.
- Write the script so the key only ever exists in memory, resolved right before use:
What happens
create_chargecallsresolve_secret, which hitsGET /api/v1/agents/{agent}/secrets/STRIPE_SECRET_KEY?environment=production— the same endpoint documented in the REST API reference.- The resolved key lives only in the
stripe_keylocal variable, used immediately as the Basic-auth username on the Stripe request, and goes out of scope oncecreate_chargereturns. - Stripe processes the charge and returns a charge object; the script prints its
id, never the key. - SecretStash records the resolution in the audit log, the same as the MCP example above.
Never assign the resolved value to a module-level constant, write it to a .env file, or include it in a log line. Resolve it inside the function that needs it, right before the call that uses it.