Fix `/.well-known/oauth-authorization-server` dropping path by calclavia · Pull Request #687 · modelcontextprotocol/typescript-sdk
This fixes the TS SDK so it properly handles the provided path in the authorizationServerUrl, as per rfc 8414:
https://datatracker.ietf.org/doc/html/rfc8414#section-3
Authorization servers supporting metadata MUST make a JSON document containing metadata as specified in Section 2 available at a path formed by inserting a well-known URI string into the authorization server's issuer identifier between the host component and the path component, if any. By default, the well-known URI string used is "/.well-known/oauth-authorization-server". This path MUST use the "https" scheme. The syntax and semantics of ".well-known" are defined in RFC 5785 [RFC5785]. The well-known URI suffix used MUST be registered in the IANA "Well-Known URIs" registry [IANA.well-known].
Motivation and Context
Without this change, auth servers hosted at a subpath will break.
How Has This Been Tested?
Yes, this is being used at Smithery to handle servers hosted under different subpaths.
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
Relevant reviewer: @ihrpr