Skip to content

Conversation

@jlowin
Copy link
Owner

@jlowin jlowin commented Sep 29, 2025

This PR refines the OAuth 2.1 error handling approach from #1923 by using a cleaner TokenHandler subclass instead of wrapping and parsing responses.

Per OAuth 2.1 Section 5.3 and MCP spec requirements, invalid clients must receive HTTP 401.

Note: This replaces the implementation from #1923. The original approach was completely valid and we appreciate the contribution! This refactor just makes the code a bit more maintainable by working at the model layer rather than parsing serialized responses. I think the only operational difference here is maintaining the SDK's use of CORS middleware - I am not sure to what degree this has impact.

@marvin-context-protocol marvin-context-protocol bot added enhancement Improvement to existing functionality. For issues and smaller PR improvements. server Related to FastMCP server implementation or server-side functionality. auth Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server. labels Sep 29, 2025
@jlowin jlowin merged commit d7c6051 into main Sep 29, 2025
12 checks passed
@jlowin jlowin deleted the refactor-oauth-token-handler branch September 29, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server. enhancement Improvement to existing functionality. For issues and smaller PR improvements. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants