Repository navigation
Description
Please make sure you read the contribution guide and file the issues in the right place.
Contribution guide.
🔴 Required Information
Describe the Bug:
McpSessionManager.initializeAsyncSession(Object connectionParams, McpTransportBuilder transportBuilder) throws an IllegalArgumentException whenever StdioConnectionParameters is passed, and also ignores any custom timeoutDuration() configured on StdioConnectionParameters.
In synchronous McpSessionManager.initializeSession(...) (core/src/main/java/com/google/adk/tools/mcp/McpSessionManager.java, lines 62–77), connectionParams is inspected before calling transportBuilder.build(...):
- If
connectionParams instanceof StdioConnectionParameters stdioConnectionParameters, it unwrapsstdioConnectionParameters.serverParams().toServerParameters()intotransportBuilderParamsand extractsrequestTimeout = stdioConnectionParameters.timeoutDuration(). - It then passes
transportBuilderParamstotransportBuilder.build(transportBuilderParams).
However, in McpSessionManager.initializeAsyncSession(...) (core/src/main/java/com/google/adk/tools/mcp/McpSessionManager.java, lines 101–120):
transportBuilder.build(connectionParams)is called immediately on line 105 with the rawconnectionParamsobject.- There is no
instanceof StdioConnectionParametersbranch at all (lines 106–112 only handleSseServerParametersandStreamableHttpServerParameters). DefaultMcpTransportBuilder.build(Object connectionParams)(DefaultMcpTransportBuilder.java, lines 45–89) only acceptsServerParameters,SseServerParameters, orStreamableHttpServerParameters, so passingStdioConnectionParametersthrowsIllegalArgumentExceptionimmediately.- Even if a custom
McpTransportBuilderacceptedStdioConnectionParameters,requestTimeoutremainsnulland silently falls back to the 5-minute default (Duration.ofMinutes(5)), ignoringstdioConnectionParameters.timeoutDuration().
Steps to Reproduce:
- Construct a
StdioServerParametersinstance (e.g.,StdioServerParameters.builder().command("echo").build()). - Wrap it in
StdioConnectionParameterswith a custom timeout (e.g.,StdioConnectionParameters.builder().serverParams(serverParams).timeout(10.0f).build()). - Call
McpSessionManager.initializeAsyncSession(connectionParams)(ornew McpSessionManager(connectionParams).createAsyncSession()). - Observe
IllegalArgumentExceptionthrown byDefaultMcpTransportBuilder.build.
Expected Behavior:
McpSessionManager.initializeAsyncSession should unwrap StdioConnectionParameters to stdioConnectionParameters.serverParams().toServerParameters() before calling transportBuilder.build(...), and set requestTimeout = stdioConnectionParameters.timeoutDuration() — matching the behavior of synchronous McpSessionManager.initializeSession.
Observed Behavior:
McpSessionManager.initializeAsyncSession immediately crashes with:
java.lang.IllegalArgumentException: DefaultMcpTransportBuilder supports only ServerParameters, SseServerParameters, or StreamableHttpServerParameters, but got com.google.adk.tools.mcp.AutoValue_StdioConnectionParameters
Environment Details:
- ADK Library Version (see maven dependency):
1.16.1-SNAPSHOT(latestmain) - OS: Windows
- Java Version (
java -version): Java 25 (compiled with release 17)
Model Information:
- Which model is being used: N/A (MCP Toolset /
McpSessionManager)
🟡 Optional Information
Regression:
No (present since async session initialization was introduced).
Logs:
Local reproduction test output (.\mvnw.cmd test -pl core -Dtest=McpSessionManagerReproTest):
REPRODUCED EXCEPTION: DefaultMcpTransportBuilder supports only ServerParameters, SseServerParameters, or StreamableHttpServerParameters, but got com.google.adk.tools.mcp.AutoValue_StdioConnectionParameters
Additional Context:
McpSessionManager.initializeSession (lines 66–77) already implements the correct unwrapping and timeout extraction logic:
Object transportBuilderParams = connectionParams;
if (connectionParams instanceof StdioConnectionParameters stdioConnectionParameters) {
transportBuilderParams = stdioConnectionParameters.serverParams().toServerParameters();
requestTimeout = stdioConnectionParameters.timeoutDuration();
} else if (connectionParams instanceof SseServerParameters sseServerParams) {
initializationTimeout = sseServerParams.timeout();
requestTimeout = sseServerParams.sseReadTimeout();
} else if (connectionParams instanceof StreamableHttpServerParameters streamableParams) {
initializationTimeout = streamableParams.timeout();
requestTimeout = streamableParams.readTimeout();
}
McpClientTransport transport = transportBuilder.build(transportBuilderParams);Applying the same pattern in initializeAsyncSession resolves both the IllegalArgumentException and the ignored requestTimeout.
Minimal Reproduction Code:
@Test
public void initializeAsyncSession_withStdioConnectionParameters_throwsIllegalArgumentException() {
StdioServerParameters serverParams = StdioServerParameters.builder().command("echo").build();
StdioConnectionParameters connectionParams =
StdioConnectionParameters.builder().serverParams(serverParams).timeout(10.0f).build();
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> McpSessionManager.initializeAsyncSession(connectionParams));
assertThat(thrown)
.hasMessageThat()
.contains(
"DefaultMcpTransportBuilder supports only ServerParameters, SseServerParameters, or"
+ " StreamableHttpServerParameters");
}How often has this issue occurred?:
- Always (100%)
cc @hemasekhar-p @damianmomotgoogle @dosadczuk @MiloszSobczyk
Activity
Amansingh0807 commentedon Dec 1, 2026
Hi @hemasekhar-p, I have opened up a PR for this issue.
PTAL whenever you have a moment.
Thank you.
hemasekhar-p commentedon Dec 2, 2026
Hi @Amansingh0807, thank you for reporting this issue and for your contribution. I have successfully reproduced the bug using your inputs. The issue and your corresponding pull request are currently under review by our team. We will reach out if we require any additional information.