Guides
MCP OAuth 2.1 Configuration Guide
December 18, 2026 · patchbay
Why OAuth 2.1 matters for MCP servers
The Model Context Protocol authorization specification (2026-07-28) requires MCP servers that expose authenticated tools to speak OAuth 2.1, with specific RFC-level requirements layered on top. Getting this right is not optional if you plan to list on the public MCP registry, integrate with major agent platforms, or ship to enterprise buyers.
Getting it wrong is easy. Common failure modes split into three groups: missing discovery metadata, missing security mitigations, and misconfigured flow enforcement.
This guide walks through every requirement, what breaks when you miss it, and how to validate your server before you ship.
The four RFCs that matter
MCP OAuth 2.1 is not a new spec. It is a profile that pins specific requirements from four existing RFCs. Knowing which RFC each requirement comes from helps you read primary sources when you get stuck.
RFC 9728: OAuth 2.0 Protected Resource Metadata (PRM)
RFC 9728 defines how a protected resource (your MCP server) advertises its authorization server to clients. Clients fetch /.well-known/oauth-protected-resource and learn where to send the user for authentication.
What you need: A PRM document at /.well-known/oauth-protected-resource that includes at minimum authorization_servers and resource fields.
What breaks when you miss it: Clients cannot discover your authorization server. Scanners (patchbay included) flag AUTH-001 as "authentication posture not discoverable."
Example minimal PRM:
{
"resource": "https://your-mcp-server.example.com",
"authorization_servers": ["https://auth.example.com"],
"scopes_supported": ["mcp:read", "mcp:write"],
"bearer_methods_supported": ["header"]
}
RFC 7636: PKCE (Proof Key for Code Exchange)
RFC 7636 defines PKCE, which binds the authorization request to the token request so that intercepted authorization codes cannot be exchanged by an attacker.
What you need: Your authorization server must require code_challenge on every /authorize call and validate the code_verifier on /token. The challenge method must be S256 (never plain).
What breaks when you miss it: Any attacker who captures an authorization code (via logs, referer leaks, malicious redirect) can exchange it for a token. Scanners flag PKCE-001 (no PKCE), PKCE-002 (plain method), or PKCE-003 (challenge not enforced on /authorize).
RFC 8707: OAuth 2.0 Resource Indicators
RFC 8707 lets clients request tokens bound to a specific audience (a specific MCP server). Without this, a token issued for Server A might work on Server B.
What you need: Your authorization server accepts a resource parameter on token requests and binds the issued token to that audience. Your MCP server validates the aud claim on incoming tokens.
What breaks when you miss it: Cross-server token replay. Scanners flag RESOURCE-001.1 through RESOURCE-001.8 covering the various failure modes (no resource param, resource not validated at token issuance, aud not validated at resource server, wildcard aud accepted, etc.).
RFC 9207: iss Parameter in Authorization Response
RFC 9207 requires the authorization response to include an iss parameter so the client can confirm which authorization server issued the response. This defends against mix-up attacks where a malicious AS tricks a client into sending a code to the wrong server.
What you need: Your authorization server includes iss in the authorization response redirect. Your client validates it against the expected AS.
What breaks when you miss it: AS mix-up attacks. Scanners flag AUTH-005.
The checklist
If you have 20 minutes to make your MCP server OAuth 2.1 compliant, work through this list in order.
Discovery:
- Serve
/.well-known/oauth-protected-resourcewith valid JSON - Include
authorization_serversarray - Include
resourcefield matching your MCP server base URL - Verify
/.well-known/openid-configurationon your AS exposesissuer,authorization_endpoint,token_endpoint
PKCE enforcement:
/authorizerejects requests withoutcode_challenge/authorizerejectscode_challenge_method=plain/tokenvalidatescode_verifieragainst storedcode_challenge
Resource indicators:
/tokenacceptsresourceparameter/tokenbinds issued access token to that resource in theaudclaim- MCP server validates incoming token's
audmatches its own base URL
Issuer validation:
- Authorization response redirect includes
issparameter - Client code validates
issbefore exchanging code
Transport:
- HTTPS enforced on all endpoints
- HSTS header on all responses
- Modern TLS (1.2+, prefer 1.3)
Headers:
WWW-Authenticateheader on 401 responses includesrealmand points to the PRM document- No sensitive data in response headers
Validating your configuration
You can check each item above by hand. We built patchbay to do it in about 20 seconds per server.
npx @patchbay-nebius/audit-core --url=https://your-mcp-server.example.com
The report returns each check's result (PASS, FAIL, INFO, SKIP) with the RFC citation, the reproducer, and the fix.
If you prefer, the public leaderboard at [leaderboard URL] shows the grade and findings for every public MCP server. If yours is listed, you can see where it stands without running the scanner.
Common mistakes we see at patchbay
Common failure patterns across MCP servers we have scanned:
1. PRM published but points to a non-existent AS.
The authorization_servers URL in PRM returns 404 or non-OAuth JSON. Scanners that only check "is PRM present" pass; scanners that follow the chain fail.
2. PKCE advertised in code_challenge_methods_supported but not enforced.
The AS says it supports PKCE in its discovery metadata, but /authorize accepts requests without code_challenge. Easy to miss in testing because PKCE-aware clients always send it.
3. Resource parameter accepted but ignored.
The /token endpoint accepts the resource parameter without error, but the issued token's aud claim is set to a default (often the AS itself). Tokens then work on any resource that trusts this AS.
4. iss in authorization response but no client validation.
The AS correctly includes iss in the authorization response. The MCP server trusts any token that validates on the AS. Clients never actually check iss, which is where the protection lives.
5. HTTPS everywhere except /.well-known.
The MCP server endpoint is HTTPS. The discovery documents (served from a static asset host) are HTTP. Clients fetching discovery over HTTP are vulnerable to MITM.
Beyond OAuth 2.1
OAuth 2.1 is the authentication floor. For production MCP servers, consider also:
- Tool manifest signing so clients can verify tool definitions have not been swapped. patchbay's MANIFEST-001 check tracks manifest drift across scans.
- Tool poisoning detection. Even with correct auth, malicious tool descriptions can hijack agent behavior. See patchbay POISONING-001 through POISONING-003.
- Audit logging of tool calls at the MCP server side for forensics.
- Rate limiting per-token at the MCP server.