auth: DCR registration omits scopes, causing invalid_scope on strict auth servers
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 68/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Calme
- Stack technique
- go
- Domaine
- authentication
Piste de recherche
Commencez par AuthorizationCodeHandler et suivez la manière dont requestedScopes est calculé par rapport à handleRegistration et RegisterClient. Vérifiez comment DynamicClientRegistrationConfig.Metadata.Scope distingue les valeurs fournies par l’appelant, puis vérifiez que les scopes découverts sont présents dans les métadonnées DCR avant l’autorisation, tandis que les valeurs explicites de Scope restent inchangées.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
When using AuthorizationCodeHandler with DynamicClientRegistrationConfig, the SDK registers the DCR client before computing the scopes it will request during authorization. If the caller doesn't set ClientRegistrationMetadata.Scope the client is registered without any scope restriction. Section 2 of RFC 7591 says:
scope:
String containing a space-separated list of scope values (as
described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client
can use when requesting access tokens. The semantics of values in
this list are service specific. If omitted, an authorization
server MAY register a client with a default set of scopes.
I think the important part being that the server MAY register a client with default scopes but for registration endpoints that aren't exclusively used for MCP, it's hard to know what that default set of scopes would be.
To Reproduce
- Configure an AuthorizationCodeHandler with DynamicClientRegistrationConfig, leaving Metadata.Scope empty
- Connect to an MCP server whose auth server enforces scope restrictions on DCR clients (i.e. the authorization endpoint rejects scopes the client wasn't registered for)
- The server's Protected Resource Metadata advertises scopes_supported
- The 401 response does not include a WWW-Authenticate header with a scope parameter
The SDK discovers the PRM scopes, registers the client without them, then requests authorization with them and the auth server rejects the request.
Expected behavior
The SDK should propagate the discovered scopes into DynamicClientRegistrationConfig.Metadata.Scope before calling RegisterClient, so the client is registered for the same scopes it will request. Callers who explicitly set Scope should not be affected.
Logs
Error: calling "initialize": sending "initialize": rejected by transport: authorization error: invalid_scope: OAuth 2.0 Parameter: scope
Additional context
The fix is to move scope computation above handleRegistration, and set the DCR metadata scope when the caller didn't provide one:
if dcrCfg := h.config.DynamicClientRegistrationConfig; dcrCfg != nil && dcrCfg.Metadata.Scope == "" && len(requestedScopes) > 0 {
dcrCfg.Metadata.Scope = strings.Join(requestedScopes, " ")
}
I believe this would also match what is described in the Scope Selection Strategy section of the specification as well
Reproduced on v1.6.1 and v1.7.0-pre.3. I've made a small change locally that seems to fix the issue I'm seeing. I'm happy to put that up as a PR if that'd be helpful but wanted to confirm the behavior with you first. Thanks!
Edit:
It seems like what I'm describing is what happens with the typescript-sdk. Looks like they are resolving the scopes here. Then registering the DCR client here with those scopes. I don't know what the correct behavior is, but I think there's a difference.
- Langage dominant
- Go
- Étoiles
- 5.4k
- Forks
- 623
- Merge moyen
- 22 h 10 min
- PR mergées (30 j)
- 30
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un 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/go-sdk
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
modelcontextprotocol/go-sdk#1557 ·
Les mainteneurs répondent en général sous 1 jour
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into anyPeut-être à nouveau libre @beiryu l’a pris il y a 10 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
modelcontextprotocol/go-sdk#1534 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverteneeds investigation
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
modelcontextprotocol/go-sdk#745 · 13 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 18/100
modelcontextprotocol/go-sdk#1555 ·
Les mainteneurs répondent en général sous 1 jour
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requestsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
modelcontextprotocol/go-sdk#1552 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/go-sdk
Issues similaires
-
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
compiler-explorer/compiler-explorer#9738 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
evilmartians/lefthook#1674 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour