fix: await async MCP header providers#6105
Closed
he-yufeng wants to merge 1 commit into
Closed
Conversation
Collaborator
|
Hi @he-yufeng , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing mypy-diff tests. |
he-yufeng
force-pushed
the
fix/adk-async-mcp-header-provider
branch
2 times, most recently
from
June 18, 2026 06:15
1be8161 to
e22ef16
Compare
he-yufeng
force-pushed
the
fix/adk-async-mcp-header-provider
branch
from
June 18, 2026 10:14
e22ef16 to
4f7ccb5
Compare
copybara-service Bot
pushed a commit
that referenced
this pull request
Jul 1, 2026
Merge #6105 ## Summary - await async/awaitable MCP header providers in async execution paths. - add unit tests verifying the async header provider functionality. Fixes #6090 Co-authored-by: Kathy Wu <wukathy@google.com> COPYBARA_INTEGRATE_REVIEW=#6105 from he-yufeng:fix/await-async-header-provider 086d352 PiperOrigin-RevId: 941317964
Collaborator
|
Thank you @he-yufeng for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit c01e538. Closing this PR as the changes are now in the main branch. |
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.
Link to Issue or Description of Change
Closes: #6090
Problem:
header_provideris called from async MCP execution paths, but async providers were not awaited. Passing an async provider therefore left a coroutine object in the header merge path, which fails withTypeError: 'coroutine' object is not iterableand leaves the coroutine unawaited.Solution:
Await awaitable
header_providerresults before merging headers in both MCP paths:McpToolset._execute_with_session, used while creating sessions forget_tools()/ resources.McpTool._run_async_impl, used when an individual MCP tool call creates a session.The existing sync provider behavior is unchanged.
Testing Plan
Unit Tests:
header_providercoverage forMcpToolset.get_tools().header_providercoverage forMcpTool._run_async_impl().PYTHONPATH=src python -m pytest tests/unittests/tools/mcp_tool/test_mcp_tool.py tests/unittests/tools/mcp_tool/test_mcp_toolset.py -qAdditional checks:
python -m py_compile src/google/adk/tools/mcp_tool/mcp_tool.py src/google/adk/tools/mcp_tool/mcp_toolset.pypython -m pyink --check src/google/adk/tools/mcp_tool/mcp_tool.py src/google/adk/tools/mcp_tool/mcp_toolset.py tests/unittests/tools/mcp_tool/test_mcp_tool.py tests/unittests/tools/mcp_tool/test_mcp_toolset.pypython -m ruff check src/google/adk/tools/mcp_tool/mcp_tool.py src/google/adk/tools/mcp_tool/mcp_toolset.pygit diff --checkManual E2E was not run; the changed behavior is covered by the MCP unit tests above.