FeaturesPricingFAQMCPSecurityAffiliatesContact

MCP & Agents

How MCP Servers Leak Your API Keys — and How to Fix It

MCP turned every AI coding tool into an API caller — and put your keys in a new kind of config file. In 2025, researchers found 24,008 unique secrets exposed in MCP configuration files. Here is how that happens and how to stop it.

Why MCP setups leak keys

MCP (Model Context Protocol) is the open standard that lets assistants such as Claude Code, Cursor, and Windsurf call external APIs through small local servers. To call a provider — GitHub, Stripe, a database, an LLM API — that MCP server needs a credential. In practice, the credential is almost always a plaintext API key written into a JSON config file on your machine.

That file gets copied into dotfiles repos, committed by accident, synced to personal cloud drives, pasted into screenshots and issues, or simply read by any process on the machine. The secret is no longer secret the moment it lands in a file that travels.

From the data: the API Key Exposure Report 2026 records 24,008 unique secrets in MCP configuration files, including Google API keys (19.2%), PostgreSQL connection strings (14%), Firecrawl keys (11.9%), and Perplexity.ai keys (11.2%). See the full report →

How the leak actually happens

  1. Hardcoding. The key is pasted straight into the MCP server block or an .env that the config references.
  2. Accidental commit. Config files live next to code. One git add . and the key is public forever — history is hard to purge.
  3. Tool sprawl. The same real key gets copied into four tools' configs, multiplying the exposure surface.
  4. No rotation. Even after a leak, most keys are never revoked — the report found 64% of valid 2022 secrets were still unrevoked in 2026.

The fix: the safe_key pattern

The problem is architectural, so the fix is too: the agent should never hold a real key at all. ProphetKey runs a local MCP server on 127.0.0.1. When an agent asks for a key, it receives a safe_key — a placeholder that identifies which vault entry to use. When the agent makes the actual API request, ProphetKey injects the real key on your device, forwards the request, and records the usage.

# Claude / Cursor / Windsurf MCP config { "mcpServers": { "prophetkey": { "command": "npx", "args": ["-y", "prophetkey-mcp"] } } }
What the agent sees: a safe_key and a list of key names — never a real value. The real key is injected on your device and stays encrypted at rest. See the MCP server →

Checklist: keep MCP keys out of config files

  • Never paste a real key into an MCP or agent config file.
  • Use a local vault + MCP bridge that returns safe_keys instead of secrets.
  • Scan public repos and paste sites for your own keys (leak monitoring).
  • Scope and rotate: give each tool its own virtual key so one leak is replaceable.
  • Assume any key that touched a config file is compromised — rotate it.
ProphetKey is a local-first vault that injects keys through a local proxy and MCP bridge. The agent gets a safe_key; the real key stays encrypted on your device. → Download for Windows

FAQ

What is an MCP server?

MCP (Model Context Protocol) is an open standard that lets AI tools like Claude Code, Cursor, and Windsurf call external tools and APIs. An MCP server exposes those tools to the agent.

Why do MCP configs leak API keys?

Most MCP servers authenticate to upstream APIs with a plaintext API key placed in a JSON config file (for example a Claude or Cursor config). Those files are frequently committed to git, synced to cloud drives, shared in screenshots, or read by the agent itself — all common leak paths.

What is a safe_key?

A safe_key is a placeholder token an AI agent receives instead of the real API key. When the agent makes a request, ProphetKey swaps in the real key on your device and forwards the call. The agent never sees or stores the real credential.

Can I use MCP without giving the agent my real key?

Yes. Run a local MCP server that returns a safe_key to the agent. The real provider key stays encrypted on your machine and is injected only at the moment of the outbound request.

Related

Sources