MCP server not receiving environment variables from mcp_settings.json
Description
Environment variables defined in ~/.claude/mcp_settings.json are not being passed to MCP server processes. The Notion MCP server consistently returns 401 Unauthorized despite valid token configuration.
Steps to Reproduce
- Install Notion MCP server globally:
``bash``
npm install -g @notionhq/notion-mcp-server@2.1.0
- Configure
~/.claude/mcp_settings.json:
``json``
{
"mcpServers": {
"notion": {
"command": "/opt/homebrew/bin/notion-mcp-server",
"args": [],
"env": {
"NOTION_TOKEN": "ntn_xxxxx"
}
}
}
}
- Restart Claude Code
- Use any Notion MCP tool (e.g.,
mcp__notion__API-post-search)
- Result:
{"status":401,"object":"error","code":"unauthorized","message":"API token is invalid."}
Expected Behavior
The NOTION_TOKEN environment variable should be passed to the MCP server process, and Notion API calls should authenticate successfully.
Actual Behavior
The MCP server receives no authentication token, resulting in 401 errors on every API call.
Verification That Token Is Valid
The same token works correctly via direct curl:
curl -X POST "https://api.notion.com/v1/search" \
-H "Authorization: Bearer ntn_xxxxx" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"query":"test"}'
# Returns valid search results
Attempted Workarounds (All Failed)
| Approach | Result |
|----------|--------|
| NOTION_TOKEN in env block | 401 |
| OPENAPI_MCP_HEADERS in env block | 401 |
| Both env vars combined | 401 |
| npx with -y flag | 401 |
| Direct binary path | 401 |
| Wrapper shell script with export | 401 |
| Different package versions (latest, 2.1.0) | 401 |
Environment
- OS: macOS (Darwin 25.3.0)
- Claude Code version: Latest (as of Feb 2026)
- Node.js: Current LTS
- MCP Server: @notionhq/notion-mcp-server@2.1.0
Additional Context
The Notion MCP server's --help confirms it expects NOTION_TOKEN as an environment variable:
Environment Variables:
NOTION_TOKEN Notion integration token (recommended)
OPENAPI_MCP_HEADERS JSON string with Notion API headers (alternative)
The server source code shows it correctly reads these env vars in parseHeadersFromEnv(), so the issue appears to be that Claude Code is not passing the configured env vars to the spawned process.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗