fix(mcp): reject config-supplied stdio MCP servers by default - #6547
Open
yusmer96-maker wants to merge 2 commits into
Open
fix(mcp): reject config-supplied stdio MCP servers by default#6547yusmer96-maker wants to merge 2 commits into
yusmer96-maker wants to merge 2 commits into
Conversation
McpToolset.from_config() passed stdio_server_params.command and args straight from the agent config to the MCP stdio transport, which launches them as a local process. Agent configs are untrusted input, so this made a YAML config a process-execution primitive. Reject stdio connection params in from_config() unless the embedding application opts in via _set_allow_config_stdio_servers(True). Remote transports (SSE, streamable HTTP) are unaffected.
Add tests for from_config() rejecting stdio_server_params and stdio_connection_params by default, allowing them under the _set_allow_config_stdio_servers(True) opt-in, and leaving remote transports (SSE) unaffected. Update the existing credential_key test to opt in for its stdio config.
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
2. Or, if no issue exists, describe the change:
Problem:
McpToolset.from_config()acceptsstdio_server_params/stdio_connection_paramsdirectly from an agent config. Those carry acommandand
argsthat the MCP stdio transport launches as a local process, so loadingan agent config can start an arbitrary process on the first agent turn — before
the model is contacted.
Agent configs are not necessarily authored by the person running the agent: they
are shared as bundles, templates, samples and registry entries. That makes
config loading equivalent to code execution for anyone who runs an agent they
did not write.
ADK already treats this input as untrusted elsewhere: the
argskey is blockedfor Agent Builder uploads (
fast_api.py) and for disk loads when the web UI isenabled (
config_agent_utils._set_enforce_yaml_key_denylist). It was simply notenforced on the default
adk run/adk api_serverpaths.Solution:
from_config()now rejects stdio connection params unless the embeddingapplication explicitly opts in via
_set_allow_config_stdio_servers(True).Applications that legitimately launch local MCP servers from config keep working
by opting in; everything else fails closed.
Unaffected: remote transports (
sse_connection_params,streamable_http_connection_params), constructingMcpToolsetdirectly incode, and applications that opt in.
Testing Plan
Unit Tests:
pytest tests/unittests/tools/mcp_tool/test_mcp_toolset.py -k from_configtest_from_config_with_credential_key(updated to opt in)test_from_config_rejects_stdio_server_paramstest_from_config_rejects_stdio_connection_paramstest_from_config_allows_stdio_when_opted_intest_from_config_allows_remote_connection_paramsManual End-to-End (E2E) Tests:
Two agent bundles, each a single
root_agent.yaml, run withadk run.1 — stdio MCP server declared in an agent config (now rejected):
adk runnow fails at config load with the newValueError. Before thischange the same config launched the configured command on the first turn.
2 — remote MCP server in an agent config (unchanged):
The toolset builds normally and the run proceeds to the model step, confirming
remote transports are not affected.
Additional context
Reported through the Google VRP (issue 541474207); this PR is the corresponding
fix. Related hardening on the same surface in the Go SDK: google/adk-go#923.