Implement SEP-990 Enterprise Managed OAuth #1721
Open
+1,681
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the client-side components of SEP-990: Enterprise Managed Authorization. It introduces the
EnterpriseAuthOAuthClientProviderto handle the full token exchange flow required for Enterprise SSO, including RFC 8693 (Token Exchange) and RFC 7523 (JWT Bearer Grant).Motivation and Context
Implements: SEP-990
To support enterprise environments where direct API keys are not compliant, the Python SDK needs to support "Managed Authorization." This implementation allows the SDK to:
This aligns the Python SDK with the architecture defined in the SEP-990 implementation guide.
Implementation Details
The following components have been added to
src/mcp/client/auth/extensions/enterprise_managed_auth.py:TokenExchangeParametersandTokenExchangeResponseusing Pydantic to strictly type the exchange payloads.EnterpriseAuthOAuthClientProvider, which extends the baseOAuthClientProviderto orchestrate the exchange logic.urn:ietf:params:oauth:token-type:id-jagtoken types.How Has This Been Tested?
I have implemented comprehensive unit tests in
tests/client/auth/test_enterprise_managed_auth_client.pyusingpytestandunittest.mock.The testing suite covers the following scenarios:
Data Model Validation:
TokenExchangeParameterscorrectly generates requests for both OIDC ID Tokens (test_token_exchange_params_from_id_token) and SAML Assertions (test_token_exchange_params_from_saml_assertion).RFC 8693 Token Exchange Logic:
httpxto verify the correct payload structure (grant types, token types) is sent to the IdP.client_idandclient_secretare correctly injected into the request body when configured (test_exchange_token_with_client_authentication).RFC 7523 JWT Bearer Grant Logic:
Network Edge Cases:
httpx.ConnectError,httpx.ReadTimeout) to ensureOAuthTokenErroris raised with descriptive messages.Breaking Changes
No.
This is an additive extension. The core
OAuthClientProviderremains backward compatible. Only users specifically importing and usingEnterpriseAuthOAuthClientProviderwill be affected.Types of changes
Checklist
Additional context
pydanticfor model validation andhttpxfor async requests.src/mcp/client/auth/extensions/).