fix(mcp): MCP OAuth broken - PEP 525 generator delegation bug (#12400) - #12409
Closed
vominh1919 wants to merge 1 commit into
Closed
fix(mcp): MCP OAuth broken - PEP 525 generator delegation bug (#12400)#12409vominh1919 wants to merge 1 commit into
vominh1919 wants to merge 1 commit into
Conversation
…ync_auth_flow The plain 'async for item in super().async_auth_flow(request): yield item' pattern does NOT forward asend() values back to the inner generator due to a PEP 525 limitation. The MCP SDK's auth flow (httpx.Auth flow) expects the caller to asend() the HTTP response back in, so without manual forwarding the flow silently receives None and OAuth token exchange / refresh breaks. Fixes NousResearch#12400
Collaborator
|
Likely stale — #12717 (merged) already fixed the same MCP OAuth bidirectional auth_flow issue. Please verify this is still needed. |
Contributor
|
Thanks for the thorough write-up and the correct diagnosis of the PEP 525 limitation, @vominh1919! This is an automated hermes-sweeper review. After verifying against current
The fix is already live on |
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.
Problem
MCP OAuth is broken because
async for item in super().async_auth_flow(request): yield itemdoes not forwardasend()values back to the inner generator.This is a known PEP 525 limitation — the
async for ... initeration protocol does not support bidirectional communication. The MCP SDK'sOAuthClientProvider.async_auth_flow(built onhttpx.Auth) usesasend()to receive the HTTP response from the caller. Without manual forwarding, the inner generator silently receivesNone, breaking token exchange and refresh.Fix
Replace the
async for ... yielddelegation with explicit bidirectional forwarding that properly handlesasend(),athrow(), andaclose().Files Changed
tools/mcp_oauth_manager.py—HermesMCPOAuthProvider.async_auth_flowmethod (lines 128-130 → bidirectional forwarding pattern)Closes #12400