feat: MCP OAuth proxy for virtual servers (DCR bypass with pre-registered clients)#4147
Open
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Open
feat: MCP OAuth proxy for virtual servers (DCR bypass with pre-registered clients)#4147ecthelion77 wants to merge 1 commit intoIBM:mainfrom
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Conversation
Contributor
Author
|
Suggested labels: |
c33cb01 to
f8978b9
Compare
167c9bf to
81868d5
Compare
Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
81868d5 to
68eb512
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
✨ Feature / Enhancement PR
🔗 Epic / Issue
Addresses the need for MCP OAuth support with identity providers that do not implement Dynamic Client Registration (DCR), such as Microsoft Entra ID (Azure AD).
🔗 Epic / Issue
Addresses #2148
🚀 Summary
This PR adds an MCP OAuth proxy layer that allows virtual servers to authenticate MCP clients using pre-registered OAuth client credentials instead of relying on DCR. This is essential for enterprise deployments where the IdP (e.g., Entra ID, Okta) does not support RFC 7591 dynamic client registration.
What it adds:
/mcp-oauth/router (mcpgateway/routers/mcp_oauth.py): A full MCP-compliant OAuth proxy that handles.well-known/oauth-authorization-servermetadata,/authorize,/token, and/registerendpoints. It translates MCP OAuth flows into standard IdP flows using pre-registeredclient_idandclient_secret./.well-known/oauth-protected-resourceendpoint (mcpgateway/routers/well_known.py): Implements RFC 9728 OAuth Protected Resource Metadata, advertising the gateway's authorization server to MCP clients.Admin UI fields: Adds
client_idandclient_secretinput fields to the virtual server creation/edit form, allowing administrators to provide pre-registered OAuth app credentials.Encrypted state management: Uses encrypted state tokens (Fernet) instead of in-memory storage for the OAuth authorization flow, making it compatible with multi-pod deployments behind a load balancer.
Secret decryption: Ensures
oauth_configsecrets are decrypted before being sent to the IdP for token exchange.🧪 Checks
make lintpassesmake testpasses📓 Notes
Architecture
The proxy presents standard MCP OAuth endpoints to the client, while translating requests to the actual IdP using pre-registered credentials. The client never needs to know about DCR — it just follows the standard MCP OAuth flow.
Key design decisions
client_id/client_secretcontinue to work with DCR as before.