function oauthFlowFigure(host) { ensureStyles(); var shell = document.createElement('div'); shell.className = 'mf-shell'; var svg = [ '', '', '', '', '1. tools/call with no token', 'client', 'mcp server', '', 'tools/call, no Authorization header', '401 + WWW-Authenticate: resource_metadata=...', '2. discover, PKCE, authorize', 'client', 'auth server', '', 'PRM + AS metadata + S256 challenge + resource + state', 'code + iss checked against the recorded issuer', '3. retry with a bearer token', 'client', 'mcp server', '', 'tools/call, Authorization: Bearer <token>', '200, resultType complete (audience validated)', '' ].join(''); shell.innerHTML = [ '
Authorizing an MCP Request a 401, a round trip to the authorization server, then a bearer-authenticated retry
', '
', svg, '
', '
Rejection happens at the HTTP layer with no JSON-RPC body. The middle lane resolves entirely outside the MCP wire: Protected Resource Metadata, authorization server metadata, PKCE, and an iss check the client applies itself. Only the retried tools/call, now carrying a bearer token whose audience matches this server, reaches the tool.
' ].join(''); host.appendChild(shell); } // register as: mcpa-23-oauth-flow