Skip to content

Fix Azure scope fallback - #4469

Merged
jlowin merged 1 commit into
mainfrom
codex/low-hanging-fruit
Jul 9, 2026
Merged

Fix Azure scope fallback#4469
jlowin merged 1 commit into
mainfrom
codex/low-hanging-fruit

Conversation

@zzstoatzz

Copy link
Copy Markdown
Collaborator

Azure-backed servers currently authorize successfully when an MCP client omits scope, because the authorize URL falls back to the provider's configured required_scopes. The token exchange path did not make the same fallback, so Entra could receive a token request whose scope was only offline_access, which it rejects with AADSTS70011.

This keeps the existing authorize behavior and applies the same fallback when preparing Azure token-exchange and refresh scopes. Scope-sending clients keep their requested scopes; scope-omitting clients now exchange and refresh against the configured API scope instead of offline_access alone.

provider = AzureProvider(
    client_id="...",
    client_secret="...",
    tenant_id="...",
    required_scopes=["mcp.access"],
    base_url="https://example.com/mcp",
)

provider._prepare_scopes_for_token_exchange([])
# ["api://.../mcp.access", "offline_access"]

Fixes #4467

馃 Generated with Codex

@marvin-context-protocol marvin-context-protocol Bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. auth Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server. labels Jul 8, 2026
馃 Generated with Codex
@zzstoatzz
zzstoatzz force-pushed the codex/low-hanging-fruit branch from 9e213bf to cf51d3e Compare July 9, 2026 18:38
@zzstoatzz
zzstoatzz marked this pull request as ready for review July 9, 2026 18:40
@jlowin
jlowin merged commit 1d932cc into main Jul 9, 2026
16 checks passed
@jlowin
jlowin deleted the codex/low-hanging-fruit branch July 9, 2026 19:29
jlowin added a commit that referenced this pull request Jul 27, 2026
(cherry picked from commit 1d932cc)

Co-authored-by: nate nowack <thrast36@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server. bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AzureProvider sends only offline_access during code exchange when the client omits scope (AADSTS70011)

2 participants