Repository navigation
fix(mcp): unwrap StdioConnectionParameters and preserve requestTimeout in initializeAsyncSession - #1982
Open
Amansingh0807 wants to merge 1 commit into
Open
fix(mcp): unwrap StdioConnectionParameters and preserve requestTimeout in initializeAsyncSession#1982Amansingh0807 wants to merge 1 commit into
Amansingh0807 wants to merge 1 commit into
Conversation
…t in initializeAsyncSession
Contributor
|
Hi @Amansingh0807, Thank you for your contribution and for taking the time to submit this pull request. Our team is currently reviewing your changes, and we will reach out if we need any further information. |
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
McpSessionManager.initializeAsyncSession(Object connectionParams, McpTransportBuilder transportBuilder)previously passedconnectionParamsdirectly totransportBuilder.build(connectionParams)before inspecting its type, and only checkedSseServerParametersandStreamableHttpServerParametersafterward.When
StdioConnectionParameterswas passed:DefaultMcpTransportBuilder.build(...)immediately threw:IllegalArgumentException: DefaultMcpTransportBuilder supports only ServerParameters, SseServerParameters, or StreamableHttpServerParameters, but got com.google.adk.tools.mcp.AutoValue_StdioConnectionParameters.timeoutDuration()configured onStdioConnectionParameterswas ignored and defaulted to 5 minutes (Duration.ofMinutes(5)).createAsyncSession()also omittedthis.transportBuilder, unlikecreateSession().Solution:
resolveTransportConfig(Object connectionParams, McpTransportBuilder transportBuilder)helper (using a privateTransportConfigrecord andDEFAULT_TIMEOUT = Duration.ofMinutes(5)) used by bothinitializeSessionandinitializeAsyncSessionso parameter unwrapping and timeout extraction are handled uniformly without code duplication.StdioConnectionParameterstostdioConnectionParameters.serverParams().toServerParameters()before callingtransportBuilder.build(...)and setsrequestTimeout = stdioConnectionParameters.timeoutDuration().createAsyncSession()to forwardthis.transportBuildertoinitializeAsyncSession(this.connectionParams, this.transportBuilder), matchingcreateSession().Testing Plan
Unit Tests:
Summary of Passed Java Test Results (
.\mvnw.cmd test -pl core -Dtest="com.google.adk.tools.mcp.*Test" -DfailIfNoTests=false):All MCP unit tests in
core(AbstractMcpToolTest,ConversionUtilsTest,DefaultMcpTransportBuilderTest,McpAsyncToolsetTest,McpSessionManagerTest,McpToolsetReservedNamesTest,McpToolsetTest,StdioServerParametersTest) passed with 0 failures and 0 errors.Manual End-to-End (E2E) Tests:
N/A (verified via unit tests with both
DefaultMcpTransportBuilderand mockedMcpTransportBuildercapturing unwrappedServerParameters).Checklist
Additional context
3482d23e fix(mcp): unwrap StdioConnectionParameters and preserve requestTimeout in initializeAsyncSession) following Conventional Commits and Google Java Style conventions with Apache 2.0 license headers.cc @hemasekhar-p @damianmomotgoogle @dosadczuk @MiloszSobczyk