Support Authorization Server Metadata with path insertion and endpoints on subpaths #1095
+37
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #167
This PR adds support for Authorization Server Metadata with path insertion and endpoints on subpaths
One might not want to run their authorization server on the root of their domain (like
https://api.example.com) but instead run it on a path (https://api.example.com/oauth)How Has This Been Tested?
simpleOAuthClient.tsnow works properly with theDEFAULT_SERVER_URL(http://localhost:3000/mcp) if testing on a mcpAuthRouterBreaking Changes
If the user has configured their
mcpAuthRouterwith aissuerUrlorbaseUrlthat contains a path (likehttps://localhost/path), endpoints will now be setup athttps://localhost/path/authorizeinstead ofhttps://localhost/authorizelike it works right now, even if the user has set a path.Types of changes
Checklist
Additional context
I used https://modelcontextprotocol.io/specification/draft/basic/authorization#authorization-server-metadata-discovery as a reference along with my observations of my own implementation of the MCP OAuth spec