fix: suppress RFC 8707 resource parameter in OAuth authorization requests#1154
Open
DSavaliya-gh wants to merge 2 commits intomodelcontextprotocol:mainfrom
Open
fix: suppress RFC 8707 resource parameter in OAuth authorization requests#1154DSavaliya-gh wants to merge 2 commits intomodelcontextprotocol:mainfrom
resource parameter in OAuth authorization requests#1154DSavaliya-gh wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
…ests Add validateResourceURL() to InspectorOAuthClientProvider to prevent the SDK from appending the RFC 8707 'resource' query parameter to the /authorize URL. Authorization servers that do not support RFC 8707 — notably Azure Entra ID v2.0 — reject authorization requests containing this parameter with errors like AADSTS9010010. The resource field in RFC 9728 Protected Resource Metadata is intended for discovery, not for inclusion in authorization requests to servers that rely solely on scopes. Returning undefined from the hook tells the SDK to omit the parameter. PRM-based discovery of authorization_servers and scopes_supported continues to work normally.
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.
Problem
When connecting the MCP Inspector to an MCP server that implements RFC 9728 Protected Resource Metadata (PRM), the TypeScript SDK reads the
resourcefield from the PRM document and appends it as aresourcequery parameter on the/authorizeURL (per RFC 8707).Authorization servers that do not support RFC 8707 reject this parameter. Specifically, Azure Entra ID v2.0 returns:
This blocks the OAuth authorization code flow entirely for any MCP server deployed behind Azure Entra ID (and potentially other authorization servers that don't implement RFC 8707).
Root Cause
The SDK's
startAuthorization()callsselectResourceURL(), which returnsnew URL(resourceMetadata.resource)when PRM is present. This URL is then added asresource=<server-url>to the authorize endpoint. Azure Entra ID v2.0 only uses thescopeparameter for audience resolution and treatsresourceas a v1.0-only concept — any request including it is rejected.The
resourcefield in RFC 9728 PRM is intended for resource discovery (identifying the protected resource), not necessarily for inclusion as a query parameter in authorization requests to all authorization servers.Fix
Implements
validateResourceURL()onInspectorOAuthClientProvider, returningundefined. This is the SDK's intended escape hatch — when this hook is present, the SDK delegates to it instead of using the raw PRMresourcefield. Returningundefinedtells the SDK to omit theresourceparameter from the authorize URL entirely.What still works:
authorization_servers(used to find the correct authorization endpoint)scopes_supported(used to request the correct scopes)code_challenge/code_verifier)What changes:
resource=<server-url>query parameter is no longer appended to the/authorizeURLSince
DebugInspectorOAuthClientProviderextendsInspectorOAuthClientProvider, the fix applies to both normal and debug OAuth flows automatically.How to Reproduce
resource: the server URLauthorization_servers: pointing to the Entra ID v2.0 issuerscopes_supported: e.g.["api://<app-id>/.default"]/authorizeendpoint withresource=https://<server-url>/in the query stringAADSTS9010010Change
client/src/lib/auth.tsInspectorOAuthClientProvidervalidateResourceURL()— returnsPromise.resolve(undefined)