Skip to content

OAuth discovery fails against Keycloak: client only tries RFC 8414 canonical well-known path, doesn't fall back to realm-first / OIDC discovery #2296

Description

@Nubilly

Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

Web

Inspector version

2.5.0

Node version

22.19.0

Operating system (and browser, for the web client)

No response

Transport

Streamable HTTP

MCP server under inspection

  • MCP Inspector version: 2.5.0
  • MCP server: ASP.NET Core, ModelContextProtocol.AspNetCore, Streamable HTTP transport
  • Authorization server: Keycloak 26.0
    npx -y @modelcontextprotocol/inspector@2.5.0 --server mcp-server

Steps to reproduce

  1. Point Inspector at an MCP server (Streamable HTTP) that requires OAuth and serves RFC 9728 protected-resource
    metadata correctly.
  2. Server responds 401 with WWW-Authenticate: Bearer resource_metadata="<server>/.well-known/oauth-protected-resource/mcp".
  3. Inspector fetches that URL successfully and reads authorization_servers: ["https://keycloak:9090/realms/tenant"].
  4. Inspector then requests https://keycloak:9090/.well-known/oauth-authorization-server/realms/tenant404.
  5. The OAuth flow terminates here with no further attempt.

Expected behavior

Per RFC 8414 §3.1 and common client fallback practice, when the plain-OAuth well-known metadata request fails, the
client should also try:

  • The same well-known name in "simple append" form:
    https://keycloak:9090/realms/tenant/.well-known/oauth-authorization-server (confirmed working, returns 200 with
    valid metadata
    — see evidence below)
  • OIDC discovery as a fallback: https://keycloak:9090/realms/tenant/.well-known/openid-configuration (also
    confirmed working
    )

Actual behavior

Only the RFC 8414 canonical form (.well-known/oauth-authorization-server inserted before the issuer path) is
attempted. On 404, the flow dies with no fallback, and the connection cannot be authenticated via Inspector's OAuth
button at all.

Logs, errors, or screenshots

$ curl -sk -i "https://keycloak:9090/.well-known/oauth-authorization-server/realms/tenant"
HTTP/1.1 404 Not Found

$ curl -sk -i "https://keycloak:9090/realms/tenant/.well-known/oauth-authorization-server"
HTTP/1.1 200 OK
{"issuer":"https://keycloak:9090/realms/tenant", ...valid RFC 8414 metadata...}

$ curl -sk -i "https://keycloak:9090/realms/tenant/.well-known/openid-configuration"
HTTP/1.1 200 OK
{"issuer":"https://keycloak:9090/realms/tenant", ...valid OIDC metadata...}

Already prototyped a fix?

No response

Before you submit

  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report (those go through the private advisory process).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions