Skip to content

Conversation

@sebastian-velten
Copy link

@sebastian-velten sebastian-velten commented Oct 24, 2025

Parsing the token response now depends on the received Content-Type.
This allows the MCP Client to deal with a application/x-www-form-urlencoded token response.

Motivation and Context

I played around with some example OAuth secured MCP servers and I noticed, that not all authorization servers are willing to return the token response as application/json, for instance the Github MCP Server auth server. As a a consequence the auth flow crashed at this point, because the response could not be parsed as OAuthToken from JSON.

How Has This Been Tested?

I ran an MCP Client (also built with this Python SDK) and tried to connect to OAuth secured MCP Servers.
When I tested the Github MCP Server, I was unhappy to see the auth flow crashes. With my suggested code changes, I tested again and authorization went fine this time.

Breaking Changes

No code or configurations need to be updated.

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

@sebastian-velten sebastian-velten force-pushed the url-encoded-token-response branch from 73062e3 to 71f7e39 Compare October 24, 2025 10:44
@felixweinberger felixweinberger added the auth Issues and PRs related to Authentication / OAuth 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants