Skip to content

Conversation

olaservo
Copy link
Member

@olaservo olaservo commented Aug 20, 2025

Resolves a regression introduced in PR #715 and reported in #726 where the OAuth flow always chose client_secret_post regardless of the server's token_endpoint_auth_methods_supported setting.

Motivation and Context

  • PR fweinberger/fix sensitive local storage #715 removed client_secret from sessionStorage for security reasons
  • This broke the MCP SDK's ability to determine the correct authentication method
  • OAuth flows with servers requiring client_secret_basic would fail

How Has This Been Tested?

Added tests but still needs testing with real flow through UI.

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

…lcontextprotocol#726)

This commit resolves a regression introduced in PR modelcontextprotocol#715 where the OAuth flow
always chose client_secret_post regardless of the server's
token_endpoint_auth_methods_supported setting.

## Problem
- PR modelcontextprotocol#715 removed client_secret from sessionStorage for security reasons
- This broke the MCP SDK's ability to determine the correct authentication method
- OAuth flows with servers requiring client_secret_basic would fail

## Solution
- Added temporary in-memory storage for client_secret during OAuth flow
- client_secret is stored temporarily when saveClientInformation() is called
- client_secret is provided to the SDK when clientInformation() is called
- client_secret is cleared from memory after successful token exchange or clear()
- client_secret is never persisted to sessionStorage (maintains security)

## Testing
- Added comprehensive tests for temporary client_secret handling
- Verified client_secret is available during OAuth flow
- Verified client_secret is not stored in sessionStorage
- Verified client_secret is cleared after token exchange
- All existing tests continue to pass

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Member

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

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

Tested locally, using the Typescript SDK example.

 tsx --watch src/examples/server/simpleStreamableHttp.ts --oauth

In the AS metadata, token_endpoint_auth_methods_supported is client_secret_post
Screenshot 2025-08-20 at 5 23 26 PM

However, I did not see the client_secret in the subsequent POST to the /token endpoint.
Screenshot 2025-08-20 at 5 35 09 PM

On the upside, it does not appear that client_secret was stored in localstorage.
Screenshot 2025-08-20 at 5 25 16 PM

Ultimately, connection was successful. However I'm not certain that the token endpoint was enforcing the requirement for a client_secret to appear in that post.
Screenshot 2025-08-20 at 5 38 29 PM

I went to the original issue #726 and used the Flask server that was failing to test with. See my comment there for details.

@olaservo
Copy link
Member Author

Closing this for now since the original issue is still reproducible with this branch.

@olaservo olaservo closed this Aug 21, 2025
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.

2 participants