Skip to content

Fix OAuth metadata validation for compliant servers #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jalehman
Copy link

@jalehman jalehman commented May 21, 2025

Motivation and Context

The OAuth metadata validation was overly restrictive, causing connection failures with
compliant MCP servers like Asana that support multiple OAuth authentication methods.
The validation rejected servers advertising additional authentication methods beyond
the minimum required set, even though these methods are allowed by both the MCP and
OAuth 2.0 specifications.

Specifically, servers returning:

  • token_endpoint_auth_methods_supported:
    ["client_secret_basic","client_secret_post","none"]
  • code_challenge_methods_supported: ["plain","S256"]

Were rejected because the client only accepted a limited subset of these methods.

How Has This Been Tested?

  • ✅ Successfully tested connection to https://mcp.asana.com/sse
  • ✅ OAuth flow completes without validation errors
  • ✅ Verified backward compatibility with existing servers
  • ✅ All existing tests continue to pass

Breaking Changes

No - this change maintains backward compatibility while expanding support for
additional compliant servers.

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

Changes made:

  • Added client_secret_basic to allowed token_endpoint_auth_methods_supported
  • Added plain to allowed code_challenge_methods_supported

Compliance:

  • ✅ MCP Specification: The [MCP authorization specification](https://modelcontextprot
    ocol.io/specification/2025-03-26/basic/authorization.md) requires PKCE support but
    doesn't restrict which authentication methods servers can advertise
  • ✅ OAuth 2.0: These are standard OAuth 2.0 authentication methods defined in
    relevant RFCs

This fix enables the MCP Python SDK to work with any compliant MCP server regardless
of which optional OAuth authentication methods they advertise.

The OAuthMetadata validation was too restrictive, rejecting valid OAuth 2.0
server configurations that advertise additional authentication methods beyond
the minimum required set.

Changes:
- Allow 'client_secret_basic' in token_endpoint_auth_methods_supported
- Allow 'plain' in code_challenge_methods_supported

This fixes compatibility with MCP servers like Asana (mcp.asana.com) that
advertise support for multiple OAuth authentication methods as allowed by
the OAuth 2.0 specification and MCP specification.

The MCP specification does not restrict which authentication methods servers
can support, only requiring that PKCE is used. These changes ensure the
client can connect to any compliant MCP server regardless of which optional
authentication methods they also support.
@SightStudio
Copy link

SightStudio commented Jun 4, 2025

Does anyone know why this isn’t being actively discussed?

I couldn’t find any documentation mentioning that this isn’t supported

I only found out by digging through the source code.

cc @dsp-ant

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.

3 participants