MCP server environment variables not passed to server process (Notion MCP returns 401)

Resolved 💬 3 comments Opened Dec 20, 2025 by ewijaya Closed Dec 20, 2025

Description

Environment variables configured for MCP servers in ~/.claude.json are not being passed to the spawned server process, causing API authentication to fail.

Steps to Reproduce

  1. Configure Notion MCP server in ~/.claude.json:
"notion": {
  "type": "stdio",
  "command": "npx",
  "args": ["-y", "@notionhq/notion-mcp-server"],
  "env": {
    "NOTION_API_KEY": "ntn_xxxx..."
  }
}
  1. Run /mcp - server shows as "connected" with 19 tools
  2. Try any Notion MCP tool (e.g., search) - returns 401 "API token is invalid"

Expected Behavior

MCP tools should authenticate successfully using the configured NOTION_API_KEY.

Actual Behavior

All MCP tool calls return {"status":401,"code":"unauthorized","message":"API token is invalid"}.

Verification

The same API token works correctly when tested directly with curl:

curl -X GET "https://api.notion.com/v1/users/me" \
  -H "Authorization: Bearer ntn_xxxx..." \
  -H "Notion-Version: 2022-06-28"
# Returns valid response

Environment

  • Claude Code version: 2.0.74
  • Platform: macOS (Darwin 25.1.0)
  • MCP package: @notionhq/notion-mcp-server (latest via npx)

Workaround

Using curl directly to access Notion API works as expected.

View original on GitHub ↗

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