pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/modelcontextprotocol/python-sdk/pull/2373

8641c0a1f3e0.css" /> fix(auth): respect explicitly-set client_metadata.scope during discovery by chasewhughes · Pull Request #2373 · modelcontextprotocol/python-sdk · GitHub
Skip to content

fix(auth): respect explicitly-set client_metadata.scope during discovery#2373

Open
chasewhughes wants to merge 1 commit intomodelcontextprotocol:mainfrom
chasewhughes:fix/respect-explicit-client-scopes
Open

fix(auth): respect explicitly-set client_metadata.scope during discovery#2373
chasewhughes wants to merge 1 commit intomodelcontextprotocol:mainfrom
chasewhughes:fix/respect-explicit-client-scopes

Conversation

@chasewhughes
Copy link
Copy Markdown

Problem

async_auth_flow unconditionally overwrites client_metadata.scope with server-advertised scopes during OAuth discovery (Step 3). This prevents clients from limiting their requested permissions, which is required by some servers — for example, the official SalesForce MCP server rejects requests that include scopes not authorized for the given client application.

Solution

Only apply automatic scope selection when client_metadata.scope is None. If the caller has explicitly set scopes, they are preserved through the discovery flow.

The 403 step-up flow (insufficient_scope) is intentionally left unchanged — when a server explicitly demands different scopes, those should override regardless.

Tests

Two new tests:

  • test_auth_flow_preserves_explicit_scopes — verifies that explicitly-set scopes survive the discovery flow
  • test_auth_flow_auto_selects_scopes_when_none — verifies that auto-selection still works when no explicit scope is set

All 86 tests in test_auth.py pass.

Fixes #2317

The scope selection strategy in async_auth_flow unconditionally
overwrites client_metadata.scope with server-advertised scopes. This
is problematic when the caller has explicitly set scopes to limit
permissions or to avoid rejection by servers that only permit certain
scopes (e.g. SalesForce MCP server).

Only apply automatic scope selection when client_metadata.scope is
None, preserving any explicitly-set value.

Github-Issue: modelcontextprotocol#2317
Reported-by: jbweston
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't override client_metadata.scopes if they are already set

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy