Skip to content

Conversation

@jnjpng
Copy link

@jnjpng jnjpng commented Oct 21, 2025

Accept HTTP 201 status code in addition to 200 for successful OAuth token exchanges.

Motivation and Context

Fixes #1502, some OAuth servers (like Supabase) return 201 Created instead of 200 OK for successful token exchanges. The OAuth 2.0 spec doesn't mandate a specific success status code, so we should accept both 200 and 201.

How Has This Been Tested?

Tested locally against remote MCP servers that return this status code, and ran the tests specified in the contribution guide.
image

Breaking Changes

No.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Fixes modelcontextprotocol#1502

Some OAuth servers (like Supabase) return 201 Created instead of 200 OK
for successful token exchanges. The OAuth 2.0 spec doesn't mandate a
specific success status code, so we should accept both 200 and 201.
@jnjpng jnjpng force-pushed the fix-oauth-token-status-codes branch from 3c482be to 27d1566 Compare October 21, 2025 19:09
@felixweinberger felixweinberger added bug Something isn't working auth Issues and PRs related to Authentication / OAuth enhancement New feature or request and removed bug Something isn't working labels Oct 24, 2025
Copy link
Member

@pcarleton pcarleton left a comment

Choose a reason for hiding this comment

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

change looks good, can you please add a test?

@felixweinberger felixweinberger added the needs more work Not ready to be merged yet, needs additional changes. label Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Issues and PRs related to Authentication / OAuth enhancement New feature or request needs more work Not ready to be merged yet, needs additional changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_handle_token_response should accept 201 responses

3 participants