You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit de24644
Browse filesBrowse the repository at this point in the historyBrowse files
test(client): pin pathless PRM resource end to end, document selectResourceURL normalization (modelcontextprotocol#1968)
- auth.test.ts: drive auth() with PRM `resource: https://example.com` and assert the
authorization redirect and the authorization-code token exchange both carry it
without a trailing slash (fails on main with 'https://example.com/')
- auth.ts: JSDoc on selectResourceURL explaining that it returns a parsed URL and that
auth() sends the metadata string verbatim; comment at the decision site in auth()
- changeset: describe the trailing-slash normalization, the Entra rejection, the
widened `resource` inputs, and that selectResourceURL's signature is unchanged
Copy file name to clipboardExpand all lines: .changeset/plenty-plums-sip.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,4 @@
2
2
'@modelcontextprotocol/client': patch
3
3
---
4
4
5
-
Preserve exact OAuth resource indicators from protected resource metadata.
5
+
Preserve the exact OAuth resource indicator from protected resource metadata when building authorization and token requests. Previously a pathless `resource` such as `https://example.com` was normalized to `https://example.com/` via `URL.href`, which breaks authorization servers that require the `resource` parameter to match the published value exactly (Microsoft Entra ID rejects it with `AADSTS9010010`). The exported OAuth helpers (`startAuthorization`, `exchangeAuthorization`, `refreshAuthorization`, `fetchToken`, `executeTokenRequest`) now also accept a `string` for `resource`; `selectResourceURL` still returns a `URL`, and a provider's `validateResourceURL` result is used unchanged. Fixes #1968.
// Send the metadata's resource indicator verbatim: `selectResourceURL` returns a parsed
1247
+
// `URL`, and `URL.href` appends "/" to a pathless indicator such as `https://example.com`,
1248
+
// which exact-match authorization servers reject (#1968). A URL returned by the
1249
+
// provider's own `validateResourceURL` is used as returned.
@@ -1462,6 +1466,17 @@ export function isHttpsUrl(value?: string): boolean {
1462
1466
}
1463
1467
}
1464
1468
1469
+
/**
1470
+
* Selects the RFC 8707 resource indicator for an MCP server: the provider's
1471
+
* {@linkcode OAuthClientProvider.validateResourceURL | validateResourceURL} result when
1472
+
* implemented, otherwise the protected resource metadata's `resource` (checked against the
1473
+
* server URL with `checkResourceAllowed`), or `undefined` when there is no metadata.
1474
+
*
1475
+
* The result is a parsed `URL`, so a pathless indicator such as `https://example.com` has
1476
+
* the `href` `https://example.com/`. {@linkcode auth} therefore sends the metadata string
1477
+
* verbatim instead of this URL's `href` (#1968); callers that emit the `resource`
it('sends a pathless PRM resource verbatim on the authorization and token requests (#1968)',async()=>{
3371
+
// RFC 9728 publishes the resource identifier and RFC 8707 requires it to be
3372
+
// sent unchanged. `new URL('https://example.com').href` is 'https://example.com/',
3373
+
// and authorization servers that match the indicator exactly (Microsoft Entra
0 commit comments