swiftapplications

MCP on macOS

MCP security: where credentials leak and how to keep keys out of config

The four places MCP credentials leak on a Mac (config files, process environments, model context, logs) and how to design servers so agents never hold keys.

Updated 8 October 2026 3 min read

The short answer

MCP credentials leak in four places: plain-text config files, the environment of the server process, the model’s context when a tool echoes a secret, and logs. The fix is architectural: one local server holds the keys, the agent gets results and never credentials, sensitive values come back as tokens, and changes become proposals a person approves.

Where keys leak

  • Config files. env blocks in claude_desktop_config.json, mcp.json or config.toml are plain text.
  • Process environment. A server started with a key in its environment exposes it to anything that can inspect that process as you.
  • Model context. A tool that returns a config or an error with a token in it puts the token into the conversation, and into the provider’s logs.
  • Logs. Debug logging of requests often includes the Authorization header.

Design so agents never hold keys

  1. One local server holds the credentials, in the Keychain or a vault, not in config.
  2. Tools return results, never secrets; error messages are scrubbed.
  3. Customer names, emails and addresses come back as tokens the agent can pass around but not read.
  4. Reads are open; writes become proposals with a human approval.
  5. Every call and decision is logged locally.

The safe way to do this

MoltenRock Connect

One local MCP server for 30 business platforms

Connect holds every key; your agents read Stripe, Shopify and 28 more over MCP and never see one. On Stripe they can only propose, and you approve with Touch ID.

Get MoltenRock Connect

Questions developers ask

Is it safe to put API keys in claude_desktop_config.json?

No. It’s plain text in your home folder. Use servers that hold their own credentials.

Can an MCP server leak my API key to the model?

Yes, if a tool returns it in a result or an error. Servers should never return credentials.

What is the safest way to give an agent access to Stripe?

Through a server that holds the key, lets the agent read, and turns refunds and other changes into proposals you approve.