claude-code - 💡(How to fix) Fix Notion MCP OAuth fails with "Invalid redirect_uri for OAuth client" [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52961Fetched 2026-04-25 06:16:07
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
3
Timeline (top)
labeled ×5commented ×2cross-referenced ×1subscribed ×1

Authenticating the hosted Notion MCP server (https://mcp.notion.com/mcp) via /mcp in Claude Code fails with an "Invalid redirect_uri for OAuth client" error returned from Notion's OAuth server. Authentication never completes.

Error Message

Authenticating the hosted Notion MCP server (https://mcp.notion.com/mcp) via /mcp in Claude Code fails with an "Invalid redirect_uri for OAuth client" error returned from Notion's OAuth server. Authentication never completes.

Root Cause

Root cause (from Claude Code debug logs)

Claude Code uses a fixed client_id (a claude.ai-hosted client metadata URL) combined with a randomly-picked localhost callback port. Notion's OAuth server validates the submitted redirect_uri against the metadata document's allowlist and rejects because the random localhost port isn't listed.

Fix Action

Fix / Workaround

Workarounds tried

  • Re-running /mcp — fails with a new random port each time
  • claude update — already on latest
  • Different browser (Brave → Chrome) — identical failure, confirms server-side rejection
  • Falling back to @notionhq/notion-mcp-server with an internal integration token — blocked for users whose Notion workspace restricts integration creation to owners

Code Example

Authorization URL: https://mcp.notion.com/authorize
  ?response_type=code
  &client_id=https%3A%2F%2Fclaude.ai%2Foauth%2Fclaude-code-client-metadata
  &code_challenge=[REDACTED]
  &code_challenge_method=S256
  &redirect_uri=http%3A%2F%2Flocalhost%3A55564%2Fcallback
  &state=[REDACTED]
  &resource=https%3A%2F%2Fmcp.notion.com%2Fmcp
RAW_BUFFERClick to expand / collapse

Description

Authenticating the hosted Notion MCP server (https://mcp.notion.com/mcp) via /mcp in Claude Code fails with an "Invalid redirect_uri for OAuth client" error returned from Notion's OAuth server. Authentication never completes.

Environment

  • Claude Code version: 2.1.119 (latest as of filing)
  • OS: macOS 15 (Darwin 24.6.0)
  • Install: ~/.local/bin/claude
  • Browsers tried: Brave, Chrome — both fail identically (rules out browser shields / extensions)

Steps to reproduce

  1. claude mcp add --transport http notion https://mcp.notion.com/mcp
  2. /mcp → select Notion → Authenticate
  3. Browser opens the Notion authorize URL
  4. Complete Notion login → Notion rejects with Invalid redirect_uri for OAuth client before redirecting back to localhost

Root cause (from Claude Code debug logs)

Claude Code uses a fixed client_id (a claude.ai-hosted client metadata URL) combined with a randomly-picked localhost callback port. Notion's OAuth server validates the submitted redirect_uri against the metadata document's allowlist and rejects because the random localhost port isn't listed.

From ~/Library/Caches/claude-cli-nodejs/<cwd>/mcp-logs-notion/<timestamp>.jsonl:

Authorization URL: https://mcp.notion.com/authorize
  ?response_type=code
  &client_id=https%3A%2F%2Fclaude.ai%2Foauth%2Fclaude-code-client-metadata
  &code_challenge=[REDACTED]
  &code_challenge_method=S256
  &redirect_uri=http%3A%2F%2Flocalhost%3A55564%2Fcallback
  &state=[REDACTED]
  &resource=https%3A%2F%2Fmcp.notion.com%2Fmcp

The port is randomized per attempt (observed 55564, 60330, etc.). The log also shows "No client info found" immediately prior, suggesting Dynamic Client Registration (RFC 7591) was expected but skipped — the static claude.ai client is being reused instead of registering a fresh one.

Expected behavior

Either:

  • (a) Perform DCR against Notion's authorization server to register a fresh client with the current localhost callback, or
  • (b) Update the claude-code-client-metadata document's redirect_uris to include wildcard localhost entries that Notion will accept.

Workarounds tried

  • Re-running /mcp — fails with a new random port each time
  • claude update — already on latest
  • Different browser (Brave → Chrome) — identical failure, confirms server-side rejection
  • Falling back to @notionhq/notion-mcp-server with an internal integration token — blocked for users whose Notion workspace restricts integration creation to owners

Notes

Notion's connector works fine in the Claude Desktop app (different OAuth client / fixed redirect URI), so the issue is specific to the Claude Code CLI's OAuth flow against mcp.notion.com.

extent analysis

TL;DR

The most likely fix is to update the claude-code-client-metadata document's redirect_uris to include wildcard localhost entries that Notion will accept, or perform Dynamic Client Registration (DCR) against Notion's authorization server.

Guidance

  • Verify that the redirect_uri in the authorization URL matches the expected format and is included in the redirect_uris list of the claude-code-client-metadata document.
  • Check if Notion's OAuth server supports wildcard localhost entries in the redirect_uris list, and update the document accordingly.
  • Consider implementing Dynamic Client Registration (DCR) as per RFC 7591 to register a fresh client with the current localhost callback.
  • Review the Claude Code CLI's OAuth flow to ensure it aligns with Notion's expected authentication process.

Example

No code snippet is provided as the issue is related to the OAuth flow and client registration, which requires a deeper understanding of the Claude Code CLI's implementation.

Notes

The issue is specific to the Claude Code CLI's OAuth flow against mcp.notion.com, and the Notion connector works fine in the Claude Desktop app with a different OAuth client and fixed redirect URI.

Recommendation

Apply a workaround by updating the claude-code-client-metadata document's redirect_uris to include wildcard localhost entries that Notion will accept, as this is a more feasible solution than implementing DCR.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Either:

  • (a) Perform DCR against Notion's authorization server to register a fresh client with the current localhost callback, or
  • (b) Update the claude-code-client-metadata document's redirect_uris to include wildcard localhost entries that Notion will accept.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Notion MCP OAuth fails with "Invalid redirect_uri for OAuth client" [2 comments, 3 participants]