Honor MCP OAuth metadata challenge URLs - #481
Open
sam-maass wants to merge 2 commits into
Open
Conversation
sam-maass
marked this pull request as ready for review
August 28, 2026 07:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resource_metadatachallenge before derived metadata discoveryReproduction
Add d0 to
~/.fx/mcp.json:{ "mcpServers": { "d0": { "type": "http", "url": "https://d0-web.vercel.tools/eve/v1/mcp", "enabled": true } } }Then run either the top-level command:
or, from an interactive fx session:
Before this fix, authentication fails with:
The d0 resource responds with a
401 Unauthorizedchallenge that advertises its protected-resource metadata URL. This behavior is valid under RFC 9728 Section 5.1, which defines theresource_metadataparameter for providing the protected-resource metadata URL:WWW-Authenticate: Bearer resource_metadata="https://d0-web.vercel.tools/eve/v1/.well-known/oauth-protected-resource", scope="d0:invoke"Root cause
fx mcp auth d0did not first contact the protected resource.WWW-Authenticatechallenge.resource_metadataURL, fx tried only its already-correct RFC-derived fallback URLs.ProtectedResourceMetadataUnavailable.d0's challenge-directed metadata discovery is standards-compliant. The bug was not that fx dropped the resource path while constructing the RFC 9728 fallback URL. fx already derived
https://d0-web.vercel.tools/.well-known/oauth-protected-resource/eve/v1/mcpcorrectly, but d0 returns 404 there and instead relies on its challenge-advertised metadata URL.Verification
zig fmt --check src/zig buildbun test mcp-auth.test.ts --test-name-pattern 'top-level MCP auth'— 2 passed, 0 failedbun test mcp-auth.test.ts— 31 passed, 14 environment skips, 0 failed./zig-out/bin/fx mcp auth d0— exit 0, authenticated, stderr emptyFull CI is pending on this draft PR. The required
type: buglabel must be applied by a maintainer because the PR author cannot manage labels in the upstream repository.