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

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

Claude Desktop runs local MCP servers (stdio) defined in `claude_desktop_config.json`, or installed as one-click Desktop Extensions (`.mcpb`), and shows connected servers under Connectors. Each action needs your approval, and the server runs with your user account's permissions. It has no project instructions file.

## MCP support

Yes. Transports: stdio.

- user: `~/Library/Application Support/Claude/claude_desktop_config.json (macOS); %APPDATA%\Claude\claude_desktop_config.json (Windows)`

## Environment variables and .env files

The config file's `mcpServers` entries take `command`, `args` and an optional `env` object; the MCP guide shows values written literally and notes that on Windows you may need to add the expanded `APPDATA` value to `env`. Desktop Extensions can mark manifest fields `"sensitive": true`, in which case Claude Desktop stores them in the OS secure store (Keychain, Credential Manager or the distribution's keychain manager). The pages reviewed do not describe `.env` loading.

## File access

Claude Desktop itself has no workspace; access depends on the MCP servers you install. The filesystem server example limits access to the directories you list in `args`, and Claude asks for approval before each file operation. The MCP guide warns that servers run with your user account's permissions.

## Credential risks

- **Desktop Extensions run unsandboxed.** LayerX reported in February 2026 that a single Google Calendar event could trigger code execution through chained Claude Desktop Extensions, because extensions run with full system privileges; per the reporting, Anthropic said the issue was outside its current threat model and declined to fix it.
- **Command injection in official extensions.** Koi Security reported command-injection flaws in the Chrome, iMessage and Apple Notes extensions, rated high severity (CVSS 8.9) and patched by Anthropic.
- **Local servers have your permissions.** Anthropic's MCP guide states a server "runs with your user account permissions", so it can perform any file operation you can.

## FAQ

### Where is claude_desktop_config.json?

On macOS it is `~/Library/Application Support/Claude/claude_desktop_config.json`, and on Windows `%APPDATA%\Claude\claude_desktop_config.json`. Open it from Settings > Developer > Edit Config.

### How do I pass an API key to an MCP server in Claude Desktop?

Put it in the server's `env` object in the config file, or install a Desktop Extension whose manifest marks the field `sensitive` so it is kept in the OS secure store. Restart Claude Desktop after editing the file.

### Does Claude Desktop read CLAUDE.md or AGENTS.md?

The documentation reviewed describes no project instructions file for Claude Desktop; project instructions belong to Claude Code.

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

Don't put the key in the prompt, in a file Claude Desktop 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://modelcontextprotocol.io/docs/develop/connect-local-servers
- https://support.claude.com/en/articles/10949351-getting-started-with-local-mcp-servers-on-claude-desktop
- https://www.infosecurity-magazine.com/news/zeroclick-flaw-claude-dxt/
- https://www.esecurityplanet.com/de/threats/news-promptjacking-ai/
