Skip to content

Commit 795bcb8

Browse files
committed
fix: strip trailing slash from resource URL in get_resource_url()
Pydantic v2 AnyHttpUrl adds a trailing slash to bare-domain URLs when str() is called, causing audience mismatch with Entra ID v2.0 which registers the resource without a trailing slash. Fixes #2578
1 parent 161834d commit 795bcb8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/mcp/client/auth/oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def get_resource_url(self) -> str:
151151

152152
# If PRM provides a resource that's a valid parent, use it
153153
if self.protected_resource_metadata and self.protected_resource_metadata.resource:
154-
prm_resource = str(self.protected_resource_metadata.resource)
154+
prm_resource = str(self.protected_resource_metadata.resource).rstrip("/")
155155
if check_resource_allowed(requested_resource=resource, configured_resource=prm_resource):
156156
resource = prm_resource
157157

0 commit comments

Comments
 (0)