[v2] Client accepts a parent-path protected resource metadata, is this intended given RFC 9728?
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
- #3169 par @bbdu3 — fermée sans fusion
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 43/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- typescript
- Domaine
- authentication
Piste de recherche
Start with packages/core-internal/src/shared/authUtils.ts, especially selectResourceURL and checkResourceAllowed, then compare the current behavior with RFC 9728 §3.3 and the linked issues #638, #2751, and #3041. The issue asks whether parent-path resources should be accepted and whether any change should allow an opt-in for lenient matching; the expected resolution is a maintainer decision on that behavior and its compatibility implications.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What happened?
Question
Is it intended that the client accepts Protected Resource Metadata (PRM) whose resource is a parent path of the server URL? And if so, how should that be reconciled with RFC 9728 §3.3?
Current behaviour
selectResourceURL validates resourceMetadata.resource with checkResourceAllowed, which accepts any same-origin resource whose path is a prefix of the server URL's path (authUtils.ts). The less specific URL is then returned and sent as the RFC 8707 resource parameter.
Example:
- Server URL:
https://host/mcp/gateway/bundle/my-bundle 401withWWW-Authenticate: Bearer resource_metadata="https://host/mcp/gateway/.well-known/oauth-protected-resource/bundle/my-bundle"- PRM:
{"resource": "https://host/mcp/gateway", ...}
The SDK accepts this and requests a token for https://host/mcp/gateway. VS Code rejects the same metadata (oauth.ts: "Per RFC 9728, these MUST match"), so a server that works with SDK-based clients fails in VS Code.
Why I'm asking
RFC 9728 §3.3:
If the protected resource metadata was retrieved from a URL returned by the protected resource via the WWW-Authenticate resource_metadata parameter, then the resource value returned MUST be identical to the URL that the client used to make the request to the resource server. If these values are not identical, the data contained in the response MUST NOT be used.
§7.3 gives impersonation as the reason for the identical-match rule. The MCP spec adopts RFC 9728 and asks clients to "provide the most specific URI that they can" (2025-11-25, Canonical Server URI).
The prefix matching was introduced in #638. Its description says resource URIs are used as-is "to allow having different MCP servers under different subpaths … w/o spilling their resource authorization to each other". It also warns that a non-specific resource lets a "bad apple" server benefit from resource confusion with its siblings. Accepting a parent-path resource from the PRM seems to allow exactly that: a server at /a/b can get the client to request a token for /a. I couldn't find a rationale for the prefix rule in the PR or its review.
#2751 already notes in passing that this leniency hides non-compliant server setups.
#3041 covers the trailing-slash asymmetry in the same function. Neither asks whether the prefix rule itself is intended.
Questions
- Is accepting a parent-path
resourceon the client side intentional? - If yes, is it meant to apply to metadata discovered via
WWW-Authenticate, where §3.3 requires identity? Or only to the root well-known fallback? - If no, would you accept a change that makes
selectResourceURLrequire equality? This would be normalized equality, tolerant of a trailing slash as in #3041, possibly with an opt-in for lenient matching to avoid breaking existing servers.
Note: downstream clients reuse checkResourceAllowed in their own validateResourceURL hooks (e.g. OpenCode), so the answer also determines what they should do.
What did you expect?
No response
Code to reproduce
SDK version
No response
Area
Auth
- Langage dominant
- TypeScript
- Étoiles
- 13.8k
- Forks
- 2.5k
- Merge moyen
- 6 j 23 h
- PR mergées (30 j)
- 2
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/typescript-sdk
-
v2
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`Peut-être pris @mgoldsborough l’a pris il y a 6 jours. Ouvertev2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
modelcontextprotocol/typescript-sdk#3249 ·
Les mainteneurs répondent en général sous 1 jour
-
v2
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` replyPeut-être pris @Tidehyc l’a pris il y a 7 jours. Ouvertev2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
UriTemplate.match() throws a TypeError on an empty expression it acceptsPeut-être pris @yunusemrejs l’a pris il y a 12 jours. Ouvertev1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/typescript-sdk
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Vessel9817/onion-site-template#512 ·
Les mainteneurs répondent en général sous 1 jour
-
nightly-tests
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
Les mainteneurs répondent en général sous 1 jour
-
approved
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
fritzprix/libr-agent#3266 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
better-auth/better-auth#13101 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour