Skip to content

Commit 20a951a

Browse files
authored
Merge pull request modelcontextprotocol#734 from modelcontextprotocol/localden/rfc8707
chore: Add requirement for RFC8707
2 parents 47339c0 + 7f8f1b0 commit 20a951a

File tree

1 file changed

+57
-6
lines changed

1 file changed

+57
-6
lines changed

docs/specification/draft/basic/authorization.mdx

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,65 @@ sequenceDiagram
178178
A->>C: Client Credentials
179179
end
180180
181-
Note over C: Generate PKCE parameters
182-
C->>B: Open browser with authorization URL + code_challenge
183-
B->>A: Authorization request
181+
Note over C: Generate PKCE parameters<br/>Include resource parameter
182+
C->>B: Open browser with authorization URL + code_challenge + resource
183+
B->>A: Authorization request with resource parameter
184184
Note over A: User authorizes
185185
A->>B: Redirect to callback with authorization code
186186
B->>C: Authorization code callback
187-
C->>A: Token request + code_verifier
187+
C->>A: Token request + code_verifier + resource
188188
A->>C: Access token (+ refresh token)
189189
C->>M: MCP request with access token
190190
M-->>C: MCP response
191191
Note over C,M: MCP communication continues with valid token
192192
```
193193

194+
#### Resource Parameter Implementation
195+
196+
MCP clients **MUST** implement Resource Indicators for OAuth 2.0 as defined in [RFC 8707](https://www.rfc-editor.org/rfc/rfc8707.html)
197+
to explicitly specify the target resource for which the token is being requested. The `resource` parameter:
198+
199+
1. **MUST** be included in both authorization requests and token requests.
200+
2. **MUST** identify the MCP server that the client intends to use the token with.
201+
3. **MUST** use the canonical URI of the MCP server as defined in [RFC 8707 Section 2](https://www.rfc-editor.org/rfc/rfc8707.html#name-access-token-request).
202+
203+
##### Canonical Server URI
204+
205+
For the purposes of this specification, the canonical URI of an MCP server is defined as the resource identifier as specified in
206+
[RFC 8707 Section 2](https://www.rfc-editor.org/rfc/rfc8707.html#section-2) and aligns with the `resource` parameter in
207+
[RFC 9728](https://datatracker.ietf.org/doc/html/rfc9728). This URI:
208+
209+
1. **MUST** be an absolute URI, as specified by [Section 4.3 of RFC 3986](https://www.rfc-editor.org/rfc/rfc3986#section-4.3).
210+
1. **MUST** include the fully qualified domain name (FQDN) of the server.
211+
1. **MUST** include any non-default port if applicable (e.g., `https://mcp.example.com:8443`).
212+
1. **MUST NOT** include a fragment component.
213+
1. **SHOULD** use lowercase for the scheme and host components as per [RFC 3986 Section 6.2.2.1](https://www.rfc-editor.org/rfc/rfc3986#section-6.2.2.1), which defines this as the canonical form for comparison purposes.
214+
1. **SHOULD NOT** include a query component unless necessary for MCP server identification.
215+
1. **SHOULD NOT** include path components beyond what is necessary to uniquely identify the MCP server.
216+
217+
MCP clients **SHOULD** provide the most specific URI that they can for the MCP server they intend to access, following the guidance in [RFC 8707](https://www.rfc-editor.org/rfc/rfc8707). While the canonical form uses lowercase scheme and host components, implementations **SHOULD** accept uppercase scheme and host components for robustness and interoperability.
218+
219+
Examples of valid canonical URIs:
220+
221+
- `https://mcp.example.com`
222+
- `https://mcp.example.com:8443`
223+
- `https://mcp.example.com/server` (when path component is necessary to identify individual MCP server)
224+
225+
Examples of invalid canonical URIs:
226+
227+
- `mcp.example.com` (missing scheme)
228+
- `https://mcp.example.com#fragment` (contains fragment)
229+
230+
> **Note:** While both `https://mcp.example.com/` (with trailing slash) and `https://mcp.example.com` (without trailing slash) are technically valid absolute URIs according to [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986), implementations **SHOULD** consistently use the form without the trailing slash for better interoperability unless the trailing slash is semantically significant for the specific resource.
231+
232+
For example, if accessing an MCP server at `https://mcp.example.com`, the authorization request would include:
233+
234+
```
235+
&resource=https%3A%2F%2Fmcp.example.com
236+
```
237+
238+
MCP clients **MUST** send this parameter regardless of whether authorization servers support it.
239+
194240
### Access Token Usage
195241

196242
#### Token Requirements
@@ -223,6 +269,8 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
223269

224270
MCP servers, acting in their role as an OAuth 2.1 resource server, **MUST** validate access tokens as described in
225271
[OAuth 2.1 Section 5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.2).
272+
MCP servers **MUST** validate that access tokens were issued specifically for them as the intended audience,
273+
according to [RFC 8707 Section 2](https://www.rfc-editor.org/rfc/rfc8707.html#section-2).
226274
If validation fails, servers **MUST** respond according to
227275
[OAuth 2.1 Section 5.3](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.3)
228276
error handling requirements. Invalid or expired tokens **MUST** receive a HTTP 401
@@ -313,8 +361,11 @@ MCP servers **MUST** validate access tokens before processing the request, ensur
313361

314362
A MCP server **MUST** follow the guidelines in [OAuth 2.1 - Section 5.2](https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-12.html#section-5.2) to validate inbound tokens.
315363

316-
MCP servers **MUST** only accept tokens specifically intended for themselves.
364+
MCP servers **MUST** only accept tokens specifically intended for themselves and **MUST** reject tokens that do not include them in the audience claim or otherwise verify that they are the intended recipient of the token. See [Security Best Practices Section 2.2](/specification/draft/basic/security_best_practices#token-passthrough) for details.
317365

318366
If the MCP server makes requests to upstream APIs, it may act as an OAuth client to them. The access token used at the upstream API is a seperate token, issued by the upstream authorization server. The MCP server **MUST NOT** pass through the token it received from the MCP client.
319367

320-
If the authorization server supports the `resource` parameter, it is recommended that implementers follow [RFC 8707](https://www.rfc-editor.org/rfc/rfc8707.html) to prevent token misuse.
368+
MCP clients **MUST** implement and use the `resource` parameter as defined in [RFC 8707 - Resource Indicators for OAuth 2.0](https://www.rfc-editor.org/rfc/rfc8707.html)
369+
to explicitly specify the target resource for which the token is being requested. This requirement aligns with the recommendation in
370+
[RFC 9728 Section 7.4](https://datatracker.ietf.org/doc/html/rfc9728#section-7.4). This ensures that access tokens are bound to their intended resources and
371+
cannot be misused across different services.

0 commit comments

Comments
 (0)