fix(mcp): McpToolset.fromConfig ignoring stdioServerParams#1360
Merged
copybara-service[bot] merged 1 commit intoJul 22, 2026
Merged
Conversation
Contributor
|
Hi @svetanis, thank you for your contribution and We appreciate you taking the time to submit this pull request. Currently this PR is under review by our team, we will keep you updated if any additional information is required. thank you. |
kvmilos
approved these changes
Jul 21, 2026
svetanis
force-pushed
the
fix/mcptoolset-fromconfig-stdioserverparams
branch
from
July 21, 2026 23:28
2ee0d9b to
cf71d7b
Compare
Contributor
Author
|
@kvmilos , Thanks so much for the review and approval! |
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:
When an agent config defines an MCP Toolset using
stdioServerParams(config-driven),McpToolset.fromConfigcorrectly validates the config but then fails to use the provided parameters. It falls back tostdioConnectionParams(), which is null. This leads to aNullPointerExceptionat session creation time insideDefaultMcpTransportBuilder.Solution:
Extracted the connection-parameter resolution from
fromConfiginto a new@VisibleForTestinghelper,McpToolset.resolveConnectionParameters(), and added the missingstdioServerParamsbranch, mapping viaStdioServerParameters::toServerParameters(the type the underlying MCP SDK transport builder accepts). The chain now ends inorElseThrowso a broken invariant fails explicitly atfromConfigtime instead of deferring to aNullPointerExceptionat session creation.Testing Plan
Unit Tests:
Please include a summary of passed java test results.
All 22 tests in
McpToolsetTest.javapass locally (18 existing + 4 new). The following 4 tests were newly added to directly cover the extractedresolveConnectionParametersmethod — the core of the fix:resolveConnectionParameters_stdioServerParams_convertsToSdkServerParameters— verifies the formerly-deadstdioServerParamsbranch now resolves toServerParametersresolveConnectionParameters_sseServerParams_passesThroughresolveConnectionParameters_stdioConnectionParams_passesThroughresolveConnectionParameters_nothingSet_throwsIllegalStateExceptionManual End-to-End (E2E) Tests:
Verified the fix using a standalone end-to-end demo application that exercises the config-driven agent flow:
LlmAgent(configured viaroot_agent.yaml) to load a local file system MCP server viastdioServerParams. The MCP server is a Node-free Java implementation (JavaFileMcpServer) to remove any Node.js dependency.listFilesandreadFiletools from the MCP server, and successfully executes a multi-step tool-calling exchange (one user turn, multiple function-call round trips) over the live connection.NullPointerException.Before fix (NPE — server never launched):
Checklist
Additional context
The fix was verified end-to-end using a Node-free Java MCP server (
JavaFileMcpServer) that replaces the usualnpx @modelcontextprotocol/server-filesystem, removing any Node.js dependency for reproduction.