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