Skip to content

feat(host): send a resource's scopes in the bearer challenge - #11

Merged
scottlovegrove merged 1 commit into
mainfrom
feat/bearer-challenge-scope
Nov 12, 2026
Merged

scottlovegrove merged 1 commit into
mainfrom
feat/bearer-challenge-scope

Conversation

@scottlovegrove

Copy link
Copy Markdown
Collaborator

Short description

buildBearerChallenge takes an optional scopes list and adds it to the challenge as RFC 6750's scope attribute, space-separated, after resource_metadata:

Bearer resource_metadata="https://notes.example.com/.well-known/oauth-protected-resource/mcp", scope="notes:read notes:write"

The MCP authorization spec tells servers they SHOULD send scope on the 401. Clients then use it first when choosing which scopes to request, and fall back to the protected-resource metadata's scopes_supported only when it's missing. Today a host can't send it, so a client that never finds the resource's own metadata has to guess. On a host that serves several resources, it can end up requesting a different resource's scopes, and the authorization server then refuses it with invalid_scope.

  • src/host/challenge.ts: new optional scopes?: readonly string[] on BearerChallengeOptions. An empty list leaves the attribute out, and the existing output doesn't change.
  • Tests: added cases for scope on its own, with resource_metadata, with error="insufficient_scope", and with an empty list.
  • README: the helper's description now mentions scope, and the host example passes scopes.

The change is additive (feat:), so it releases as 1.1.0. todoist-ai-integrations will bump to it and pass each MCP resource's scopes.

buildBearerChallenge takes an optional `scopes` list and sends it as
RFC 6750's `scope` attribute, space-separated, after
`resource_metadata`. An empty list leaves the attribute out.

The MCP authorization spec has clients take the scopes to request from
the 401's `scope` first, and fall back to the protected-resource
metadata's `scopes_supported` only when it is missing. A host that sends
nothing leaves a client that misses the resource's metadata guessing,
and on a host serving several resources it can request another
resource's scopes and be refused by the authorization server with
`invalid_scope`.
@scottlovegrove scottlovegrove self-assigned this Nov 12, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR updates feat(host): send a resource's scopes in the bearer challenge. No issues were flagged in the reviewed diff.

Share Feedback • Review Logs

@scottlovegrove scottlovegrove added the 🚢 Ship PR requires passing checks before merge, but no independent human review. label Nov 12, 2026
@scottlovegrove
scottlovegrove merged commit b48ecb6 into main Nov 12, 2026
5 checks passed
@scottlovegrove
scottlovegrove deleted the feat/bearer-challenge-scope branch November 12, 2026 16:46
@doist-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 🚢 Ship PR requires passing checks before merge, but no independent human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants