Skip to content

Fix OAuth 401 handling for config-file servers#46

Open
caseyg wants to merge 2 commits intosteipete:mainfrom
caseyg:fix/oauth-401-config-servers
Open

Fix OAuth 401 handling for config-file servers#46
caseyg wants to merge 2 commits intosteipete:mainfrom
caseyg:fix/oauth-401-config-servers

Conversation

@caseyg
Copy link

@caseyg caseyg commented Jan 31, 2026

Summary

  • Remove the ad-hoc source restriction in maybeEnableOAuth() so any HTTP server returning 401 can be promoted to OAuth mode
  • Previously only servers added via CLI (source.path === '<adhoc>') were eligible, causing config-file servers like Notion to throw a fatal 401 instead of launching the browser OAuth flow
  • Updated test to reflect the new behavior

Fixes #38

Test plan

  • pnpm build passes
  • All 377 tests pass (pnpm test)
  • Manual test: node dist/cli.js auth notion with a Notion config should open browser for OAuth instead of throwing 401

🤖 Generated with Claude Code

Remove the ad-hoc source restriction in maybeEnableOAuth() so that any
HTTP server returning 401 can be promoted to OAuth mode. Previously,
only servers added via ad-hoc CLI (`source.path === '<adhoc>'`) were
eligible, causing config-file servers like Notion to throw a fatal 401
instead of launching the browser OAuth flow.

Fixes steipete#38

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@caseyg
Copy link
Author

caseyg commented Jan 31, 2026

tested manually and verified that it works 👍

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e1dc53813

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Address review feedback: instead of promoting all HTTP servers to OAuth
on 401, probe /.well-known/oauth-protected-resource first for non-ad-hoc
servers. Only promote if the server advertises OAuth support via RFC 9728
metadata. This prevents servers using static headers/PATs from being
incorrectly promoted to OAuth, which would cause 60s timeout stalls.

Ad-hoc servers (CLI-added) still get promoted without probing, matching
the original behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Author

@caseyg caseyg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the review feedback in 9d49ca1. Non-ad-hoc servers now probe /.well-known/oauth-protected-resource (RFC 9728) before promotion. Only servers that advertise authorization_servers in their metadata get promoted to OAuth. Servers using static headers/PATs that return 401 will no longer be incorrectly promoted, avoiding the 60s timeout stall.

Ad-hoc servers (CLI-added) still get promoted without probing, preserving the original behavior.

@caseyg
Copy link
Author

caseyg commented Jan 31, 2026

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@caseyg
Copy link
Author

caseyg commented Jan 31, 2026

Tested this with a local install into my openclaw and can confirm that Notion MCP works now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notion MCP: SSE error 401 on auth attempt

1 participant