Skip to content

Conversation

@jlowin
Copy link
Owner

@jlowin jlowin commented Oct 26, 2025

Azure returns unprefixed scopes in JWT tokens (e.g., 'scp': 'read') but requires prefixed scopes in authorization requests (e.g., 'scope': 'api://xxx/read'). The previous implementation validated tokens against prefixed scopes, causing MCP clients to reject tokens with "invalid_token" errors.

Simplified AzureProvider to use standard JWTVerifier with unprefixed scopes. Scopes are only prefixed when building Azure's authorization URL via the _build_upstream_authorize_url() override.

Closes #2263

Azure returns unprefixed scopes in JWT tokens but requires prefixed scopes in authorization requests. The previous implementation incorrectly validated tokens against prefixed scopes, causing "invalid_token" errors.

Simplified AzureProvider to use standard JWTVerifier with unprefixed scopes for validation. Scopes are only prefixed when building the Azure authorization URL via _build_upstream_authorize_url() override.

Closes #2263
@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. server Related to FastMCP server implementation or server-side functionality. labels Oct 26, 2025
@jlowin jlowin merged commit ba47db9 into main Oct 26, 2025
13 checks passed
@jlowin jlowin deleted the azure branch October 26, 2025 15:41
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. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth Token rejected (401 invalid_token) when using AzureProvider with FastMCP client

2 participants