MCP config shows false positive environment variable warnings despite vars being set and servers working

Resolved 💬 3 comments Opened Nov 23, 2025 by Jstyle1 Closed Jan 23, 2026

Description

Claude Code shows warnings about missing environment variables for MCP servers even when:

  1. The variables ARE set in the shell environment
  2. The MCP servers work correctly and return data

Environment

  • macOS Darwin 25.1.0
  • Claude Code (Haiku 4.5)
  • Variables loaded from macOS Keychain via shell profile

Reproduction Steps

  1. Set env vars in .zshrc with Keychain lookups: export META_ACCESS_TOKEN="$(security find-generic-password -s 'service' -a 'account' -w)"
  2. Configure .mcp.json with env var references: "env": {"META_ACCESS_TOKEN": "${env:META_ACCESS_TOKEN}"}
  3. Verify vars are set: echo $META_ACCESS_TOKEN shows value
  4. Start Claude Code
  5. Warning appears: [Warning] [meta-ads] mcpServers.meta-ads: Missing environment variables: env:META_ACCESS_TOKEN, env:META_APP_ID, env:META_APP_SECRET
  6. Despite warning, MCP tools work: mcp__meta-ads__get_ad_accounts returns valid ad account data

Expected Behavior

No warning should appear when environment variables are set and accessible to MCP servers (which clearly have access since they work).

Suspected Root Cause

Claude Code's config validation may run in a subprocess or initialization context that doesn't fully inherit shell environment variables, even though the MCP servers themselves have full access to those variables when they execute later.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗