How to keep API keys away from AI agents
An AI agent that can read your API keys can also leak them: into a log, a file, a tool call or a prompt-injected request. On hosted Claude Code runs on FleetQ Cloud, enabled per team, the agent does not get the real Anthropic token or the bearer tokens of remote (HTTP) MCP servers. It gets a short-lived token for its run, and a secret proxy swaps that token for the real credential when a request goes out.
Why agents should not hold real keys
A coding agent runs shell commands, reads files and follows instructions it finds in the data it works on. If the real Anthropic token or an MCP server's bearer token sits in its environment or config, one bad instruction is enough to copy it somewhere. Keys copied this way keep working long after the run is over.
A short-lived token for each run
Each run gets its own opaque token instead of the real Anthropic OAuth token or the bearer token of an HTTP MCP server. The real credentials are stored encrypted (AES-256-GCM), with an expiry sized to the run's timeout, and are deleted when the run ends. A token that leaks is useless once its run is over.
The secret proxy adds the real credential
Calls to Anthropic and to the HTTP MCP servers attached to the agent go through the secret proxy. At request time the proxy looks up the run token, swaps it for the real credential and forwards the request. The agent gets the answer, but never the key.
Only the hosts the run needs
By default the proxy only forwards to listed hosts: Anthropic and the HTTP MCP servers attached to the agent. The proxy only adds credentials for listed hosts, and it does not follow redirects automatically, so a redirect cannot carry a credential somewhere else. To decide which MCP tools an agent may call at all, pair this with an MCP firewall.
Refused requests are logged
When the proxy refuses a request, it records a denied-egress event, and FleetQ moves those events into the platform audit log. If the proxy refuses to forward a credential to a host, that refusal is logged. Traffic that does not pass through the proxy is not covered by this log.
Fails closed
If the proxy is down, the run fails. It does not fall back to handing the agent raw keys.
Where it applies
Credential isolation covers hosted Claude Code runs on FleetQ Cloud, enabled per team. It protects the Anthropic token and the bearer tokens of HTTP MCP servers those runs use. Local (stdio) MCP tools still start with their own credentials in their environment, so the agent can reach those keys; prefer HTTP MCP servers for tools whose keys matter. It is not a firewall for all network traffic from the container, and other runtimes work as before.
FAQ
Can the agent read my Anthropic key?
No. On these runs it only holds an opaque run token. The real key stays encrypted and is added by the proxy.
What happens if the run token leaks?
It stops working when the run ends, because the stored credentials for that run are deleted.
Does the proxy cover stdio MCP tools?
No. Only the Anthropic token and HTTP MCP bearer tokens are swapped. Local (stdio) MCP tools receive their credentials directly.
Will the proxy send my Anthropic or HTTP MCP token to another site?
No. The proxy only adds those credentials for listed hosts. If it refuses to forward one, the refusal is recorded as a denied-egress event.
Related guides
- Manage AI agents through MCP MCP lets an AI assistant call tools in another system. FleetQ ships an MCP server, so the assistant you already use can work with your agent fleet.
- AI agent audit log When an agent sends a wrong email or burns through your LLM budget, the first question is always the same: what exactly happened? Without an audit log you guess. With one you read it.
- Self-host an AI agent platform Some teams cannot send agent data to a third party, or want to own the stack. FleetQ is open source (AGPL-3.0) and runs on your own server.
- MCP firewall for AI agents Decide which MCP tools an agent may call on its own, which need a human yes in Slack or Telegram, and which are blocked, with a budget cap on top.
- AI agent budget limits An AI agent without a budget limit is an open tab on your API bill. Set limits per run, per agent and per team, and stop the agent, not only alert, when a limit is hit.
- Build AI agents in Python Drive FleetQ agents from Python over the REST API: create a token, chat with an agent, start governed runs and approve steps with plain requests calls.
- Human in the loop for AI agents Human-in-the-loop means a person approves an agent's action before it happens. You do not need it for every step, only for actions that are costly, irreversible or external.
- All guides