Visitar URL original
Backport #4469 to release/3.x: fix Azure scope fallback by jlowin 路 Pull Request #4662 路 PrefectHQ/fastmcp 路 GitHub
Skip to content

Backport #4469 to release/3.x: fix Azure scope fallback - #4662

Merged
jlowin merged 1 commit into
release/3.xfrom
backport/4469-azure-scope-fallback
Jul 27, 2026
Merged

jlowin merged 1 commit into
release/3.xfrom
backport/4469-azure-scope-fallback

Conversation

@jlowin

@jlowin jlowin commented Jul 27, 2026

Copy link
Copy Markdown
Member

Backport of #4469 to release/3.x for the 3.4.5 patch release.

Azure-backed servers 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 scoped only to offline_access and reject it with AADSTS70011. This applies the same fallback when preparing Azure token-exchange and refresh scopes.

Cherry-picked cleanly from 1d932cc with no conflicts.

(cherry picked from commit 1d932cc)
@marvin-context-protocol marvin-context-protocol Bot added 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. labels Jul 27, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4174359373

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +507 to +509
prefixed_scopes = self._prefix_scopes_for_azure(
scopes or self.required_scopes or []
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the fallback before storing the transaction

When the default consent screen is enabled and a client omits scope, this fallback lets the Azure flow complete with required_scopes, but the transaction still contains scopes=[]; consequently consent.py renders an empty scope list and ClientCode also records no scopes even though Azure is being authorized for the configured API permissions. Normalize the effective scopes when creating the transaction (or in AzureProvider.authorize) so consent, authorization-code metadata, token exchange, and refresh all use the same scope set instead of compensating only at the upstream request hooks.

AGENTS.md reference: AGENTS.md:L136-L140

Useful? React with 馃憤聽/ 馃憥.

@jlowin
jlowin merged commit aa8ab1e into release/3.x Jul 27, 2026
17 checks passed
@jlowin
jlowin deleted the backport/4469-azure-scope-fallback branch July 27, 2026 17:10
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.

2 participants