auth: DCR registration omits scopes, causing invalid_scope on strict auth servers
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- go
- Domínio
- authentication
Direção de pesquisa
Comece por AuthorizationCodeHandler e rastreie como requestedScopes é calculado em relação a handleRegistration e RegisterClient. Verifique como DynamicClientRegistrationConfig.Metadata.Scope distingue os valores fornecidos pelo chamador e, em seguida, confirme que os scopes descobertos estão presentes nos metadados de DCR antes da autorização, enquanto os valores explícitos de Scope permanecem inalterados.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Go
- Estrelas
- 5.4k
- Forks
- 623
- Merge médio
- 22h 10min
- PRs com merge (30d)
- 30
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/go-sdk
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
modelcontextprotocol/go-sdk#1557 ·
Mantenedores costumam responder em até 1 dia
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into anyTalvez livre de novo @beiryu assumiu há 10 dias e não há nenhum pull request aberto. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
modelcontextprotocol/go-sdk#1534 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertaneeds investigation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
modelcontextprotocol/go-sdk#745 · 13 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 18/100
modelcontextprotocol/go-sdk#1555 ·
Mantenedores costumam responder em até 1 dia
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requestsTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
modelcontextprotocol/go-sdk#1552 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de modelcontextprotocol/go-sdk
Issues semelhantes
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
compiler-explorer/compiler-explorer#9738 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
evilmartians/lefthook#1674 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia