Preserve paths when building PRM URL, per specification. #722
+56
−3
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.
Preserves paths and query parameters when making Protected Resource Metdata requests, per section 3.1 of RFC 9728.
Motivation and Context
This is important for security hardening of MCP, ensuring that clients can validate that the resource metadata they are using correlates with the resource they are accessing.
How Has This Been Tested?
We (@keycardlabs) are building an identity and access system for agents, and ensuring that SDKs are implementing the relevant OAuth bits in accordance with specifications.
Unit tests have been supplied.
Breaking Changes
This returns PRM URLs that include path components, whereas before the
getOAuthProtectedResourceMetadataUrl()
function did not. This may be considered a breaking change, but also brings it inline with the specifications.Types of changes
Either a bug fix or a breaking change (or both), depending on perspective.
Checklist
Additional context
There's a discussion about expected behavior on the OAuth mailing list.
As far as I can see, proper validation of resource indicators is very lax in the MCP specification and implementations. This is leading to a number of security vulnerabilities. I've outlined this here, and there's a related issue in the MCP specification.
I'm trying to work with both the specification authors and SDK implementers to improve the security posture of MCP. This PR is part of that effort :).