OAuth Discovery · 97.5% MCP Adoption

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.

Manifest Parameters

Zero Telemetry · Strict CSP
Authentication & OAuth Scopes
RFC 9728 Protected Resource Metadata Options
Exact Well-Known Endpoint URL application/json
https://agent.example.com/.well-known/oauth-protected-resource
/.well-known/oauth-protected-resource
{
  "resource": "https://agent.example.com/mcp",
  "authorization_servers": [
    "https://auth.example.com"
  ],
  "scopes_supported": [
    "agent:invoke",
    "mcp:tools",
    "mcp:read"
  ],
  "bearer_methods_supported": [
    "header"
  ],
  "resource_name": "Acme Cloud Assistant",
  "resource_documentation": "https://docs.example.com/agents"
}
curl Verification Command
curl -i "https://agent.example.com/mcp"
curl -fsSL "https://agent.example.com/.well-known/oauth-protected-resource" | jq .
curl -fsSL "https://auth.example.com/.well-known/oauth-authorization-server" | jq .
HTTP 401 WWW-Authenticate Header (RFC 9728 / MCP-PRO-002)
WWW-Authenticate: Bearer resource_metadata="https://agent.example.com/.well-known/oauth-protected-resource", scope="agent:invoke mcp:tools mcp:read"
Live Well-Known Audit 98.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.

Required Endpoints, Paths & MIME Types

Path / Endpoint Purpose Required Content-Type
/.well-known/oauth-protected-resource Root RFC 9728 Protected Resource Metadata JSON (no file extension!) application/json; charset=utf-8
/.well-known/oauth-protected-resource/mcp Path-scoped RFC 9728 discovery when MCP resource lives at https://host/mcp application/json; charset=utf-8

RFC 9728 /.well-known/oauth-protected-resource + 401 Challenge

oauth-protected-resource.json
{
  "resource": "https://mcp.example.com/mcp",
  "authorization_servers": [
    "https://auth.example.com"
  ],
  "scopes_supported": [
    "mcp:read",
    "mcp:tools",
    "offline_access"
  ],
  "bearer_methods_supported": [
    "header"
  ],
  "resource_name": "Acme Workspace MCP",
  "resource_documentation": "https://docs.example.com/mcp/oauth"
}

Required HTTP 401 WWW-Authenticate Response Header

401-www-authenticate.http
HTTP/1.1 401 Unauthorized
Content-Type: application/json
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource", scope="mcp:read mcp:tools"
Cache-Control: no-store

{"error":"unauthorized","message":"Bearer token required. Discover OAuth metadata via resource_metadata."}

Key Empirical & Architectural Takeaways

  • 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

Backend Framework Route Handlers + Middleware

Next.js App Router /.well-known/* Route Handlers & Headers

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.

← Back to AI Agent Discovery Generator & Validator Hub

Frequently Asked Questions

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.