401 Unauthorized: API token is invalid (Notion MCP in Claude Code)
Fixes the Notion MCP server 401ing in Claude Code with a token that works elsewhere. Use when the same token succeeds in the Notion API directly. Not for unshared pages or remote SSE setups.
401 Unauthorized: API token is invalid (Notion MCP in Claude Code)
TL;DR: The token is valid; Claude Code is not passing it to the server process, so Notion sees no auth. Put the token in the MCP config env block for the notion server, not just your shell profile. Restart Claude Code so the server relaunches with the env var set.
The error
401 Unauthorized: API token is invalid.Fix it
- Open your Claude Code MCP config and find the notion server entry.
Expected: The env block is missing the token or has it under a wrong name.
- Add the token to the env block with the exact variable name the server expects.
Expected: The config now carries the token.
- Fully restart Claude Code.
Expected: The notion server process starts with the token in its environment.
- Call a Notion tool.
Expected: It returns data instead of 401.
When this applies
Notion MCP 401s in Claude Code with API token is invalid while the same token works in curl or another client.
When this does NOT apply
If curl also 401s, the token is wrong; regenerate it. Remote SSE invalid_token is a different endpoint problem.
Tool compatibility
makenotion/notion-mcp-server (@notionhq/notion-mcp-server) in Claude Code
Also seen as
- Notion MCP Claude Code unauthorized
- API token is invalid notion MCP
- notion MCP env not passed
Why it happens
MCP servers inherit env only from the client config's env block. A token exported in your shell never reaches the server Claude Code spawns, so every Notion API call goes out unauthenticated and Notion 401s.
Edge cases
- The variable name differs between server forks; match the README exactly.
- Restart the whole client, not just the conversation; the server process persists.
- Tokens starting with secret_ are internal integration tokens and are the right kind.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.