Most MCP authorisation bugs come from implementers treating the specification as "add OAuth" rather than following the exact discovery, registration and token rules it sets out. The MCP authorisation specification is a profile of OAuth 2.1 that pins down which RFCs a client and server must implement, in what order discovery happens, how a client with no prior relationship gets a client ID, and what an MCP server must refuse. This guide walks through that flow as defined in MCP specification revision 2026-07-28 (the latest dated revision when checked on 27 October 2026), flags what changed from revision 2025-11-25, and turns each requirement into implementation, test and monitoring steps. It is written for engineers building MCP clients, servers or authorisation servers, and for identity teams reviewing them. For the broader MCP threat picture, see the MCP Security Guide.
Key takeaways
- The MCP server is an OAuth resource server, nothing more. It must publish Protected Resource Metadata (RFC 9728), validate that every token was issued for it, and never forward a client's token to an upstream API.
- Discovery is ordered and mandatory. Clients start from a 401 with a
resource_metadatapointer, fall back to two well-known URIs, then try OAuth and OpenID Connect metadata endpoints in a fixed priority order. - Client ID Metadata Documents are now the default for strangers. In revision 2026-07-28, Dynamic Client Registration is deprecated in favour of an HTTPS URL as the
client_id; pre-registration still comes first where it exists. - PKCE, resource indicators and issuer checks close different holes. PKCE with
S256stops code interception, the RFC 8707resourceparameter binds tokens to one server, and RFC 9207issvalidation stops mix-up attacks. - Scopes start small and grow by challenge. Servers answer runtime shortfalls with 403
insufficient_scopeand the required scopes; clients step up by requesting the union of old and new scopes, with retry limits.
Which revision applies, and what changed
MCP publishes dated specification revisions. Authorisation is optional for MCP implementations, but when it is supported, HTTP-based transports should conform to the authorisation specification, and stdio implementations should not follow it and should instead retrieve credentials from the environment. Revision 2026-07-28 split the authorisation material into separate pages (discovery, client registration and security considerations) and made several changes that matter for implementers.
| Area | Revision 2025-11-25 | Revision 2026-07-28 |
|---|---|---|
| Issuer identification (RFC 9207) | Not referenced | Authorisation servers SHOULD send iss; clients MUST validate a present iss against the recorded issuer before redeeming the code (SEP-2468) |
| Dynamic Client Registration | MAY, kept for backwards compatibility | Deprecated in favour of Client ID Metadata Documents; still available |
DCR application_type | Not specified | Clients MUST specify it (native for desktop, CLI and localhost apps, web for remote browser apps) (SEP-837) |
| Credential binding | Not specified | Persisted or pre-registered client credentials MUST be keyed by the authorisation server's issuer and MUST NOT be reused with a different one (SEP-2352) |
| Step-up scope sets | Server may include previously granted scopes | Servers SHOULD emit all scopes needed for the current operation in one challenge; clients SHOULD request the union of previous and challenged scopes |
| Refresh tokens | Rotation for public clients | Adds guidance: clients MUST NOT assume refresh tokens will be issued; servers SHOULD NOT list offline_access in challenges or scopes_supported |
| Sessions | Mcp-Session-Id on Streamable HTTP | Protocol-level sessions removed; authorisation MUST be included in every HTTP request |
Clients that talk to servers on older revisions must support both behaviours. The draft specification continues to evolve, and the 2026-07-28 text says a future revision is expected to upgrade authorisation server inclusion of iss from SHOULD to MUST, so build for the stricter rule now.
Roles and the standards stack
The specification defines three roles. A protected MCP server acts as an OAuth 2.1 resource server. An MCP client acts as an OAuth 2.1 client making requests on behalf of a resource owner. The authorisation server interacts with the user and issues tokens; it may be co-hosted with the MCP server or be a separate identity provider.
| Standard | What MCP uses it for | Who implements it |
|---|---|---|
| OAuth 2.1 (draft-ietf-oauth-v2-1-13) | Authorisation code flow, PKCE, bearer token rules, security considerations | Client, authorisation server, MCP server |
| RFC 9728 Protected Resource Metadata | MCP server tells clients which authorisation servers protect it | MCP server MUST; client MUST use it |
| RFC 8414 AS Metadata / OpenID Connect Discovery 1.0 | Client learns endpoints, PKCE support, registration options | AS MUST provide at least one; client MUST support both |
| RFC 8707 Resource Indicators | resource parameter binds the token to the MCP server's canonical URI | Client MUST send; server MUST validate audience |
| RFC 9207 Issuer Identification | iss in the authorisation response defeats mix-up | AS SHOULD send; client MUST validate when present |
| Client ID Metadata Document (draft-ietf-oauth-client-id-metadata-document-00) | HTTPS URL as client_id | Client and AS SHOULD support |
| RFC 7591 Dynamic Client Registration | Legacy registration path | MAY, deprecated in 2026-07-28 |
| RFC 6750 Bearer Token Usage | WWW-Authenticate challenges, insufficient_scope | MCP server |
OAuth 2.1 and the Client ID Metadata Document specification were still Internet-Drafts when checked, and MCP pins specific draft versions. Avoid relying on draft details beyond what the MCP text itself requires. See the OAuth 2.1, GNAP and FAPI Guide for the wider OAuth 2.1 picture.
Discovery: from a 401 to the authorisation server
The flow begins when a client calls the MCP endpoint without a token. Discovery is where most interoperability failures and several security failures (notably SSRF) occur, so implement it exactly.
- Challenge: the server returns
401 Unauthorized. It MUST provide Protected Resource Metadata location through either theWWW-Authenticateheader'sresource_metadataparameter or a well-known URI, and SHOULD include ascopeparameter naming the scopes needed, for exampleWWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource", scope="files:read". - Metadata fetch: clients MUST use the header URL when present. Otherwise they MUST try, in order, the path-specific URI (
https://example.com/.well-known/oauth-protected-resource/public/mcpfor an endpoint at/public/mcp) and then the root URI (/.well-known/oauth-protected-resource). - Choose an authorisation server: the metadata document MUST contain
authorization_serverswith at least one entry. If there are several, the client selects one following RFC 9728 Section 7.6. - Authorisation server metadata: for an issuer with a path such as
https://auth.example.com/tenant1, clients MUST try/.well-known/oauth-authorization-server/tenant1, then/.well-known/openid-configuration/tenant1, then/tenant1/.well-known/openid-configuration. Without a path, they try the OAuth endpoint and then the OpenID Connect endpoint. - Record the issuer: in 2026-07-28 the client MUST record the
issuerfrom the validated metadata and store it with the PKCE verifier andstatefor this request. This value is what laterisschecks compare against.
Every URL in this chain can come from a hostile server. The specification's security best practices list the resource_metadata URL, the authorization_servers entries and the endpoints inside authorisation server metadata as SSRF sources, and say clients SHOULD require HTTPS (loopback excepted during development), block private, loopback and link-local ranges including 169.254.0.0/16, and validate redirect targets. Server-side clients should route discovery through an egress proxy. See the SSRF Prevention Guide.
Client registration: pre-registration, CIMD or DCR
Before the authorisation request, the client needs a client_id. Clients that support all options SHOULD use this order: pre-registered credentials if available; Client ID Metadata Documents if the authorisation server advertises client_id_metadata_document_supported; Dynamic Client Registration if a registration_endpoint exists; and finally prompting the user to enter client details.
| Approach | When it fits | Security properties | Watch for |
|---|---|---|---|
| Pre-registration | Known client and server, enterprise deployments, confidential clients | Administrator controls redirect URIs and client authentication; credentials bound to one issuer | Credentials MUST be keyed by issuer; surface an error if the advertised AS changes |
| Client ID Metadata Document | Open ecosystems where client and server have no prior relationship | Client identity tied to an HTTPS domain it controls; no registration database; portable across authorisation servers | AS fetches attacker-supplied URLs (SSRF); localhost redirect impersonation |
| Dynamic Client Registration | Legacy authorisation servers without CIMD support | Weakest: anyone can register a client and redirect URI | Enables the confused deputy pattern in proxies; deprecated in 2026-07-28 |
CIMD client requirements: the metadata document MUST be hosted at an HTTPS URL with a path component (for example https://app.example.com/oauth/client-metadata.json), MUST include client_id, client_name and redirect_uris, and the client_id value MUST match the document URL exactly. Clients MAY use private_key_jwt at the token endpoint.
CIMD authorisation server requirements: it MUST check that the fetched client_id matches the URL, MUST validate presented redirect URIs against the document, MUST validate the JSON structure, SHOULD cache respecting HTTP headers, and SHOULD treat the fetch as an SSRF risk. Because a metadata document cannot prove which local process is listening on a localhost redirect, the authorisation server SHOULD warn on localhost-only redirect URIs, MAY require attestation, and MUST clearly show the redirect URI hostname at consent. Trust policies are the server's choice: an allowlist of domains for protected servers, any HTTPS client_id for open servers, or reputation and domain-age checks in between.
Decision guidance: a small team exposing one MCP server to its own staff should pre-register the few clients it supports and refuse anonymous registration. A SaaS provider offering a public MCP server should support CIMD with a domain trust policy and keep DCR only while major clients still need it, with rate limits and redirect URI review on the registration endpoint.
The authorisation request and response
With a client ID, the client builds an authorisation code request. Each parameter maps to a specific threat.
- PKCE: clients MUST implement PKCE and MUST use
S256when technically capable. Because OAuth does not define PKCE discovery, clients MUST check thatcode_challenge_methods_supportedis present in authorisation server metadata (OAuth or OpenID Connect) and MUST refuse to proceed if it is absent. OpenID providers serving MCP MUST include that field. - Resource indicator: clients MUST send
resourcein both the authorisation and token requests, set to the MCP server's canonical URI (for examplehttps://mcp.example.com/mcp, lowercase scheme and host, no fragment, no trailing slash unless significant). They MUST send it even if the authorisation server does not support it. - State: clients SHOULD use and verify
stateand discard responses that lack it or do not match. - Redirect URIs: MUST be registered, MUST be
localhostor HTTPS, and authorisation servers MUST validate them by exact match. - Issuer check (2026-07-28): on receiving the response, and before sending the code to any token endpoint, the client MUST apply RFC 9207 Section 2.4 validation.
authorization_response_iss_parameter_supported | iss in response | Client action |
|---|---|---|
true | present | Compare with recorded issuer by simple string comparison |
true | absent | Reject the response |
false or absent | present | Compare with recorded issuer by simple string comparison |
false or absent | absent | Proceed |
The comparison is deliberately strict: clients MUST NOT apply case folding, default-port elision, trailing-slash or percent-encoding normalisation, and on a mismatch MUST NOT act on or display error, error_description or error_uri. The best practices page explains why this is needed even with PKCE: in a mix-up, the client sends the code_verifier to the attacker's token endpoint, so PKCE alone does not help.
Token handling at the MCP server
This is the section auditors should test hardest, because a single permissive code path undoes everything above.
- Transport of the token: clients MUST send
Authorization: Bearer <token>on every HTTP request and MUST NOT put tokens in the query string. With sessions removed in 2026-07-28 there is no session to fall back on. - Validation: servers MUST validate tokens per OAuth 2.1 Section 5.2 and MUST confirm they are the intended audience per RFC 8707. For JWT access tokens that means signature,
iss,aud,expand scope checks on every call; for opaque tokens, introspection with the same checks. - Failure codes: invalid or expired tokens MUST get 401; insufficient scope or permission gets 403; a malformed authorisation request gets 400.
- No passthrough: servers MUST NOT accept or transit tokens issued for other resources, and when they call upstream APIs they act as an OAuth client with a separate token from the upstream authorisation server. See the OAuth Token Exchange and Delegation Guide for delegation patterns that keep user context without forwarding tokens.
- Token theft: clients and servers MUST store tokens securely; authorisation servers SHOULD issue short-lived access tokens and MUST rotate refresh tokens for public clients.
- Refresh tokens (2026-07-28): clients MUST keep them confidential, SHOULD list
refresh_tokeningrant_types, MAY addoffline_accesswhen the authorisation server lists it, and MUST NOT assume one will be issued.
The MCP server is also a non-human identity in its own right when it calls upstream services. Give it its own credential, scoped to what its tools need. See the Agent Identity and Access Guide.
Scopes, challenges and step-up
The specification expects a progressive model: a minimal starting scope set and targeted elevation when a privileged tool is first used.
- Initial selection: clients SHOULD use the
scopefrom the initial 401 challenge; if there is none, request all scopes inscopes_supported, omittingscopeif that field is undefined. Because clients may request everything listed,scopes_supportedshould represent the minimal set for basic functionality, not the full catalogue. - Runtime shortfall: the server SHOULD reply
403 ForbiddenwithWWW-Authenticate: Bearer error="insufficient_scope", scope="files:write", resource_metadata="..."and an optionalerror_description. - One challenge per operation: in 2026-07-28 servers SHOULD include all scopes required for the current operation in a single challenge rather than one at a time, and MUST account for scope hierarchies when deciding whether a token is sufficient.
- Step-up: user-facing clients SHOULD re-authorise with the union of previously requested and newly challenged scopes, retry only a few times, and track upgrade attempts per resource and operation.
client_credentialsclients MAY step up or abort.
The security best practices list the common mistakes: publishing every scope in scopes_supported, wildcard scopes such as * or full-access, returning the whole catalogue in every challenge, and treating token scopes as sufficient without server-side authorisation logic. Per-object authorisation still has to happen in the server.
Implementation roadmap
- Inventory: list every remote MCP server, its authorisation server, registration method and the revision each client and server implements. stdio servers sit outside this flow and need the local controls in the Local MCP Server Security Guide.
- Server first: publish Protected Resource Metadata, emit correct 401 and 403 challenges, and enforce audience validation with a fail-closed middleware that rejects any request whose token validation throws.
- Authorisation server: confirm
code_challenge_methods_supported, enableissin authorisation responses and setauthorization_response_iss_parameter_supported, configure short access token lifetimes, refresh token rotation and exact redirect matching, then decide CIMD trust policy and whether DCR stays on. - Client: implement ordered discovery with SSRF guards, the registration priority, PKCE S256,
resource,state, issuer recording and RFC 9207 validation, and issuer-keyed credential storage in the OS secret store. - Test in a pilot ring: use the MCP Inspector and negative tests: a token with the wrong
aud, an expired token, a token in the query string, a response with a wrongiss, metadata pointing at169.254.169.254, and an unregistered redirect URI. Each must fail. - Roll out and roll back: enable enforcement per server behind a flag, keep the previous accepted-issuer configuration for one release, and roll back by disabling the new check for a named client while you fix it, never by switching audience validation off globally.
Detection and measurement
Log at the MCP server: token validation result and reason (audience, issuer, expiry, signature), the client ID, the subject, granted and required scopes, and the tool called. Log at the authorisation server: registrations, CIMD fetches and their destinations, consent grants, refresh token reuse, and iss-related failures reported by clients. The best practices also ask servers to log elevation events with correlation IDs.
- Audience rejection rate: requests rejected for wrong
aud, by client. A sudden rise signals token replay or a misconfigured client. - Scope breadth: median number of scopes per issued token for MCP resources, trending down over time.
- Step-up loop rate: operations needing more than one challenge; the target is close to zero.
- Legacy registration share: proportion of clients still using DCR, with a target date to reach zero where the ecosystem allows.
- Refresh token reuse detections: any value above zero needs investigation.
- Access token lifetime: percentage of MCP tokens with lifetimes at or below your standard (for example one hour or less).
Framework mapping
| MCP requirement | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | ATT&CK technique addressed |
|---|---|---|---|
| Audience validation, no passthrough | AC-3 Access Enforcement, IA-9 Service Identification and Authentication | PR.AA-03 | T1550.001 Application Access Token |
| Short-lived tokens, rotation, secure storage | IA-5 Authenticator Management | PR.AA-01 | T1528 Steal Application Access Token |
| Scope minimisation and step-up | AC-6 Least Privilege | PR.AA-05 | T1078.004 Cloud Accounts (misuse of valid credentials) |
| HTTPS endpoints and redirect URIs | SC-8 Transmission Confidentiality and Integrity | PR.DS-02 | T1566.002 Spearphishing Link (consent phishing via redirects) |
| SSRF guards on discovery | SC-7 Boundary Protection, SI-10 Information Input Validation | PR.IR-01 | T1552.005 Cloud Instance Metadata API |
| Logging of validation and elevation | AU-2 Event Logging, AU-12 Audit Record Generation | PR.PS-04 | Supports detection of all of the above |
In ISO/IEC 27001:2022 Annex A the closest controls are 5.17 Authentication information, 8.5 Secure authentication and 8.15 Logging. In the OWASP MCP Top 10 (2025 beta), this guide addresses MCP01 Token Mismanagement and Secret Exposure, MCP02 Privilege Escalation via Scope Creep and MCP07 Insufficient Authentication and Authorization.
Common failure patterns
- Fail-open token validation: a validation error falls through to an empty or default identity. The LiteLLM MCP auth bypass is the pattern in practice: a failed token check produced an empty authentication object, so any bearer token got an MCP session. Test with garbage tokens.
- Signature checked, audience ignored: the server accepts any token from the corporate identity provider, so a token minted for another API works against it. The specification requires rejection of tokens that do not name the server as audience.
- Forwarding the client token upstream: forbidden by the specification, and it destroys the audit trail because upstream logs show the user, not the MCP server.
- Omnibus scopes:
scopes_supportedlists every scope, generic clients request all of them, and every user ends up with admin-level tokens. - Skipping PKCE capability checks: the client proceeds against an authorisation server whose metadata lacks
code_challenge_methods_supported, instead of refusing as required. - Unguarded discovery fetches: a server-side MCP client follows
resource_metadatato a cloud metadata endpoint and leaks credentials in error messages.
Practitioner checklist
- Record which MCP revision each client and server implements, and target 2026-07-28 behaviour for new builds.
- Publish Protected Resource Metadata with at least one
authorization_serversentry and a minimalscopes_supported. - Return 401 with
resource_metadataandscope, and 403insufficient_scopewith all scopes the operation needs. - Validate signature, issuer, audience, expiry and scope on every request; fail closed on any validation error.
- Never forward client tokens; use a separate upstream credential or token exchange.
- Require PKCE S256, refuse authorisation servers without
code_challenge_methods_supported, and sendresourceon both requests. - Record the issuer per request and enforce RFC 9207 validation; enable
isson your authorisation servers. - Prefer pre-registration or CIMD with a domain trust policy; plan DCR retirement and key stored credentials by issuer.
- Apply HTTPS-only and private-range blocking to every discovery URL.
- Log validation failures and scope elevations with correlation IDs, and review the metrics monthly.
Standards and references
- Model Context Protocol: Authorization (revision 2026-07-28)
- Model Context Protocol: Client Registration (revision 2026-07-28)
- Model Context Protocol: Authorization Security Considerations (revision 2026-07-28)
- Model Context Protocol: Security Best Practices
- Model Context Protocol: Key Changes in revision 2026-07-28
- IETF: RFC 9728 OAuth 2.0 Protected Resource Metadata
- IETF: RFC 9207 OAuth 2.0 Authorization Server Issuer Identification
- IETF: RFC 8707 Resource Indicators for OAuth 2.0
Related NHI Mgmt Group resources: MCP Security Guide · MCP Security Best Practices Explained · Remote MCP Server Hardening Guide · OAuth 2.0 and OpenID Connect Guide · Machine-to-Machine OAuth (Client Credentials) Guide