The Model Context Protocol provides authorization capabilities at the transport level, enabling MCP clients to make requests to restricted MCP servers on behalf of resource owners. This specification defines the authorization flow for HTTP-based transports.
Authorization is OPTIONAL for MCP implementations. When supported:
This authorization mechanism is based on established specifications listed below, but implements a selected subset of their features to ensure security and interoperability while maintaining simplicity:
MCP auth implementations MUST implement OAuth 2.1 with appropriate security measures for both confidential and public clients.
MCP auth implementations SHOULD support the OAuth 2.0 Dynamic Client Registration Protocol (RFC7591).
MCP servers SHOULD and MCP clients MUST implement OAuth 2.0 Authorization Server Metadata (RFC8414). Servers that do not support Authorization Server Metadata MUST follow the default URI schema.
OAuth specifies different flows or grant types, which are different ways of obtaining an access token. Each of these targets different use cases and scenarios.
MCP servers SHOULD support the OAuth grant types that best align with the intended audience. For instance:
This demonstrates the OAuth 2.1 flow for the authorization code grant type, used for user auth.
NOTE: The following example assumes the MCP server is also functioning as the authorization server. However, the authorization server may be deployed as its own distinct service.
A human user completes the OAuth flow through a web browser, obtaining an access token that identifies them personally and allows the client to act on their behalf.
When authorization is required and not yet proven by the client, servers MUST respond with HTTP 401 Unauthorized.
Clients initiate the OAuth 2.1 IETF DRAFT authorization flow after receiving the HTTP 401 Unauthorized.
The following demonstrates the basic OAuth 2.1 for public clients using PKCE.
For server capability discovery:
The discovery flow is illustrated below:
MCP clients SHOULD include the header MCP-Protocol-Version: <protocol-version>
during
Server Metadata Discovery to allow the MCP server to respond based on the MCP protocol
version.
For example: MCP-Protocol-Version: 2024-11-05
The authorization base URL MUST be determined from the MCP server URL by discarding
any existing path
component. For example:
If the MCP server URL is https://api.example.com/v1/mcp
, then:
https://api.example.com
https://api.example.com/.well-known/oauth-authorization-server
This ensures authorization endpoints are consistently located at the root level of the domain hosting the MCP server, regardless of any path components in the MCP server URL.
For servers that do not implement OAuth 2.0 Authorization Server Metadata, clients MUST use the following default endpoint paths relative to the authorization base URL:
Endpoint | Default Path | Description |
---|---|---|
Authorization Endpoint | /authorize | Used for authorization requests |
Token Endpoint | /token | Used for token exchange & refresh |
Registration Endpoint | /register | Used for dynamic client registration |
For example, with an MCP server hosted at https://api.example.com/v1/mcp
, the default
endpoints would be:
https://api.example.com/authorize
https://api.example.com/token
https://api.example.com/register
Clients MUST first attempt to discover endpoints via the metadata document before falling back to default paths. When using default paths, all other protocol requirements remain unchanged.
MCP clients and servers SHOULD support the OAuth 2.0 Dynamic Client Registration Protocol to allow MCP clients to obtain OAuth client IDs without user interaction. This provides a standardized way for clients to automatically register with new servers, which is crucial for MCP because:
Any MCP servers that do not support Dynamic Client Registration need to provide alternative ways to obtain a client ID (and, if applicable, client secret). For one of these servers, MCP clients will have to either:
The complete Authorization flow proceeds as follows:
Access token handling MUST conform to OAuth 2.1 Section 5 requirements for resource requests. Specifically:
Note that authorization MUST be included in every HTTP request from client to server, even if they are part of the same logical session.
Example request:
Resource servers MUST validate access tokens as described in Section 5.2. If validation fails, servers MUST respond according to Section 5.3 error handling requirements. Invalid or expired tokens MUST receive a HTTP 401 response.
The following security requirements MUST be implemented:
Servers MUST return appropriate HTTP status codes for authorization errors:
Status Code | Description | Usage |
---|---|---|
401 | Unauthorized | Authorization required or token invalid |
403 | Forbidden | Invalid scopes or insufficient permissions |
400 | Bad Request | Malformed authorization request |
MCP servers MAY support delegated authorization through third-party authorization servers. In this flow, the MCP server acts as both an OAuth client (to the third-party auth server) and an OAuth authorization server (to the MCP client).
The third-party authorization flow comprises these steps:
MCP servers implementing third-party authorization MUST:
When implementing third-party authorization, servers MUST:
We strongly recommend that local clients implement OAuth 2.1 as a public client:
We strongly recommend that all clients implement metadata discovery. This reduces the need for users to provide endpoints manually or clients to fallback to the defined defaults.
Since clients do not know the set of MCP servers in advance, we strongly recommend the implementation of dynamic client registration. This allows applications to automatically register with the MCP server, and removes the need for users to obtain client ids manually.
The Model Context Protocol provides authorization capabilities at the transport level, enabling MCP clients to make requests to restricted MCP servers on behalf of resource owners. This specification defines the authorization flow for HTTP-based transports.
Authorization is OPTIONAL for MCP implementations. When supported:
This authorization mechanism is based on established specifications listed below, but implements a selected subset of their features to ensure security and interoperability while maintaining simplicity:
MCP auth implementations MUST implement OAuth 2.1 with appropriate security measures for both confidential and public clients.
MCP auth implementations SHOULD support the OAuth 2.0 Dynamic Client Registration Protocol (RFC7591).
MCP servers SHOULD and MCP clients MUST implement OAuth 2.0 Authorization Server Metadata (RFC8414). Servers that do not support Authorization Server Metadata MUST follow the default URI schema.
OAuth specifies different flows or grant types, which are different ways of obtaining an access token. Each of these targets different use cases and scenarios.
MCP servers SHOULD support the OAuth grant types that best align with the intended audience. For instance:
This demonstrates the OAuth 2.1 flow for the authorization code grant type, used for user auth.
NOTE: The following example assumes the MCP server is also functioning as the authorization server. However, the authorization server may be deployed as its own distinct service.
A human user completes the OAuth flow through a web browser, obtaining an access token that identifies them personally and allows the client to act on their behalf.
When authorization is required and not yet proven by the client, servers MUST respond with HTTP 401 Unauthorized.
Clients initiate the OAuth 2.1 IETF DRAFT authorization flow after receiving the HTTP 401 Unauthorized.
The following demonstrates the basic OAuth 2.1 for public clients using PKCE.
For server capability discovery:
The discovery flow is illustrated below:
MCP clients SHOULD include the header MCP-Protocol-Version: <protocol-version>
during
Server Metadata Discovery to allow the MCP server to respond based on the MCP protocol
version.
For example: MCP-Protocol-Version: 2024-11-05
The authorization base URL MUST be determined from the MCP server URL by discarding
any existing path
component. For example:
If the MCP server URL is https://api.example.com/v1/mcp
, then:
https://api.example.com
https://api.example.com/.well-known/oauth-authorization-server
This ensures authorization endpoints are consistently located at the root level of the domain hosting the MCP server, regardless of any path components in the MCP server URL.
For servers that do not implement OAuth 2.0 Authorization Server Metadata, clients MUST use the following default endpoint paths relative to the authorization base URL:
Endpoint | Default Path | Description |
---|---|---|
Authorization Endpoint | /authorize | Used for authorization requests |
Token Endpoint | /token | Used for token exchange & refresh |
Registration Endpoint | /register | Used for dynamic client registration |
For example, with an MCP server hosted at https://api.example.com/v1/mcp
, the default
endpoints would be:
https://api.example.com/authorize
https://api.example.com/token
https://api.example.com/register
Clients MUST first attempt to discover endpoints via the metadata document before falling back to default paths. When using default paths, all other protocol requirements remain unchanged.
MCP clients and servers SHOULD support the OAuth 2.0 Dynamic Client Registration Protocol to allow MCP clients to obtain OAuth client IDs without user interaction. This provides a standardized way for clients to automatically register with new servers, which is crucial for MCP because:
Any MCP servers that do not support Dynamic Client Registration need to provide alternative ways to obtain a client ID (and, if applicable, client secret). For one of these servers, MCP clients will have to either:
The complete Authorization flow proceeds as follows:
Access token handling MUST conform to OAuth 2.1 Section 5 requirements for resource requests. Specifically:
Note that authorization MUST be included in every HTTP request from client to server, even if they are part of the same logical session.
Example request:
Resource servers MUST validate access tokens as described in Section 5.2. If validation fails, servers MUST respond according to Section 5.3 error handling requirements. Invalid or expired tokens MUST receive a HTTP 401 response.
The following security requirements MUST be implemented:
Servers MUST return appropriate HTTP status codes for authorization errors:
Status Code | Description | Usage |
---|---|---|
401 | Unauthorized | Authorization required or token invalid |
403 | Forbidden | Invalid scopes or insufficient permissions |
400 | Bad Request | Malformed authorization request |
MCP servers MAY support delegated authorization through third-party authorization servers. In this flow, the MCP server acts as both an OAuth client (to the third-party auth server) and an OAuth authorization server (to the MCP client).
The third-party authorization flow comprises these steps:
MCP servers implementing third-party authorization MUST:
When implementing third-party authorization, servers MUST:
We strongly recommend that local clients implement OAuth 2.1 as a public client:
We strongly recommend that all clients implement metadata discovery. This reduces the need for users to provide endpoints manually or clients to fallback to the defined defaults.
Since clients do not know the set of MCP servers in advance, we strongly recommend the implementation of dynamic client registration. This allows applications to automatically register with the MCP server, and removes the need for users to obtain client ids manually.