Skip to main content

MCP servers behind OAuth say how to sign in

When an MCP server protected by OAuth 2.1 answers discovery with 401, Apiome now follows its WWW-Authenticate challenge. It finds the server's authorization server and stores its authorization and token endpoints, scopes and resource indicator with the endpoint's credential. See Servers protected by OAuth.

  • Standards-based. The challenge's resource_metadata URL, or the well-known URL, gives the Protected Resource Metadata (RFC 9728). That names the authorization servers, whose metadata comes from /.well-known/oauth-authorization-server (RFC 8414).
  • Readable over the API. GET …/endpoints/{id}/credentials returns it as oauth_metadata. The discovery job's result.oauth_discovery says whether it was found and, if not, why.
  • Checked before it is stored.
    • The metadata must describe this server, and the authorization server must name the issuer it was fetched for.
    • Every URL must be HTTPS and on a public address.
    • Redirects are not followed.
  • Not sign-in yet. Apiome does not fetch tokens. Store an OAuth 2.1 access token to reach the server; signing in with these endpoints comes next.