# 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

1. 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.
2. Add the token to the env block with the exact variable name the server expects.
   Expected: The config now carries the token.
3. Fully restart Claude Code.
   Expected: The notion server process starts with the token in its environment.
4. 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.