@@ -4,15 +4,15 @@ title: Authorization
4
4
5
5
<Info >** Protocol Revision** : 2025-03-26</Info >
6
6
7
- ## 1. Introduction
7
+ ## Introduction
8
8
9
- ### 1.1 Purpose and Scope
9
+ ### Purpose and Scope
10
10
11
11
The Model Context Protocol provides authorization capabilities at the transport level,
12
12
enabling MCP clients to make requests to restricted MCP servers on behalf of resource
13
13
owners. This specification defines the authorization flow for HTTP-based transports.
14
14
15
- ### 1.2 Protocol Requirements
15
+ ### Protocol Requirements
16
16
17
17
Authorization is ** OPTIONAL** for MCP implementations. When supported:
18
18
@@ -22,7 +22,7 @@ Authorization is **OPTIONAL** for MCP implementations. When supported:
22
22
- Implementations using alternative transports ** MUST** follow established security best
23
23
practices for their protocol.
24
24
25
- ### 1.3 Standards Compliance
25
+ ### Standards Compliance
26
26
27
27
This authorization mechanism is based on established specifications listed below, but
28
28
implements a selected subset of their features to ensure security and interoperability
@@ -34,9 +34,9 @@ while maintaining simplicity:
34
34
- OAuth 2.0 Dynamic Client Registration Protocol
35
35
([ RFC7591] ( https://datatracker.ietf.org/doc/html/rfc7591 ) )
36
36
37
- ## 2. Authorization Flow
37
+ ## Authorization Flow
38
38
39
- ### 2.1 Overview
39
+ ### Overview
40
40
41
41
1 . MCP auth implementations ** MUST** implement OAuth 2.1 with appropriate security
42
42
measures for both confidential and public clients.
@@ -49,7 +49,7 @@ while maintaining simplicity:
49
49
that do not support Authorization Server Metadata ** MUST** follow the default URI
50
50
schema.
51
51
52
- ### 2.1.1 OAuth Grant Types
52
+ ### OAuth Grant Types
53
53
54
54
OAuth specifies different flows or grant types, which are different ways of obtaining an
55
55
access token. Each of these targets different use cases and scenarios.
@@ -63,7 +63,7 @@ audience. For instance:
63
63
- For instance, an agent calls a secure MCP tool to check inventory at a specific
64
64
store. No need to impersonate the end user.
65
65
66
- ### 2.2 Example: authorization code grant
66
+ ### Example: authorization code grant
67
67
68
68
This demonstrates the OAuth 2.1 flow for the authorization code grant type, used for user
69
69
auth.
@@ -104,7 +104,7 @@ sequenceDiagram
104
104
Note over C,M: Begin standard MCP message exchange
105
105
```
106
106
107
- ### 2.3 Server Metadata Discovery
107
+ ### Server Metadata Discovery
108
108
109
109
For server capability discovery:
110
110
@@ -132,15 +132,15 @@ sequenceDiagram
132
132
Note over C: Continue with authorization flow
133
133
```
134
134
135
- #### 2.3.1 Server Metadata Discovery Headers
135
+ #### Server Metadata Discovery Headers
136
136
137
137
MCP clients _ SHOULD_ include the header ` MCP-Protocol-Version: <protocol-version> ` during
138
138
Server Metadata Discovery to allow the MCP server to respond based on the MCP protocol
139
139
version.
140
140
141
141
For example: ` MCP-Protocol-Version: 2024-11-05 `
142
142
143
- #### 2.3.2 Authorization Base URL
143
+ #### Authorization Base URL
144
144
145
145
The authorization base URL ** MUST** be determined from the MCP server URL by discarding
146
146
any existing ` path ` component. For example:
@@ -154,11 +154,11 @@ If the MCP server URL is `https://api.example.com/v1/mcp`, then:
154
154
This ensures authorization endpoints are consistently located at the root level of the
155
155
domain hosting the MCP server, regardless of any path components in the MCP server URL.
156
156
157
- #### 2.3.3 Fallbacks for Servers without Metadata Discovery
157
+ #### Fallbacks for Servers without Metadata Discovery
158
158
159
159
For servers that do not implement OAuth 2.0 Authorization Server Metadata, clients
160
- ** MUST** use the following default endpoint paths relative to the authorization base URL
161
- (as defined in [ Section 2.3.2 ] ( #232- authorization-base-url ) ):
160
+ ** MUST** use the following default endpoint paths relative to the [ authorization base
161
+ URL ] ( #authorization-base-url ) :
162
162
163
163
| Endpoint | Default Path | Description |
164
164
| ---------------------- | ------------ | ------------------------------------ |
@@ -177,7 +177,7 @@ Clients **MUST** first attempt to discover endpoints via the metadata document b
177
177
falling back to default paths. When using default paths, all other protocol requirements
178
178
remain unchanged.
179
179
180
- ### 2.4 Dynamic Client Registration
180
+ ### Dynamic Client Registration
181
181
182
182
MCP clients and servers ** SHOULD** support the
183
183
[ OAuth 2.0 Dynamic Client Registration Protocol] ( https://datatracker.ietf.org/doc/html/rfc7591 )
@@ -200,7 +200,7 @@ these servers, MCP clients will have to either:
200
200
OAuth client themselves (e.g., through a configuration interface hosted by the
201
201
server).
202
202
203
- ### 2.5 Authorization Flow Steps
203
+ ### Authorization Flow Steps
204
204
205
205
The complete Authorization flow proceeds as follows:
206
206
@@ -233,7 +233,7 @@ sequenceDiagram
233
233
C->>M: API Requests with Access Token
234
234
```
235
235
236
- #### 2.5.1 Decision Flow Overview
236
+ #### Decision Flow Overview
237
237
238
238
``` mermaid
239
239
flowchart TD
@@ -257,9 +257,9 @@ flowchart TD
257
257
N --> O[Use Access Token]
258
258
```
259
259
260
- ### 2.6 Access Token Usage
260
+ ### Access Token Usage
261
261
262
- #### 2.6.1 Token Requirements
262
+ #### Token Requirements
263
263
264
264
Access token handling ** MUST** conform to
265
265
[ OAuth 2.1 Section 5] ( https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5 )
@@ -285,7 +285,7 @@ Host: mcp.example.com
285
285
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
286
286
```
287
287
288
- #### 2.6.2 Token Handling
288
+ #### Token Handling
289
289
290
290
Resource servers ** MUST** validate access tokens as described in
291
291
[ Section 5.2] ( https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.2 ) .
@@ -294,7 +294,7 @@ If validation fails, servers **MUST** respond according to
294
294
error handling requirements. Invalid or expired tokens ** MUST** receive a HTTP 401
295
295
response.
296
296
297
- ### 2.7 Security Considerations
297
+ ### Security Considerations
298
298
299
299
The following security requirements ** MUST** be implemented:
300
300
@@ -304,7 +304,7 @@ The following security requirements **MUST** be implemented:
304
304
4 . Servers ** MUST** validate redirect URIs to prevent open redirect vulnerabilities
305
305
5 . Redirect URIs ** MUST** be either localhost URLs or HTTPS URLs
306
306
307
- ### 2.8 Error Handling
307
+ ### Error Handling
308
308
309
309
Servers ** MUST** return appropriate HTTP status codes for authorization errors:
310
310
@@ -314,22 +314,22 @@ Servers **MUST** return appropriate HTTP status codes for authorization errors:
314
314
| 403 | Forbidden | Invalid scopes or insufficient permissions |
315
315
| 400 | Bad Request | Malformed authorization request |
316
316
317
- ### 2.9 Implementation Requirements
317
+ ### Implementation Requirements
318
318
319
319
1 . Implementations ** MUST** follow OAuth 2.1 security best practices
320
320
2 . PKCE is ** REQUIRED** for all clients
321
321
3 . Token rotation ** SHOULD** be implemented for enhanced security
322
322
4 . Token lifetimes ** SHOULD** be limited based on security requirements
323
323
324
- ### 2.10 Third-Party Authorization Flow
324
+ ### Third-Party Authorization Flow
325
325
326
- #### 2.10.1 Overview
326
+ #### Overview
327
327
328
328
MCP servers ** MAY** support delegated authorization through third-party authorization
329
329
servers. In this flow, the MCP server acts as both an OAuth client (to the third-party
330
330
auth server) and an OAuth authorization server (to the MCP client).
331
331
332
- #### 2.10.2 Flow Description
332
+ #### Flow Description
333
333
334
334
The third-party authorization flow comprises these steps:
335
335
@@ -363,7 +363,7 @@ sequenceDiagram
363
363
M->>C: MCP access token
364
364
```
365
365
366
- #### 2.10.3 Session Binding Requirements
366
+ #### Session Binding Requirements
367
367
368
368
MCP servers implementing third-party authorization ** MUST** :
369
369
@@ -372,7 +372,7 @@ MCP servers implementing third-party authorization **MUST**:
372
372
3 . Implement appropriate token lifecycle management
373
373
4 . Handle third-party token expiration and renewal
374
374
375
- #### 2.10.4 Security Considerations
375
+ #### Security Considerations
376
376
377
377
When implementing third-party authorization, servers ** MUST** :
378
378
@@ -382,9 +382,9 @@ When implementing third-party authorization, servers **MUST**:
382
382
4 . Consider security implications of token chaining
383
383
5 . Implement proper error handling for third-party auth failures
384
384
385
- ## 3. Best Practices
385
+ ## Best Practices
386
386
387
- #### 3.1 Local clients as Public OAuth 2.1 Clients
387
+ #### Local clients as Public OAuth 2.1 Clients
388
388
389
389
We strongly recommend that local clients implement OAuth 2.1 as a public client:
390
390
@@ -394,13 +394,13 @@ We strongly recommend that local clients implement OAuth 2.1 as a public client:
394
394
3 . Following token refresh best practices to maintain sessions
395
395
4 . Properly handling token expiration and renewal
396
396
397
- #### 3.2 Authorization Metadata Discovery
397
+ #### Authorization Metadata Discovery
398
398
399
399
We strongly recommend that all clients implement metadata discovery. This reduces the
400
400
need for users to provide endpoints manually or clients to fallback to the defined
401
401
defaults.
402
402
403
- #### 3.3 Dynamic Client Registration
403
+ #### Dynamic Client Registration
404
404
405
405
Since clients do not know the set of MCP servers in advance, we strongly recommend the
406
406
implementation of dynamic client registration. This allows applications to automatically
0 commit comments