You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
authorization flow after receiving the _HTTP 401 Unauthorized_.
75
+
The authorization server is responsible for interacting with the user and issuing access tokens for use at the MCP server. The implementation details of the authorization server are beyond the scope of this specification. It may be the same server as the
76
+
resource server or a separate entity. Section [2.3 Authorization Server Discovery](#2-3-authorizaton-server-discovery)
77
+
specifies how an MCP server indicates the location of an authorization server to a client.
84
78
85
-
The following demonstrates the basic OAuth 2.1 for public clients using PKCE.
79
+
### 2.3 Authorization Server Discovery
80
+
This section describes the mechanisms by which MCP servers advertise their associated
81
+
authorization servers to MCP clients, as well as the discovery process through which MCP
82
+
clients can determine authorization server endpoints and supported capabilities.
86
83
87
-
```mermaid
88
-
sequenceDiagram
89
-
participant B as User-Agent (Browser)
90
-
participant C as Client
91
-
participant M as MCP Server
84
+
### 2.3.1 Authorization Server Location
85
+
MCP servers **MUST** implement the [OAuth 2.0 Protected Resource Metadata](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-resource-metadata-13)
86
+
specification to indicate the locations of authorization servers. The Protected Resource Metadata document returned by the MCP server **MUST** include
87
+
the `authorization_servers` field containing at least one authorization server.
92
88
93
-
C->>M: MCP Request
94
-
M->>C: HTTP 401 Unauthorized
95
-
Note over C: Generate code_verifier and code_challenge
96
-
C->>B: Open browser with authorization URL + code_challenge
97
-
B->>M: GET /authorize
98
-
Note over M: User logs in and authorizes
99
-
M->>B: Redirect to callback URL with auth code
100
-
B->>C: Callback with authorization code
101
-
C->>M: Token Request with code + code_verifier
102
-
M->>C: Access Token (+ Refresh Token)
103
-
C->>M: MCP Request with Access Token
104
-
Note over C,M: Begin standard MCP message exchange
105
-
```
89
+
The specific use of `authorization_servers` is beyond the scope of this specification; implementers should consult
90
+
the [OAuth 2.0 Protected Resource Metadata](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-resource-metadata-13) documentation for
91
+
guidance on implementation details.
106
92
107
-
### 2.3 Server Metadata Discovery
93
+
MCP servers **MUST** use the HTTP header `WWW-Authenticate` when returning a _401 Unauthorized_ to indicate the location of the resource server metadata URL
94
+
as described in [OAuth 2.0 Protected Resource Metadata](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-resource-metadata-13).
108
95
109
-
For server capability discovery:
96
+
MCP clients **MUST** be able to parse `WWW-Authenticate` headers and respond appropriately to `HTTP 401 Unauthorized` responses from the MCP server.
110
97
111
-
- MCP clients _MUST_ follow the OAuth 2.0 Authorization Server Metadata protocol defined
112
-
in [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414).
113
-
- MCP server _SHOULD_ follow the OAuth 2.0 Authorization Server Metadata protocol.
114
-
- MCP servers that do not support the OAuth 2.0 Authorization Server Metadata protocol,
115
-
_MUST_ support fallback URLs.
116
98
117
-
The discovery flow is illustrated below:
99
+
#### 2.3.2 Server Metadata Discovery
118
100
119
-
```mermaid
120
-
sequenceDiagram
121
-
participant C as Client
122
-
participant S as Server
123
-
124
-
C->>S: GET /.well-known/oauth-authorization-server
125
-
alt Discovery Success
126
-
S->>C: 200 OK + Metadata Document
127
-
Note over C: Use endpoints from metadata
128
-
else Discovery Failed
129
-
S->>C: 404 Not Found
130
-
Note over C: Fall back to default endpoints
131
-
end
132
-
Note over C: Continue with authorization flow
133
-
```
101
+
MCP clients **MUST** follow the OAuth 2.0 Authorization Server Metadata protocol defined
102
+
in [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414) to obtain the information
103
+
required to interact with the authorization server.
134
104
135
-
#### 2.3.1 Server Metadata Discovery Headers
105
+
#### 2.3.3 MCP specific headers for discovery
136
106
137
-
MCP clients _SHOULD_ include the header `MCP-Protocol-Version: <protocol-version>` during
107
+
MCP clients **SHOULD** include the `MCP-Protocol-Version: <protocol-version>` HTTP header during
138
108
Server Metadata Discovery to allow the MCP server to respond based on the MCP protocol
139
109
version.
140
110
141
-
For example: `MCP-Protocol-Version: 2024-11-05`
142
-
143
-
#### 2.3.2 Authorization Base URL
111
+
MCP servers **SHOULD** use the `MCP-Protocol-Version` header to determine compatibility with the MCP client.
144
112
145
-
The authorization base URL **MUST** be determined from the MCP server URL by discarding
146
-
any existing `path` component. For example:
147
-
148
-
If the MCP server URL is `https://api.example.com/v1/mcp`, then:
113
+
For example: `MCP-Protocol-Version: 2024-11-05`
149
114
150
-
- The authorization base URL is `https://api.example.com`
0 commit comments