Skip to content

app/: MCP's 401 names the resource's metadata, so clients find the sign-in (sc-8900) - #123

Merged
ndbroadbent merged 1 commit into
mainfrom
mcp-challenge
Dec 3, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
mcp-challenge

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Found by the new journeys suite: POST https://mcp.visualci.com/mcp without a token answers 401 with a bare WWW-Authenticate: Bearer. The MCP spec (2025-06-18, authorization) requires the challenge to name the protected resource's metadata (RFC 9728 section 5.1), which is how a client such as Claude Code finds the OAuth server to sign in with. The metadata document itself was already served.

app/ now answers as today's server/ did (server/src/mcp.rs, auth): through oauth-provider's challenge, for the resource <VISUALCI_MCP_URL>/mcp (or <APP_URL>/mcp on one host), scope mcp:

  • no token: Bearer resource_metadata="https://mcp.visualci.com/.well-known/oauth-protected-resource/mcp", scope="mcp";
  • a token we don't know: the same, plus error="invalid_token", error_description="The token is unknown or revoked.".

Tests

  • an_mcp_client_finds_the_sign_in_from_the_401 follows the connect flow as a client does: it parses the challenge's auth-params (RFC 6750 section 3), fetches the resource_metadata URL, then the authorization server's metadata, and checks it offers authorization, token and dynamic registration endpoints and PKCE with S256.
  • rejects_requests_without_a_valid_token also checks invalid_token.

On main the first test fails at once: a bare Bearer has no parameters.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@ndbroadbent
ndbroadbent merged commit 4c63ec4 into main Dec 3, 2026
12 checks passed
@ndbroadbent
ndbroadbent deleted the mcp-challenge branch December 3, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant