part…
Building governance for MCP?
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
Before requesting a token, the client has to work out which AS protects the MCP server and which endpoints it has. MCP resolves this in two hops: Protected Resource Metadata (from the MCP server) and Authorization Server Metadata (from the AS).
The MCP server MUST publish it, and the document MUST include authorization_servers with at least one AS.
{ "resource": "https://mcp.example.com/mcp",
"authorization_servers": ["https://auth.example.com"],
"scopes_supported": ["files:read", "files:write"],
"bearer_methods_supported": ["header"] }
Two ways for the client to locate it; the server MUST offer at least one and the client MUST support both:
WWW-Authenticate on the 401: Bearer resource_metadata="https://…/.well-known/oauth-protected-resource", scope="files:read".https://host/.well-known/oauth-protected-resource/<endpoint path> (e.g. /public/mcp) and then https://host/.well-known/oauth-protected-resource at the root.Clients MUST be able to parse WWW-Authenticate and handle 401.
If authorization_servers lists several, each one is independent; the choice is the client's (RFC 9728 §7.6). client_ids are unique per AS (RFC 6749 §2.2): the client MUST keep separate registration and tokens per AS and MUST NOT assume that the credentials of one are valid at another.
MCP uses the standard oauth-authorization-server suffix (RFC 8414 §3.1); it does not define one of its own. Since issuers may have a path, the client MUST try several endpoints in order:
Issuer with a path (https://auth.example.com/tenant1):
https://auth.example.com/.well-known/oauth-authorization-server/tenant1https://auth.example.com/.well-known/openid-configuration/tenant1https://auth.example.com/tenant1/.well-known/openid-configurationIssuer without a path (https://auth.example.com):
https://auth.example.com/.well-known/oauth-authorization-serverhttps://auth.example.com/.well-known/openid-configurationAfter obtaining the document, the client MUST check that its issuer is identical to the identifier used to build the URL (RFC 8414 §3.3 / OIDC Discovery §4.3). A document at attacker.example with "issuer": "https://honest.example" MUST be rejected.
sequenceDiagram
participant C as Client
participant M as MCP server
participant A as AS
C->>M: request without token
M-->>C: 401 (+ WWW-Authenticate resource_metadata?)
alt header present
C->>M: GET resource_metadata
else no header
C->>M: GET /.well-known/oauth-protected-resource/<path>
C->>M: GET /.well-known/oauth-protected-resource
end
M-->>C: PRM (authorization_servers)
C->>A: GET metadata (order RFC 8414 → OIDC)
A-->>C: metadata; validate issuer
authorization_servers (they force re-registration and forbid reusing credentials).WWW-Authenticate.1. If the 401 carries no resource_metadata, what does the client try first?
First with the endpoint path, then the root.
2. For an issuer with a path, which AS metadata endpoint is tried first?
Order: 8414 with insertion, OIDC with insertion, OIDC with the path appended.
3. What must the client do if the document's issuer does not match the identifier used?
MUST NOT use it; it is the basic defence against forged metadata.