Replyz is open. Your agent signs itself up and gets an inbox in about a minute, and you claim the account with one email. It receives mail and extracts codes and links; it can reply to people who emailed it (claimed accounts on the 21 Nov 2026 terms or later), with no cold sending. The JavaScript and Python SDKs are in progress. Quickstart

Replyz / Guides / Keep an API key out of the agent's context

How to keep an API key out of an AI agent's context.

If an agent sees an API key, it can end up in a prompt, a log, a transcript or a message to a person. The safer pattern is that a program reads the key and the model never does. This guide shows how that works with the Replyz CLI and MCP server, and what each method still leaves exposed.

Short answer. Let a program read the key, not the model: a CLI that reads it from an environment variable or a protected file, or an MCP config that expands ${VAR} from your environment. Never paste the key into the chat, and treat any file the agent can read as readable by the model.

Why does it matter?

Everything in the model's context can be repeated: in a reply, in a tool call, in a log that someone shares. A key in the context is a key you have already shared with every system that stores that context. Email makes it sharper, because an agent that reads mail also reads text written by strangers; see prompt injection in email.

How does the Replyz CLI keep the key out of the model's view?

The agent runs commands such as replyz wait --otp. The CLI, not the model, reads the key:

At signup the CLI saves the key and does not print it. This is real output (production, 9 November 2026, @replyz/cli 0.2.1):

npx -y @replyz/cli signup --name guide-demo
...
API key:    saved in ~/.config/replyz/credentials.json

The key is printed only when you pass --print-key, or when saving the file failed. Do not run that in a session the agent sees.

How do you keep the key out of an MCP config?

The CLI can print the configuration for any MCP client, with a variable instead of the key. This is real output from the same run:

npx -y @replyz/cli mcp install --client print
{
 "mcpServers": {
  "replyz": {
   "type": "http",
   "url": "https://mcp.replyz.io/mcp",
   "headers": {
    "Authorization": "Bearer ${REPLYZ_API_KEY}"
   }
  }
 }
}

Claude Code expands ${VAR} in the headers of a project .mcp.json from your environment, so the key itself is not in the file. By contrast, claude mcp add --header "Authorization: Bearer <key>" saves the configuration, so the key you typed is stored in Claude Code's configuration file. See how to add an MCP server to Claude Code.

What does this still leave exposed?

What do you do if the key leaks?

The human who claimed the account can revoke every API key and issue a new one from the manage page, after signing in with a one-time link sent to the address that claimed the account, or with Google. Replyz stores only a keyed hash of each key, so it cannot show you a lost one: you issue a new key. Read how an agent creates its own email address and how a human claims it.

See the CLI and the MCP server for every command and tool, and security for what Replyz does with the mail itself.

Frequently asked questions

How do I keep an API key out of an AI agent's context?

Let a program read the key, not the model. Give the agent a command-line tool that reads the key from an environment variable or a protected file, or an MCP config that expands ${VAR} from your environment. Do not paste the key into the chat, the prompt or a file the agent reads.

Where does the Replyz CLI keep the key?

In REPLYZ_API_KEY if it is set, otherwise in a credentials file under ~/.config/replyz/ (or $XDG_CONFIG_HOME, or $REPLYZ_CONFIG_DIR). The folder is created with mode 0700 and the file with mode 0600. The CLI does not print the key unless you pass --print-key.

Does claude mcp add keep the key out of the config file?

Not if you write the key in the --header value: the command saves the configuration, so the key is stored in Claude Code's configuration file. To keep it out of the file, use a project .mcp.json with a header such as "Bearer ${REPLYZ_API_KEY}", which Claude Code expands from your environment.

Can the agent still read the key?

If it can run a shell command or read files, yes: it could print the variable or open the credentials file. Keeping the key out of the context lowers the chance of leaking it; to go further, restrict what the agent may read and run, and use an account whose key you can revoke.

What if the key leaks?

The human who claimed the account can revoke every API key and issue a new one from the manage page. Replyz stores only a keyed hash of each key, so it cannot show you the old one.

Give your agent an inbox.

Your agent signs itself up. Start with the quickstart.

Get started