# Secrets and API keys in Amp: keep credentials out of the agent's reach

Source: https://botpassword.com/agents/amp
Last checked: 2026-10-25

Amp is a coding agent from Sourcegraph that runs in the terminal and editors. MCP servers go under `amp.mcpServers` in `~/.config/amp/settings.json` or the workspace's `.amp/settings.json` (which needs approval), and `amp mcp add` registers them with `${VAR}` expansion in URLs and headers. Amp reads `AGENTS.md`, falling back to `AGENT.md` or `CLAUDE.md`.

## MCP support

Yes. Transports: stdio, http.

- user: `~/.config/amp/settings.json`
- workspace: `.amp/settings.json`

Add a server with `amp mcp add context7 -- npx -y @upstash/context7-mcp  |  amp mcp add linear https://mcp.linear.app/sse`.

## Environment variables and .env files

`${VAR_NAME}` expands in config files, for example in a remote server's `url` and `headers`. Workspace servers in `.amp/settings.json` must be approved (`amp mcp approve <name>`) before they run, while user settings and `--mcp-config` servers need no approval. For remote OAuth servers, `amp mcp oauth login <name>` stores credentials. The pages reviewed do not describe `.env` loading.

## File access

Remote MCP tools each have a policy of Allow (default), Ask First or Disabled. Setting `AMP_IGNORE_GUIDANCE_FILES` to a glob list stops matching `AGENTS.md` files loading as guidance, but Amp's documentation says ignored files can still be read explicitly with a tool, so it is not an access restriction. The pages reviewed do not document a file-deny mechanism.

## Credential risks

- **Self-modifying configuration.** A 2025 disclosure listed by Simon Willison describes the Amp agent being tricked into editing the VS Code `settings.json` to enable new Bash commands and MCP servers, leading to code execution; the entry is recorded as fixed.
- **Workspace MCP servers are repository-supplied code.** A `.amp/settings.json` in a cloned repository can define a stdio command, which is why Amp requires explicit approval before it runs; global and `--mcp-config` servers skip that approval.
- **Remote MCP tools default to Allow.** Amp's MCP page says each remote tool's default policy is Allow, so a tool with side effects runs without a prompt unless you set Ask First or Disabled.

## FAQ

### Where does Amp store MCP server configuration?

Under `amp.mcpServers` in `~/.config/amp/settings.json` (user) or `.amp/settings.json` (workspace, needs approval). The `--mcp-config` flag also works and needs no approval.

### How do I add an MCP server to Amp from the command line?

Run `amp mcp add context7 -- npx -y @upstash/context7-mcp` for a local server or `amp mcp add linear https://mcp.linear.app/sse` for a remote one.

### Does Amp read AGENTS.md?

Yes. It includes `AGENTS.md` from the working directory up to `$HOME`, subdirectory files when you read in that subtree, and personal files in `~/.config/amp/`. If a directory has none it uses `AGENT.md` or `CLAUDE.md`.

### How do I give Amp an API key without it seeing the key?

Don't put the key in the prompt, in a file Amp can read, or in an environment variable it can print. Give it a tool that performs the authenticated step instead: a credential broker exposed over MCP or a CLI that injects the key into the command or HTTP request and returns only the result. BotPassword is that broker, through `bpw mcp` and the `bpw` CLI.

## Sources

- https://ampcode.com/docs/customize/mcp
- https://ampcode.com/docs/customize/agents-md
- https://simonwillison.net/2025/Aug/15/the-summer-of-johann/
