RFC 9728 /.well-known/oauth-protected-resource for MCP OAuth
Implement RFC 9728 OAuth 2.0 Protected Resource Metadata and HTTP 401 WWW-Authenticate headers so MCP clients dynamically discover your Authorization Server without manual client setup.
Verify live A2A, MCP, OAuth & AEO discovery in production
In RungLab's N=140 B2B SaaS Readiness Benchmark, 98.4% (62/63) of full-telemetry domains lacked agent-card.json. Audit your live domain with ReadyCheck, cut MCP schema token tax with MCPDiet, or automate fleet discovery checks via Apify & RapidAPI.
RFC9728-BR-001: Bearer token header transport declaredPASS
Methods: header
HTTP Header & Caching Deployment Checklist
Serve with `Content-Type: application/json; charset=utf-8` (never `text/plain` or SPA HTML fallback).
Include `Access-Control-Allow-Origin: *` so browser-based agent inspectors and web clients can fetch discovery JSON.
Use `Cache-Control: public, max-age=300` instead of `immutable` so skill/scope updates propagate quickly.
Return `WWW-Authenticate: Bearer resource_metadata="https://<domain>/.well-known/oauth-protected-resource"` on HTTP 401 (prevents `MCP-PRO-002`).
Live Well-Known Audit98.4% Lack Agent Cards
Verify live A2A, MCP, OAuth & AEO discovery in production
In RungLab's N=140 B2B SaaS Readiness Benchmark, 98.4% (62/63) of full-telemetry domains lacked agent-card.json. Audit your live domain with ReadyCheck, cut MCP schema token tax with MCPDiet, or automate fleet discovery checks via Apify & RapidAPI.
In RungLab's 100-server MCP audit, 39 of 40 auth-gated (401) production servers (97.5%) already publish RFC 9728 /.well-known/oauth-protected-resource — making it the de-facto standard for remote MCP auth.
Two auth-gated servers (5%) triggered MCP-PRO-002 because they returned HTTP 401/403 without a WWW-Authenticate header pointing to resource_metadata, stalling automated MCP OAuth clients.
RFC 9728 §2 mandates that the resource field be a canonical HTTPS URI with NO fragment (#) component, matching the resource parameter clients send in OAuth token requests.
Common Production Pitfalls to Avoid
Serving /.well-known/oauth-protected-resource with text/plain or application/octet-stream because the path lacks a .json suffix — explicitly force Content-Type: application/json.
Omitting WWW-Authenticate: Bearer resource_metadata="..." on HTTP 401 responses from /mcp.
Adding "query" to bearer_methods_supported leaks bearer tokens into CDN/proxy access logs; stick strictly to ["header"].
More Agent Discovery Specifications & Framework Guides
Author valid Model Context Protocol server.json manifests for the official MCP Registry and self-hosted /.well-known/mcp/server.json discovery with Streamable HTTP and clean token budgets.
Deploy /.well-known/agent-card.json, /.well-known/mcp/server.json, and /.well-known/oauth-protected-resource on Cloudflare Workers and Cloudflare Pages with strict JSON MIME types and CORS.
Serve /.well-known/agent-card.json, /.well-known/mcp/server.json, and /.well-known/oauth-protected-resource cleanly in Next.js App Router without middleware auth redirects or trailing-slash loops.
Where should /.well-known/oauth-protected-resource live if my MCP endpoint is /mcp?
Per RFC 9728 §3.1 and MCP Auth spec, clients check path-scoped /.well-known/oauth-protected-resource/mcp first (or follow the exact resource_metadata URL in your 401 WWW-Authenticate header), then fall back to root /.well-known/oauth-protected-resource. Serving both or returning exact resource_metadata in 401 works reliably across all clients.
Why did RungLab's MCP linter flag missing WWW-Authenticate headers (MCP-PRO-002)?
Without WWW-Authenticate: Bearer resource_metadata="..." on HTTP 401, compliant MCP clients cannot reliably resolve which Authorization Server and scopes protect your endpoint.
Does authorization_servers hold full endpoint URLs or issuer base URLs?
Issuer URLs only (e.g. "https://auth.example.com"), NOT /authorize or /token URLs. Clients append /.well-known/oauth-authorization-server (RFC 8414) to that issuer.