Skip to content

Skip SSE fallback when OAuth is active#57

Open
redaphid wants to merge 1 commit intosteipete:mainfrom
redaphid:fix/skip-sse-fallback-after-oauth
Open

Skip SSE fallback when OAuth is active#57
redaphid wants to merge 1 commit intosteipete:mainfrom
redaphid:fix/skip-sse-fallback-after-oauth

Conversation

@redaphid
Copy link

@redaphid redaphid commented Feb 4, 2026

Summary

  • When a server returns 401 and OAuth promotion occurs, the server has already proven it speaks Streamable HTTP (POST). Falling back to SSE (GET) after OAuth fails with 405 or a fresh unresolvable 401.
  • This adds a guard in createClientContext to skip the SSE fallback path when activeDefinition.auth === 'oauth', re-throwing the original error instead.
  • Adds a test verifying SSE fallback is skipped when OAuth is active.

Fixes #38
Fixes #47

Test plan

  • New test: does not fall back to SSE when OAuth is active — verifies only StreamableHTTP is attempted and the error propagates
  • Existing test: falls back to SSE when primary connect fails — still passes (non-OAuth path unchanged)
  • Full test suite: 377 passed, 5 skipped, 1 pre-existing failure in daemon integration (stale dist build, unrelated)

🤖 Generated with Claude Code

When a server returns 401 and OAuth promotion occurs, the server has
already proven it speaks Streamable HTTP (POST). Falling back to SSE
(GET) after OAuth fails with 405 Method Not Allowed or a fresh 401
that can never be resolved.

Skip the SSE fallback path when the active definition has auth set
to oauth, and re-throw the original error instead.

Fixes steipete#38
Fixes steipete#47

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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: 84ae561d9e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +169 to +171
if (activeDefinition.auth === 'oauth') {
await oauthSession?.close().catch(() => {});
throw primaryError;

Choose a reason for hiding this comment

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

P2 Badge Avoid skipping SSE fallback based on auth alone

activeDefinition.auth === 'oauth' is used here to skip SSE fallback for any primary error, but auth only describes the auth mechanism, not the transport (there’s no transport field in ServerDefinition). That means an OAuth‑protected server that only exposes SSE (e.g., a POST returning 405 or a network error on the streamable endpoint) will now fail permanently instead of falling back to SSE, even though SSE may be the only supported transport. Consider gating this on a confirmed streamable‑HTTP 401 (or another capability signal) rather than the auth flag alone.

Useful? React with 👍 / 👎.

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.

OAuth retry fails with 405 for Todoist MCP server Notion MCP: SSE error 401 on auth attempt

1 participant