Skip to content

Commit 679cc65

Browse files
authored
Merge branch 'main' into pcarleton/token-validation
2 parents 6b5c214 + 3addaff commit 679cc65

File tree

8 files changed

+426
-103
lines changed

8 files changed

+426
-103
lines changed

docs/clients.mdx

Lines changed: 60 additions & 55 deletions
Large diffs are not rendered by default.

docs/docs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@
261261
"anchor": "C# SDK",
262262
"href": "https://github.com/modelcontextprotocol/csharp-sdk",
263263
"icon": "square-c"
264+
},
265+
{
266+
"anchor": "Swift SDK",
267+
"href": "https://github.com/modelcontextprotocol/swift-sdk",
268+
"icon": "swift"
264269
}
265270
]
266271
}

docs/examples.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ These MCP servers are maintained by companies for their platforms:
5151
- **[Qdrant](https://github.com/qdrant/mcp-server-qdrant/)** - Implement semantic memory using the Qdrant vector search engine
5252
- **[Raygun](https://github.com/MindscapeHQ/mcp-server-raygun)** - Access crash reporting and monitoring data
5353
- **[Search1API](https://github.com/fatwang2/search1api-mcp)** - Unified API for search, crawling, and sitemaps
54+
- **[Snyk](https://github.com/snyk/snyk-ls/tree/main/mcp_extension)** - Enhance security posture by embedding [Snyk](https://snyk.io) vulnerability scanning directly into agentic workflows.
5455
- **[Stripe](https://github.com/stripe/agent-toolkit)** - Interact with the Stripe API
5556
- **[Tinybird](https://github.com/tinybirdco/mcp-tinybird)** - Interface with the Tinybird serverless ClickHouse platform
5657
- **[Weaviate](https://github.com/weaviate/mcp-server-weaviate)** - Enable Agentic RAG through your Weaviate collection(s)

docs/specification/draft/basic/authorization.mdx

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,9 @@ while maintaining simplicity:
4848
1. MCP servers **MUST** implement OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728)).
4949
MCP clients **MUST** use OAuth 2.0 Protected Resource Metadata for authorization server discovery.
5050

51-
1. MCP authorization servers and MCP clients **MUST** implement OAuth 2.0 Authorization
51+
1. MCP authorization servers **MUST** provide OAuth 2.0 Authorization
5252
Server Metadata ([RFC8414](https://datatracker.ietf.org/doc/html/rfc8414)).
53-
54-
### 2.1.1 OAuth Grant Types
55-
56-
OAuth specifies different flows or grant types, which are different ways of obtaining an
57-
access token. Each of these targets different use cases and scenarios.
58-
59-
MCP servers **SHOULD** support the OAuth grant types that best align with the intended
60-
audience. For instance:
61-
62-
1. Authorization Code: useful when the client is acting on behalf of a (human) end user.
63-
- For instance, an agent calls an MCP tool implemented by a SaaS system.
64-
2. Client Credentials: the client is another application (not a human)
65-
- For instance, an agent calls a secure MCP tool to check inventory at a specific
66-
store. No need to impersonate the end user.
53+
MCP clients **MUST** use the OAuth 2.0 Authorization Server Metadata.
6754

6855
### 2.2 Roles
6956
A protected MCP server acts as a [OAuth 2.1 resource server](https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-12.html#name-roles),
@@ -72,7 +59,8 @@ capable of accepting and responding to protected resource requests using access
7259
An MCP client acts as an [OAuth 2.1 client](https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-12.html#name-roles),
7360
making protected resource requests on behalf of a resource owner.
7461

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
62+
The authorization server is responsible for interacting with the user (if necessary) and issuing access tokens for use at the MCP server.
63+
The implementation details of the authorization server are beyond the scope of this specification. It may be hosted with the
7664
resource server or a separate entity. Section [2.3 Authorization Server Discovery](#2-3-authorizaton-server-discovery)
7765
specifies how an MCP server indicates the location of its corresponding authorization server to a client.
7866

@@ -83,7 +71,7 @@ clients can determine authorization server endpoints and supported capabilities.
8371

8472
### 2.3.1 Authorization Server Location
8573

86-
MCP servers **MUST** implement OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728))
74+
MCP servers **MUST** implement the OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728))
8775
specification to indicate the locations of authorization servers. The Protected Resource Metadata document returned by the MCP server **MUST** include
8876
the `authorization_servers` field containing at least one authorization server.
8977

@@ -95,15 +83,14 @@ Implementors should note that Protected Resource Metadata documents can define m
9583
[RFC9728 Section 7.6 "Authorization Servers"](https://datatracker.ietf.org/doc/html/rfc9728#name-authorization-servers).
9684

9785
MCP servers **MUST** use the HTTP header `WWW-Authenticate` when returning a _401 Unauthorized_ to indicate the location of the resource server metadata URL
98-
as described in OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728)).
86+
as described in [RFC9728 Section 5.1 "WWW-Authenticate Response"](https://datatracker.ietf.org/doc/html/rfc9728#name-www-authenticate-response).
9987

10088
MCP clients **MUST** be able to parse `WWW-Authenticate` headers and respond appropriately to `HTTP 401 Unauthorized` responses from the MCP server.
10189

10290
#### 2.3.2 Server Metadata Discovery
10391

104-
MCP clients **MUST** follow the OAuth 2.0 Authorization Server Metadata protocol defined
105-
in [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414) to obtain the information
106-
required to interact with the authorization server.
92+
MCP clients **MUST** follow the OAuth 2.0 Authorization Server Metadata [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414)
93+
specification to obtain the information required to interact with the authorization server.
10794

10895
#### 2.3.4 Sequence Diagram
10996
The following diagram outlines an example flow:
@@ -147,7 +134,7 @@ For example: `MCP-Protocol-Version: 2024-11-05`
147134
### 2.5 Dynamic Client Registration
148135

149136
MCP clients and authorization servers **SHOULD** support the
150-
[OAuth 2.0 Dynamic Client Registration Protocol](https://datatracker.ietf.org/doc/html/rfc7591)
137+
OAuth 2.0 Dynamic Client Registration Protocol [RFC7591](https://datatracker.ietf.org/doc/html/rfc7591)
151138
to allow MCP clients to obtain OAuth client IDs without user interaction. This provides a
152139
standardized way for clients to automatically register with new authorization servers, which is crucial
153140
for MCP because:
@@ -161,8 +148,8 @@ Any MCP authorization servers that _do not_ support Dynamic Client Registration
161148
alternative ways to obtain a client ID (and, if applicable, client credentials). For one of
162149
these authorization servers, MCP clients will have to either:
163150

164-
1. Hardcode a client ID (and, if applicable, client credentials) specifically for that MCP
165-
server, or
151+
1. Hardcode a client ID (and, if applicable, client credentials) specifically for the MCP client to use when
152+
interacting with that authorization server, or
166153
2. Present a UI to users that allows them to enter these details, after registering an
167154
OAuth client themselves (e.g., through a configuration interface hosted by the
168155
server).
@@ -200,18 +187,19 @@ sequenceDiagram
200187
A->>C: Access token (+ refresh token)
201188
C->>M: MCP request with access token
202189
M-->>C: MCP response
190+
Note over C,M: MCP communication continues with valid token
203191
```
204192

205193
### 2.7 Access Token Usage
206194

207195
#### 2.7.1 Token Requirements
208196

209-
Access token handling **MUST** conform to
210-
[OAuth 2.1 Section 5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5)
211-
requirements for resource requests. Specifically:
197+
Access token handling when making requests to MCP servers **MUST** conform to the requirements defined in
198+
[OAuth 2.1 Section 5 "Resource Requests"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5).
199+
Specifically:
212200

213-
1. MCP client **MUST** use the Authorization request header field
214-
[Section 5.1.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.1.1):
201+
1. MCP client **MUST** use the Authorization request header field defined in
202+
[OAuth 2.1 Section 5.1.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.1.1):
215203

216204
```
217205
Authorization: Bearer <access-token>
@@ -232,10 +220,10 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
232220

233221
#### 2.7.2 Token Handling
234222

235-
Resource servers **MUST** validate access tokens as described in
236-
[Section 5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.2).
223+
MCP servers, acting in their role as an OAuth 2.1 resource server, **MUST** validate access tokens as described in
224+
[OAuth 2.1 Section 5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.2).
237225
If validation fails, servers **MUST** respond according to
238-
[Section 5.3](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.3)
226+
[OAuth 2.1 Section 5.3](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.3)
239227
error handling requirements. Invalid or expired tokens **MUST** receive a HTTP 401
240228
response.
241229

@@ -246,7 +234,6 @@ own resources.
246234

247235
MCP servers **MUST NOT** accept or transit any other tokens.
248236

249-
250237
### 2.8 Error Handling
251238

252239
Servers **MUST** return appropriate HTTP status codes for authorization errors:
@@ -259,32 +246,38 @@ Servers **MUST** return appropriate HTTP status codes for authorization errors:
259246

260247
## 3. Security Considerations
261248

262-
Implementations **MUST** follow OAuth 2.1 security best practices as laid out in [Section 7. Security Considerations](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#name-security-considerations).
249+
Implementations **MUST** follow OAuth 2.1 security best practices as laid out in [OAuth 2.1 Section 7. "Security Considerations"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#name-security-considerations).
263250

264251
### 3.1 Token Theft
252+
265253
Attackers who obtain tokens stored by the client, or tokens cached or logged on the server can access protected resources with
266254
requests that appear legitimate to resource servers.
267255

268-
Clients **MUST** implement secure token storage and follow OAuth best practices,
269-
as outlined in [OAuth 2.1, section 7.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.1).
256+
Clients and servers **MUST** implement secure token storage and follow OAuth best practices,
257+
as outlined in [OAuth 2.1, Section 7.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.1).
270258

271-
MCP authorization servers SHOULD issue short-lived access tokens token to reduce the impact of leaked tokens. For public clients, MCP authorization servers MUST rotate refresh tokens as described in [Section 4.3.1 of OAuth 2.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-4.3.1).
259+
MCP authorization servers SHOULD issue short-lived access tokens token to reduce the impact of leaked tokens.
260+
For public clients, MCP authorization servers **MUST** rotate refresh tokens as described in [OAuth 2.1 Section 4.3.1 "Refresh Token Grant"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-4.3.1).
272261

273262
### 3.2 Communication Security
274-
Implementations MUST follow [OAuth 2.1 section 1.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-1.5).
263+
264+
Implementations **MUST** follow [OAuth 2.1 Section 1.5 "Communication Security"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-1.5).
275265

276266
Specifically:
267+
277268
1. All authorization server endpoints **MUST** be served over HTTPS.
278269
1. All redirect URIs **MUST** be either `localhost` or use HTTPS.
279270

280271
### 3.3 Authorization Code Protection
281272

282-
An attacker who has gained access to an authorization code contained in an authorization response can try to redeem the authorization code for an access token or otherwise make use of the authorization code. (Further described in [OAuth 2.1, section 7.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5))
283-
284-
MCP clients **MUST** implement PKCE according to [OAuth 2.1 section 7.5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5.2). PKCE helps prevent authorization code interception and injection attacks by requiring clients to create a secret verifier-challenge pair, ensuring that only the original requestor can exchange an authorization code for tokens.
273+
An attacker who has gained access to an authorization code contained in an authorization response can try to redeem the authorization code for an access token or otherwise make use of the authorization code.
274+
(Further described in [OAuth 2.1 Section 7.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5))
285275

276+
To mitigate this, MCP clients **MUST** implement PKCE according to [OAuth 2.1 Section 7.5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5.2).
277+
PKCE helps prevent authorization code interception and injection attacks by requiring clients to create a secret verifier-challenge pair, ensuring that only the original requestor can exchange an authorization code for tokens.
286278

287279
### 3.3 Open Redirection
280+
288281
An attacker may craft malicious redirect URIs to direct users to phishing sites.
289282

290283
MCP clients **MUST** have redirect URIs registered with the authorization server.
@@ -294,13 +287,15 @@ Authorization servers **MUST** validate exact redirect URIs against pre-register
294287
MCP clients **SHOULD** use and verify state parameters in the authorization code flow
295288
and discard any results that do not include or have a mis-match with the original state.
296289

297-
Authorization servers **MUST** take precautions to prevent redirecting user agents to untrusted URI's, following suggestions laid out in [OAuth 2.1, Section 7.12.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.12.2)
290+
Authorization servers **MUST** take precautions to prevent redirecting user agents to untrusted URI's, following suggestions laid out in [OAuth 2.1 Section 7.12.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.12.2)
298291

299292
Authorization servers **SHOULD** only automatically redirect the user agent if it trusts the redirection URI. If the URI is not trusted, the authorization server MAY inform the user and rely on the user to make the correct decision.
300293

301294
### 3.4 Confused Deputy Problem
302295

303-
Attackers can exploit MCP servers acting as intermediaries to third-party APIs, leading to confused deputy vulnerabilities. By using stolen authorization codes, they can obtain access tokens without user consent. See [Security Best Practices 2.1](/specification/draft/basic/security_best_practices) for details.
296+
Attackers can exploit MCP servers acting as intermediaries to third-party APIs, leading to confused deputy vulnerabilities.
297+
By using stolen authorization codes, they can obtain access tokens without user consent.
298+
See [Security Best Practices 2.1](/specification/draft/basic/security_best_practices) for details.
304299

305300
MCP proxy servers using static client IDs **MUST** obtain user consent for each dynamically
306301
registered client before forwarding to third-party authorization servers (which may require additional consent).

0 commit comments

Comments
 (0)