How AI agents can share secrets without leaking them into transcripts

How AI agents share secrets with people and other agents without leaking them into transcripts: three handoff patterns, four ways in, and rules to copy.

The Evergist team · · Updated · 6 min read

Short answer: have the agent put the secret in an end-to-end encrypted, one-view link and share only the link. The agent encrypts on its own machine, so the secret never reaches a server in readable form, and the handoff message holds only the link. With Evergist, add the local MCP server or give the agent SKILL.md. The MCP tools do pass the text through the model: create_gist takes it as an argument and read_gist returns it. To keep the value out of an agent's context, use the CLI with files instead (npx -y evergist create FILE --views 1 to send, npx -y evergist read "<link>" > FILE to receive).

Why do AI agents leak secrets?

Agents leak secrets because everything they print is kept, and printing is the easiest way to hand something over. A password in a reply, a .env file in a pull request description, and an API key in a ticket comment all outlive the handoff. The places agents write to are built to remember:

  • Session transcripts. Claude Code's data usage docs say its clients "store session transcripts locally in plaintext under ~/.claude/projects/ for 30 days by default".
  • Issues and pull requests. GitHub's secret scanning docs say it scans the entire Git history and also the titles, descriptions, and comments of issues and pull requests.
  • Team chat. Slack's retention docs say that on paid plans "data is kept for the lifetime of your workspace by default".

Rotation fixes a leak, but only if someone notices it.

How should an agent hand a secret to a person?

The agent encrypts the value locally, uploads ciphertext, and reports a link that works once. If the secret is in a file, the agent never has to print it:

npx -y evergist create .env --views 1 --expires 1h --json

The agent then reports the full link including the part after #, when it expires, and that it opens once. It does not repeat the contents.

If the agent generated the secret itself, for example a database password it just set, the value is already in its context. The MCP tool create_gist with max_views: 1 is then as good as the CLI.

How should a person hand a secret to an agent?

The person creates a one-view note on the website and pastes only the link into the chat. The agent writes the note to a file without printing it:

npx -y evergist read "https://evergist.com/g/<id>#<key>" > .env.local
sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env.local

The first command decrypts on the agent's machine and uses the one view. The second prints only the names on NAME=value lines and skips everything else, so the agent can confirm what arrived without showing the values. The link in the chat is dead after that read.

This holds only while the agent doesn't print the file. Give Claude Code an API key without pasting it covers the deny rules and ignore files that help, and where they stop helping.

How does one agent pass a credential to another agent?

The first agent creates a one-view note with a short expiry and passes only the link through whatever channel the two share.

  1. The sending agent runs npx -y evergist create creds.env --views 1 --expires 1h --json and keeps url from the output.
  2. It passes url to the next agent. It keeps deleteToken for itself or the user.
  3. The receiving agent runs npx -y evergist read "<link>" > creds.env. The server deletes the note on that read.
  4. If the handoff never happens, the note expires within the hour. npx -y evergist status "<link>" checks a note without using a view.

When the channel between agents is itself logged, add a password and deliver it another way. The sender adds --generate-password, and the orchestrator sets EVERGIST_PASSWORD in the receiver's environment. The link alone then decrypts nothing, and 10 wrong passwords delete the note.

Which should an agent use: MCP server, SKILL.md, CLI, or REST API?

Use the CLI with files when the value must stay out of the model's context, and the MCP server when the text is already in the conversation. All four encrypt before anything goes over the network.

Way in Setup Does the model see the value? Use it when
MCP server One command per client. Node.js 20+ Yes. create_gist takes the text as an argument and read_gist returns it The text is already in the conversation, or it's a handoff note and not a credential
SKILL.md Copy one file, or add one line to the agent's instructions Only if the agent prints or reads the file. The skill uses the CLI The agent loads skills or follows instruction files and has a shell
CLI None. npx -y evergist fetches it. Node.js 20+ No, if you pass a file to create and redirect read to a file Scripts, CI jobs, and any handoff where the value should stay out of context
REST API You implement AES-256-GCM and HKDF yourself Only if your code shows it to one There's no Node.js, or you're writing your own client

The MCP server is one line in Claude Code, claude mcp add evergist -- npx -y evergist mcp, and it runs locally with no account. The agent guide has the config for every client, and An MCP server for sharing secrets shows what each tool call sends.

What rules should you give an agent that handles secrets?

Give it rules that name the places secrets must not go and what to do instead. This block works in an AGENTS.md, a CLAUDE.md, or a system prompt:

Handling secrets:
- Never print a password, token, key, or .env contents into the conversation,
  a ticket, a pull request, a commit, or a log.
- To hand a secret to anyone, create an Evergist note and share only the link.
  Read https://evergist.com/SKILL.md first.
- Use one view and an expiry of an hour or a day for credentials.
- Pass secrets as a file or on stdin, never as a command line argument.
- When given an evergist.com/g/ link, read it into a file. Don't print the file.
- Report the link, the expiry, and the view limit. Never the contents.
- Give the delete token only to the user who asked for the note.

What does this not do?

An agent that reads a note through the MCP tool, or prints a file, does see the value. Redirecting evergist read to a file keeps it out of the tool output.

  • Anyone with the link can read the note. One view limits that to the first reader, whoever that is.
  • It doesn't store credentials. Evergist is not a vault or a secrets manager. A service that needs a key on every boot should get it from one. One-time links or a vault for AI agents draws the line.
  • It holds text only. Notes take up to 512 KiB and last 1 minute to 30 days (the web form offers 10 minutes to 30 days).
  • It doesn't undo a leak. A key an agent already printed needs rotating.

Questions

Can an AI agent share a secret without seeing it?

Yes, if the secret is in a file. npx -y evergist create FILE --views 1 encrypts the file without the agent printing it, and npx -y evergist read "<link>" > FILE writes a received note to disk. The MCP tools can't do this, because the text is a tool argument or a tool result.

Yes for a one-view note. The link stays in the transcript, but after the first read the server has deleted the note. With no view limit the link works until it expires, so set one view for anything secret.

Do agents need an account or an API key to use Evergist?

No. There are no accounts and creating a note needs no key. Creates are rate limited to 10 per minute and 120 per hour from one network. The same advice for people is in How to share a password securely, and how the encryption works has the full scheme.