Repository navigation
Description
Summary
Inspector v0.21.2 sends users to a bogus <resource-host>/authorize URL instead of the auth server when:
- The MCP server is OAuth-protected (
401+WWW-Authenticate: Bearer resource_metadata=...) - The protected-resource metadata is exposed at the RFC 9728 §3 suffix location (i.e.
/<resource-path>/.well-known/oauth-protected-resource) rather than the prepend location the SDK probes by default.
This is a focused report of one of the symptoms tracked under #675. Since #675 has gathered many distinct sub-issues, opening this one to track the specific proxy-mode handleAuthError path independently.
Reproduction
- Stand up an MCP server that:
- Returns
401+WWW-Authenticate: Bearer resource_metadata="https://<host>/<resource-path>/.well-known/oauth-protected-resource"on unauthenticated requests - Hosts the metadata at the suffix location (200 with
{ authorization_servers: [...] }) - Does not host metadata at the prepend location
/.well-known/oauth-protected-resource/<resource-path> - This is the shape used by managed runtimes that mount each MCP server under a path (e.g. AWS Bedrock AgentCore Runtime:
/runtimes/<arn>/invocations?qualifier=DEFAULT).
- Returns
- In Inspector → Streamable HTTP transport, paste the MCP URL.
- Set
Client ID(any pre-registered SPA client_id with PKCE). - Click Connect.
Expected
Browser redirects to the auth server's /authorize endpoint (URL discovered via the resource_metadata URL → authorization_servers).
Actual
Browser redirects to <resource-host>/authorize (using the resource server's host as the auth server). The page 404s, and useConnection.ts toasts OAuth Authentication Failed.
Network trace (truncated)
POST /<resource-path> → 401 + WWW-Authenticate: Bearer resource_metadata=<META_URL>
[Inspector proxy wraps as JSON-RPC error code -32099 with data.upstream401.wwwAuthenticate]
GET /.well-known/oauth-protected-resource/<resource-path> → 404 (SDK's default prepend probe)
GET /.well-known/oauth-protected-resource → 404 (SDK's root fallback)
GET <resource-host>/.well-known/oauth-authorization-server → 404 (auth server discovery on resource host)
[redirect] <resource-host>/authorize?response_type=code&... → 404
Root cause
handleAuthError (in client/src/lib/hooks/useConnection.ts) calls auth(provider, { serverUrl, scope, fetchFn }) without a resourceMetadataUrl. That makes the SDK's default discovery probe the prepend path, fall back to the root, and then treat the resource server as the auth server when both 404.
In proxy mode, the proxy unwraps the upstream 401 into a JSON-RPC error containing data.upstream401.wwwAuthenticate (see server/src/mcpProxy.ts serializeProxyTransportError). The SDK's StreamableHTTPClientTransport._send therefore never sees a 401 status and the provider's onUnauthorized hook never fires — so even when the upstream advertises a metadata URL, Inspector ignores it.
Related work
- The inspector does not follow the spec according to authorization senarios #675 — umbrella issue with multiple distinct sub-issues
- Fix OAuth: use authorization_servers URL from resource metadata for scope discovery #1133 — related fix for
discoverScopesthat was closed without merging
Proposed fix
Extract resource_metadata=... from any of three sources (priority order: SDK error's resourceMetadataUrl → response/headers' WWW-Authenticate → proxy upstream401.wwwAuthenticate) and pass it to both discoverOAuthProtectedResourceMetadata and auth(). PR submitted.
Environment
- Inspector v0.21.2
- Streamable HTTP transport
connectionType: "proxy"(default)
Activity
HeatherFlux commentedon May 5, 2026
Closing — will reopen if/when needed with a cleaner repro.
renatogcarvalho commentedon May 12, 2026
We hit this exact bug yesterday with Inspector 0.21.2 — a second concrete case beyond the AWS Bedrock AgentCore Runtime shape.
Setup
/mcp/<service-name>behind a path-prefixed ALB rulehttps://<host>/mcp/<service-name>WWW-Authenticate: Bearer resource_metadata="https://<host>/mcp/<service-name>/.well-known/oauth-protected-resource"(path-preserving / "suffix" location)Observation
Inspector's first 4 requests were all apex probes — never POSTed to the MCP transport, never saw the 401 with WWW-Authenticate:
Inspector failed with "Failed to discover OAuth metadata" before any transport-level interaction.
Side note: in our case the 401s came from the MCP's own auth middleware (apex paths weren't on the public-paths allowlist). If Inspector treats 401 as a hard fail rather than "wrong location, try next," that compounds the issue here.
Why this matters for our topology
Like AWS Bedrock AgentCore, we run multiple MCPs under a shared host with a path prefix per service. The ALB listener rule matches
/mcp/<service-name>/*; apex.well-known/*goes to the ALB default action. WithoutresourceMetadataUrlsupport, every org-wide MCP has to either:Workaround (local dev only)
Register apex aliases on the MCP server itself — works in single-container docker-compose, doesn't scale to a shared org ALB.
The proposed fix in the original report (extract
resource_metadatafrom SDK error / response headers / proxyupstream401.wwwAuthenticateand pass todiscoverOAuthProtectedResourceMetadata+auth()) would unblock all three setups without server-side workarounds. Happy to test a PR.FMCorz commentedon Jun 15, 2026
+1