---
url: /secrets/using.md
---
# Giving secrets to agents

A registered secret reaches nothing until you assign it. Each place you can assign one gives the value to one target, one agent, or one server:

| Place | Command | Reaches the harness |
| --- | --- | --- |
| A target's credential, the harness's login | `pandra config target set work --login api-key --secret anthropic-api-key` | as a placeholder that Pandra's proxy replaces |
| An agent's environment variable | `pandra config set --agent AGENT env.NPM_TOKEN --secret npm-token` | as the variable's value |
| An MCP server's input | `pandra config mcp set slack-work --agent AGENT --server slack --secret token=slack-token` | as a placeholder for a remote server's header, as a variable for a local server |

Every place takes a literal string or `{ secret = "NAME" }`. A target's credential, and a value the package declares secret, take only a secret, so a token is never written into the file as text.

## A target's credential

A target's credential is the login the harness uses for the model provider. `--login` picks the variable from the target's provider and login method:

```text
$ pandra config target set work --harness claude-code --login api-key --secret anthropic-api-key
wrote env.ANTHROPIC_API_KEY = { secret = "anthropic-api-key" } to targets.work (anthropic api-key)
```

The harness gets a random placeholder in that variable, and Pandra's proxy puts the real value in its place only in requests to the provider's API, or to a gateway's base URL. On a terminal, you can leave out `--secret`, and Pandra asks for the secret. The question and the methods for each harness and provider are in [target credentials](/configure/targets.md#target-credentials).

## An agent's environment variables

`pandra agent inspect AGENT` lists the variables an agent expects, and `pandra config show --agent AGENT` shows which are set. To assign a secret to one:

```sh
pandra config secret set npm-token --1password op://Work/npm/token
pandra config set --agent github.com/acme/publisher env.NPM_TOKEN --secret npm-token
```

The harness, and everything it starts, gets the real value in that variable, because Pandra cannot know where the agent's tools send it. A variable set on a target applies to every agent that uses the target, and the narrowest place wins ([environment variables for agents](/configure/agent-settings.md#environment-variables-for-agents)).

## MCP server inputs

A server's inputs, such as a Slack token, get their values from an MCP configuration that you assign to the agent's server:

```sh
pandra config mcp set slack-work --agent AGENT --server slack --secret token=slack-token
```

Assigning it also allows that server to receive the values. A run on a terminal asks for any required input that has no value. [Allowing servers](/mcp-servers/allowing.md) covers the questions, the commands, and when Pandra asks again.

## How a value reaches the harness

Pandra never writes a secret value into a file it prepares for a run. When a run starts, Pandra reads each secret the run needs from your store, once, and passes it on in one of two ways:

1. Variable: an agent's variables and a local MCP server's values reach the harness as their real values, in environment variables. The agent and its tools can read every environment variable of the harness, so they can read these values.
2. Proxy: a target's credential and the secret headers of a remote MCP server go to Pandra's proxy instead, and the harness gets a placeholder in their place.
3. Placeholder: the harness sends its requests through the proxy, with the placeholder.
4. Value: the proxy puts the real value in place of the placeholder only in requests to the origin that should receive it, the provider's API or the MCP server's URL. A tool that prints its environment variables, or a request to another host, gets nothing usable.

`[harnesses.<name>] secret-proxy = false` turns the proxy off for a harness that cannot use it, which then receives every secret as its real value in environment variables ([harness programs and runners](/configure/targets.md#harness-programs-and-runners)). The details for each kind of MCP server are in [how values reach servers](/mcp-servers/allowing.md#how-values-reach-servers).

## Checking before a run

`pandra run AGENT --dry-run` shows every secret a run would use by name and source, and where it goes, without reading any of them:

```text
...
Environment variables
  NPM_TOKEN  secret npm-token (1password)  agent settings

Credentials
  ANTHROPIC_API_KEY  secret anthropic-api-key (keychain), through Pandra's proxy

MCP servers
  github
    Server:         io.github.github/github-mcp-server 1.4.0 (MCP Registry, registry.modelcontextprotocol.io)
    URL:            https://api.githubcopilot.com/mcp/
    Inputs:         Authorization  secret github-token (command gh auth token) as "Bearer {}", through Pandra's proxy
    Configuration:  github

Checked when the run starts: model and effort support, secret values, harness version support, MCP server connections

Ready to run.
```

A source that cannot be read stops the run with the step that fixes it, such as `op signin`; Pandra never falls back to another source.

## Supplying a value without its store

`PANDRA_SECRET_<NAME>` gives Pandra a secret's value from outside, such as from a CI job's secrets, where your password manager is not available. `<NAME>` is the name of the logical secret, as `pandra config secret set` registered it, in upper case and with each `-` replaced by `_`. The secret `github-token` reads `PANDRA_SECRET_GITHUB_TOKEN`:

```sh
PANDRA_SECRET_GITHUB_TOKEN="$TOKEN_FROM_CI" pandra run github.com/acme/reviewer
```

`pandra config secret list` shows `set` in its `OVERRIDE` column for each secret whose variable is set.

The agent does not get the variable: Pandra removes every `PANDRA_SECRET_*` variable before it starts the harness. The configuration file stays the same, and the variable takes precedence over the secret's source, even when it is empty. It only supplies a value: it never assigns the secret to anything.

In CI and in containers, use `PANDRA_SECRET_<NAME>`, so that a value you assign to a target's credential or to a remote MCP server's header stays out of what the agent can read while Pandra's proxy is on. The agent can still use such a value through the proxy ([target credentials](/configure/targets.md#target-credentials)). A value you assign to an agent's variable or to a local MCP server still reaches the agent, as [how a value reaches the harness](#how-a-value-reaches-the-harness) says. [Review every pull request in CI](/examples/review-pull-requests-in-ci.md) supplies its MCP server's token with `PANDRA_SECRET_GITHUB_TOKEN`.

An `env` source that reads the job's own variable works too, but the agent inherits that variable as well ([environment variables](/secrets/stores.md#environment-variables)). A `file` source that points at a mounted secret is another way ([container images](/integrations/containers.md)).

A run that an agent starts cannot read secrets from these variables ([agents that run agents](/configure/agent-settings.md#agents-that-run-agents)).
