Environment
- OS: Windows 11 Pro 10.0.26200
- Node.js: v24.14.1
- Claude Code: v2.1.133
- Package version: @notionhq/notion-mcp-server v2.2.1
- Notion API token: Valid integration token (verified via direct curl to api.notion.com)
Summary
When the MCP server is spawned by Claude Code on Windows, NOTION_TOKEN (and OPENAPI_MCP_HEADERS) environment variables are not being read correctly, resulting in all Notion API calls returning 401 Unauthorized.
The same configuration and token work perfectly when the server is started from bash/command line, both via stdio and HTTP transport.
Steps to Reproduce
Working: Manual bash test
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"API-get-self"}}' | NOTION_TOKEN="ntn_****" npx -y @notionhq/notion-mcp-server
# Result: ✅ Returns user info correctly
Working: HTTP transport manual test
NOTION_TOKEN="ntn_****" npx -y @notionhq/notion-mcp-server --transport http --port 3339 --auth-token "test"
# Then curl to /mcp endpoint → ✅ Works
Broken: Claude Code spawn (stdio)
{
"mcpServers": {
"notion": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@notionhq/notion-mcp-server"],
"env": {
"NOTION_TOKEN": "ntn_****"
}
}
}
}
Result: API-get-self → 401 Unauthorized: API token is invalid
Broken: Claude Code spawn (HTTP transport)
{
"mcpServers": {
"notion": {
"type": "http",
"url": "http://localhost:3339/mcp",
"headers": {
"Authorization": "Bearer test"
}
}
}
}
Result: API-get-self → 401 Unauthorized: API token is invalid
(HTTP server started with NOTION_TOKEN set correctly)
Testing Done
Configurations tried (ALL fail through Claude Code, ALL work manually):
npx.cmd + NOTION_TOKEN env var
node.exe + --require setup script (sets process.env.NOTION_TOKEN)
node.exe + npx-cli.js directly (bypasses .cmd batch file)
- HTTP transport (server runs independently with env var)
- Both
NOTION_TOKEN and OPENAPI_MCP_HEADERS env vars
- Package versions v2.2.1 and v1.4.0
Ruled out:
- Token validity (direct curl to api.notion.com works)
- Env var name (all documented names tested)
- npx.cmd batch file interference (bypassed with node.exe directly)
- Transport type (both stdio and HTTP fail)
- Global env var passing (other MCP servers work with env vars via Claude Code on the same machine)
- Empty env (
{}) causing process issues
Expected Behavior
NOTION_TOKEN env var should be read correctly when the MCP server is spawned by Claude Code on Windows, same as when spawned from bash.
Actual Behavior
All Notion API calls return 401 Unauthorized: API token is invalid regardless of transport type or configuration approach.
Additional Context
Other MCP servers (nocodb-cloud, postgres-local, n8n-local) configured in the same Claude Code instance with env vars work correctly, proving Claude Code's env var passing mechanism is functional.
Possible Clue
The process.env.NOTION_TOKEN may be accessible during module initialization (tools/list works) but becomes unavailable or empty when the OpenAPI MCP wrapper makes HTTP requests to the Notion API. This could be related to how the OpenAPI MCP framework resolves security schemes in a child process context on Windows.
Environment
Summary
When the MCP server is spawned by Claude Code on Windows,
NOTION_TOKEN(andOPENAPI_MCP_HEADERS) environment variables are not being read correctly, resulting in all Notion API calls returning401 Unauthorized.The same configuration and token work perfectly when the server is started from bash/command line, both via stdio and HTTP transport.
Steps to Reproduce
Working: Manual bash test
Working: HTTP transport manual test
Broken: Claude Code spawn (stdio)
{ "mcpServers": { "notion": { "type": "stdio", "command": "npx", "args": ["-y", "@notionhq/notion-mcp-server"], "env": { "NOTION_TOKEN": "ntn_****" } } } }Result:
API-get-self→401 Unauthorized: API token is invalidBroken: Claude Code spawn (HTTP transport)
{ "mcpServers": { "notion": { "type": "http", "url": "http://localhost:3339/mcp", "headers": { "Authorization": "Bearer test" } } } }Result:
API-get-self→401 Unauthorized: API token is invalid(HTTP server started with
NOTION_TOKENset correctly)Testing Done
Configurations tried (ALL fail through Claude Code, ALL work manually):
npx.cmd+NOTION_TOKENenv varnode.exe+--requiresetup script (setsprocess.env.NOTION_TOKEN)node.exe+npx-cli.jsdirectly (bypasses.cmdbatch file)NOTION_TOKENandOPENAPI_MCP_HEADERSenv varsRuled out:
{}) causing process issuesExpected Behavior
NOTION_TOKENenv var should be read correctly when the MCP server is spawned by Claude Code on Windows, same as when spawned from bash.Actual Behavior
All Notion API calls return
401 Unauthorized: API token is invalidregardless of transport type or configuration approach.Additional Context
Other MCP servers (nocodb-cloud, postgres-local, n8n-local) configured in the same Claude Code instance with env vars work correctly, proving Claude Code's env var passing mechanism is functional.
Possible Clue
The
process.env.NOTION_TOKENmay be accessible during module initialization (tools/list works) but becomes unavailable or empty when the OpenAPI MCP wrapper makes HTTP requests to the Notion API. This could be related to how the OpenAPI MCP framework resolves security schemes in a child process context on Windows.