Skip to content

Commit 245373c

Browse files
authored
Merge branch 'main' into localden/contrib
2 parents 233cca1 + 51e093b commit 245373c

File tree

5 files changed

+164
-5
lines changed

5 files changed

+164
-5
lines changed

MAINTAINERS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ This document lists current maintainers in the Model Context Protocol project.
7171

7272
- [Alex Hancock](https://github.com/alexhancock)
7373

74+
### PHP SDK
75+
76+
- [Kyrian Obikwelu](https://github.com/CodeWithKyrian)
77+
- [Christopher Hertel](https://github.com/chr-hertel)
78+
7479
## Project Maintainers
7580

7681
### use-mcp

docs/specification/draft/basic/authorization.mdx

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,33 @@ MCP servers **MUST** implement one of the following discovery mechanisms to prov
9898
- At the path of the server's MCP endpoint: `https://example.com/public/mcp` could host metadata at `https://example.com/.well-known/oauth-protected-resource/public/mcp`
9999
- At the root: `https://example.com/.well-known/oauth-protected-resource`
100100

101-
MCP clients **MUST** support both discovery mechanisms and use the resource metadata URL from the parsed WWW-Authenticate headers when present; otherwise, they **MUST** fall back to constructing and requesting the well-known URIs in the order listed above.
101+
MCP clients **MUST** support both discovery mechanisms and use the resource metadata URL from the parsed `WWW-Authenticate` headers when present; otherwise, they **MUST** fall back to constructing and requesting the well-known URIs in the order listed above.
102+
103+
MCP servers **SHOULD** include a `scope` parameter in the `WWW-Authenticate` header as defined in
104+
[RFC 6750 Section 3](https://datatracker.ietf.org/doc/html/rfc6750#section-3)
105+
to indicate the scopes required for accessing the resource. This provides clients with immediate
106+
guidance on the appropriate scopes to request during authorization,
107+
following the principle of least privilege and preventing clients from requesting excessive permissions.
108+
109+
The scopes included in the `WWW-Authenticate` challenge **MAY** match `scopes_supported`, be a subset
110+
or superset of it, or an alternative collection that is neither a strict subset nor
111+
superset. Clients **MUST NOT** assume any particular set relationship between the challenged
112+
scope set and `scopes_supported`. Clients **MUST** treat the scopes provided in the
113+
challenge as authoritative for satisfying the current request. Servers **SHOULD** strive for
114+
consistency in how they construct scope sets but they are not required to surface every dynamically
115+
issued scope through `scopes_supported`.
116+
117+
Example 401 response with scope guidance:
118+
119+
```http
120+
HTTP/1.1 401 Unauthorized
121+
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
122+
scope="files:read"
123+
```
124+
125+
MCP clients **MUST** be able to parse `WWW-Authenticate` headers and respond appropriately to `HTTP 401 Unauthorized` responses from the MCP server.
126+
127+
If the `scope` parameter is absent, clients **SHOULD** apply the fallback behavior defined in the [Scope Selection Strategy](#scope-selection-strategy) section.
102128

103129
#### Authorization Server Metadata Discovery
104130

@@ -190,6 +216,23 @@ these authorization servers, MCP clients will have to either:
190216
OAuth client themselves (e.g., through a configuration interface hosted by the
191217
server).
192218

219+
#### Scope Selection Strategy
220+
221+
When implementing authorization flows, MCP clients **SHOULD** follow the principle of least privilege by requesting
222+
only the scopes necessary for their intended operations. During the initial authorization handshake, MCP clients
223+
**SHOULD** follow this priority order for scope selection:
224+
225+
1. **Use `scope` parameter** from the initial `WWW-Authenticate` header in the 401 response, if provided
226+
2. **If `scope` is not available**, use all scopes defined in `scopes_supported` from the Protected Resource Metadata document, omitting the `scope` parameter if `scopes_supported` is undefined.
227+
228+
This approach accommodates the general-purpose nature of MCP clients, which typically lack domain-specific knowledge to make informed decisions about individual scope selection. Requesting all available scopes allows the authorization server and end-user to determine appropriate permissions during the consent process.
229+
230+
This approach minimizes user friction while following the principle of least privilege.
231+
The `scopes_supported` field is intended to represent the minimal set of scopes necessary
232+
for basic functionality (see [Scope Minimization](/specification/draft/basic/security_best_practices#scope-minimization)),
233+
with additional scopes requested incrementally through the step-up authorization flow steps
234+
described in the [Scope Challenge Handling](#scope-challenge-handling) section.
235+
193236
### Authorization Flow Steps
194237

195238
The complete Authorization flow proceeds as follows:
@@ -219,7 +262,7 @@ sequenceDiagram
219262
A->>C: Client Credentials
220263
end
221264
222-
Note over C: Generate PKCE parameters<br/>Include resource parameter
265+
Note over C: Generate PKCE parameters<br/>Include resource parameter<br/>Apply scope selection strategy
223266
C->>B: Open browser with authorization URL + code_challenge + resource
224267
B->>A: Authorization request with resource parameter
225268
Note over A: User authorizes
@@ -327,6 +370,69 @@ Servers **MUST** return appropriate HTTP status codes for authorization errors:
327370
| 403 | Forbidden | Invalid scopes or insufficient permissions |
328371
| 400 | Bad Request | Malformed authorization request |
329372

373+
#### Scope Challenge Handling
374+
375+
This section covers handling insufficient scope errors during runtime operations when
376+
a client already has a token but needs additional permissions. This follows the error
377+
handling patterns defined in [OAuth 2.1 Section 5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13#section-5)
378+
and leverages the metadata fields from [RFC 9728 (OAuth 2.0 Protected Resource Metadata)](https://datatracker.ietf.org/doc/html/rfc9728).
379+
380+
##### Runtime Insufficient Scope Errors
381+
382+
When a client makes a request with an access token with insufficient
383+
scope during runtime operations, the server **SHOULD** respond with:
384+
385+
- `HTTP 403 Forbidden` status code (per [RFC 6750 Section 3.1](https://datatracker.ietf.org/doc/html/rfc6750#section-3.1))
386+
- `WWW-Authenticate` header with the `Bearer` scheme and additional parameters:
387+
- `error="insufficient_scope"` - indicating the specific type of authorization failure
388+
- `scope="required_scope1 required_scope2"` - specifying the minimum scopes needed for the operation
389+
- `resource_metadata` - the URI of the Protected Resource Metadata document (for consistency with 401 responses)
390+
- `error_description` (optional) - human-readable description of the error
391+
392+
**Server Scope Management**: When responding with insufficient scope errors, servers
393+
**SHOULD** include the scopes needed to satisfy the current request in the `scope`
394+
parameter.
395+
396+
Servers have flexibility in determining which scopes to include:
397+
398+
- **Minimum approach**: Include the newly-required scopes for the specific operation. Include any existing granted scopes as well, if they are required, to prevent clients from losing previously granted permissions.
399+
- **Recommended approach**: Include both existing relevant scopes and newly required scopes to prevent clients from losing previously granted permissions
400+
- **Extended approach**: Include existing scopes, newly required scopes, and related scopes that commonly work together
401+
402+
The choice depends on the server's assessment of user experience impact and authorization friction.
403+
404+
Servers **SHOULD** be consistent in their scope inclusion strategy to provide predictable behavior for clients.
405+
406+
Servers **SHOULD** consider the user experience impact when determining which scopes to include in the
407+
response, as misconfigured scopes may require frequent user interaction.
408+
409+
Example insufficient scope response:
410+
411+
```http
412+
HTTP/1.1 403 Forbidden
413+
WWW-Authenticate: Bearer error="insufficient_scope",
414+
scope="files:read files:write user:profile",
415+
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
416+
error_description="Additional file write permission required"
417+
```
418+
419+
##### Step-Up Authorization Flow
420+
421+
Clients will receive scope-related errors during initial authorization or at runtime (`insufficient_scope`).
422+
Clients **SHOULD** respond to these errors by requesting a new access token with an increased set of scopes via a step-up authorization flow or handle the errors in other, appropriate ways.
423+
Clients acting on behalf of a user **SHOULD** attempt the step-up authorization flow. Clients acting on their own behalf (`client_credentials` clients)
424+
**MAY** attempt the step-up authorization flow or abort the request immediately.
425+
426+
The flow is as follows:
427+
428+
1. **Parse error information** from the authorization server response or `WWW-Authenticate` header
429+
2. **Determine required scopes** as outlined in [Scope Selection Strategy](#scope-selection-strategy).
430+
3. **Initiate (re-)authorization** with the determined scope set
431+
4. **Retry the original request** with the new authorization no more than a few times and treat this as a permanent authorization failure
432+
433+
Clients **SHOULD** implement retry limits and **SHOULD** track scope upgrade attempts to avoid
434+
repeated failures for the same resource and operation combination.
435+
330436
## Security Considerations
331437

332438
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-13#name-security-considerations).

docs/specification/draft/basic/security_best_practices.mdx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,49 @@ MCP servers intending for their servers to be run locally **SHOULD** implement m
289289
- Restrict access if using an HTTP transport, such as:
290290
- Require an authorization token
291291
- Use unix domain sockets or other Interprocess Communication (IPC) mechanisms with restricted access
292+
293+
### Scope Minimization
294+
295+
Poor scope design increases token compromise impact, elevates user friction, and obscures audit trails.
296+
297+
#### Attack Description
298+
299+
An attacker obtains (via log leakage, memory scraping, or local interception) an access token carrying broad scopes (`files:*`, `db:*`, `admin:*`) that were granted up front because the MCP server exposed every scope in `scopes_supported` and the client requested them all. The token enables lateral data access, privilege chaining, and difficult revocation without re-consenting the entire surface.
300+
301+
#### Risks
302+
303+
- Expanded blast radius: stolen broad token enables unrelated tool/resource access
304+
- Higher friction on revocation: revoking a max-privilege token disrupts all workflows
305+
- Audit noise: single omnibus scope masks user intent per operation
306+
- Privilege chaining: attacker can immediately invoke high-risk tools without further elevation prompts
307+
- Consent abandonment: users decline dialogs listing excessive scopes
308+
- Scope inflation blindness: lack of metrics makes over-broad requests normalised
309+
310+
#### Mitigation
311+
312+
Implement a progressive, least-privilege scope model:
313+
314+
- Minimal initial scope set (e.g., `mcp:tools-basic`) containing only low-risk discovery/read operations
315+
- Incremental elevation via targeted `WWW-Authenticate` `scope="..."` challenges when privileged operations are first attempted
316+
- Down-scoping tolerance: server should accept reduced scope tokens; auth server MAY issue a subset of requested scopes
317+
318+
Server guidance:
319+
320+
- Emit precise scope challenges; avoid returning the full catalog
321+
- Log elevation events (scope requested, granted subset) with correlation IDs
322+
323+
Client guidance:
324+
325+
- Begin with only baseline scopes (or those specified by initial `WWW-Authenticate`)
326+
- Cache recent failures to avoid repeated elevation loops for denied scopes
327+
328+
#### Common Mistakes
329+
330+
- Publishing all possible scopes in `scopes_supported`
331+
- Using wildcard or omnibus scopes (`*`, `all`, `full-access`)
332+
- Bundling unrelated privileges to preempt future prompts
333+
- Returning entire scope catalog in every challenge
334+
- Silent scope semantic changes without versioning
335+
- Treating claimed scopes in token as sufficient without server-side authorization logic
336+
337+
Proper minimization constrains compromise impact, improves audit clarity, and reduces consent churn.

docs/specification/draft/changelog.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ the previous revision, [2025-06-18](/specification/2025-06-18).
1111

1212
1. Enhance authorization server discovery with support for [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html). (PR [#797](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/797))
1313
2. Allow servers to expose icons as additional metadata for tools, resources, resource templates, and prompts ([SEP-973](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/973)).
14+
3. Enhance authorization flows with incremental scope consent via `WWW-Authenticate` ([SEP-835](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/835))
1415

1516
## Minor changes
1617

1718
1. Clarify that servers must respond with HTTP 403 Forbidden for invalid Origin headers in Streamable HTTP transport. (PR [#1439](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1439))
19+
2. Updated the [Security Best Practices guidance](https://modelcontextprotocol.io/specification/draft/basic/security_best_practices).
1820

1921
## Other schema changes
2022

docs/specification/draft/server/utilities/completion.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ title: Completion
77
<Info>**Protocol Revision**: draft</Info>
88

99
The Model Context Protocol (MCP) provides a standardized way for servers to offer
10-
argument autocompletion suggestions for prompts and resource URIs. This enables rich,
11-
IDE-like experiences where users receive contextual suggestions while entering argument
12-
values.
10+
autocompletion suggestions for the arguments of prompts and resource templates. When
11+
users are filling in argument values for a specific prompt (identified by name) or
12+
resource template (identified by URI), servers can provide contextual suggestions.
1313

1414
## User Interaction Model
1515

0 commit comments

Comments
 (0)