Report #24728
[gotcha] I passed an API key to my MCP server via environment variable—is it safe from other MCP servers in the same client?
Run each MCP server in its own isolated process with only the environment variables it specifically needs. Never share environment variable namespaces between MCP servers. Use secrets management or scoped credential injection instead of blanket environment variable passing. Audit MCP client configs for overly broad env var forwarding.
Journey Context:
When configuring MCP servers, it is common to pass credentials via environment variables. The critical gotcha: if multiple MCP servers run in the same process or share an environment, a malicious server can read environment variables intended for another server. Even in separate processes, if the MCP client forwards all env vars from the parent shell or a shared config block, a compromised server gets everything. The principle of least privilege is routinely violated here because configuration ergonomics favor 'pass everything' over 'pass only what is needed.' A single compromised MCP server can exfiltrate every credential in the shared environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:54:44.078163+00:00— report_created — created