huggingface/smolagents · error · ValueError
Unsupported transport: {transport}. Supported transports are
Error message
Unsupported transport: {transport}. Supported transports are 'streamable-http' and 'sse'. What it means
When MCPClient is constructed with a dict of server_parameters, it reads the 'transport' key (defaulting to 'streamable-http') and only accepts 'streamable-http' or 'sse'. Any other value raises ValueError immediately, before any connection is attempted. This mirrors the transports supported by the underlying MCPAdapt library.
Source
Thrown at src/smolagents/mcp_client.py:114
"To suppress this warning, explicitly set structured_output=True (new behavior) or structured_output=False (legacy behavior). "
"See documentation at https://huggingface.co/docs/smolagents/tutorials/tools#structured-output-and-output-schema-support for more details.",
FutureWarning,
stacklevel=2,
)
structured_output = False
try:
from mcpadapt.core import MCPAdapt
from mcpadapt.smolagents_adapter import SmolAgentsAdapter
except ModuleNotFoundError:
raise ModuleNotFoundError("Please install 'mcp' extra to use MCPClient: `pip install 'smolagents[mcp]'`")
if isinstance(server_parameters, dict):
transport = server_parameters.get("transport")
if transport is None:
transport = "streamable-http"
server_parameters["transport"] = transport
if transport not in {"sse", "streamable-http"}:
raise ValueError(
f"Unsupported transport: {transport}. Supported transports are 'streamable-http' and 'sse'."
)
adapter_kwargs = adapter_kwargs or {}
self._adapter = MCPAdapt(
server_parameters, SmolAgentsAdapter(structured_output=structured_output), **adapter_kwargs
)
self._tools: list[Tool] | None = None
self.connect()
def connect(self):
"""Connect to the MCP server and initialize the tools."""
self._tools: list[Tool] = self._adapter.__enter__()
def disconnect(
self,
exc_type: type[BaseException] | None = None,
exc_value: BaseException | None = None,
exc_traceback: TracebackType | None = None,View on GitHub (pinned to 30bb116109)
Solutions
- Set transport to 'streamable-http' or 'sse', or omit it to get the 'streamable-http' default
- For stdio servers (command/args config), use the MCPAdapt stdio parameters form rather than a dict with 'transport'
- Double-check for typos and trailing whitespace in the transport value
Example fix
# before
client = MCPClient({"url": "http://localhost:8000/mcp", "transport": "http"})
# after
client = MCPClient({"url": "http://localhost:8000/mcp", "transport": "streamable-http"}) Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_TRANSPORTS = {"streamable-http", "sse"}
transport = server_parameters.get("transport", "streamable-http")
if transport not in SUPPORTED_TRANSPORTS:
raise ValueError(f"Pick one of {SUPPORTED_TRANSPORTS}")
client = MCPClient(server_parameters) Type guard
def is_valid_mcp_transport(params: dict) -> bool:
t = params.get("transport", "streamable-http")
return t in {"streamable-http", "sse"} Try / catch
try:
client = MCPClient(server_parameters)
except ValueError as e:
if 'Unsupported transport' in str(e):
server_parameters['transport'] = 'streamable-http'
client = MCPClient(server_parameters) Prevention
- Omit 'transport' to use the streamable-http default
- Validate config dicts against the supported set before constructing MCPClient
- Don't reuse stdio-style MCP configs with the dict transport form
When it happens
Trigger: Passing server_parameters={'url': ..., 'transport': 'stdio'} or 'websocket', 'http', or a typo like 'sse ' to MCPClient.__init__.
Common situations: Copy-pasting stdio-based MCP server config (command/args style) into the dict form; protocol rename confusion (older MCP examples used 'http'); misspelled transport strings.
Related errors
- Please install 'mcp' extra to use MCPClient: `pip install 's
- Couldn't retrieve tools from MCP server, run `mcp_client.con
- Unsupported transport: {transport}. Supported transports are
- Parameter 'structured_output' was not specified. Currently i
- Parameter 'structured_output' was not specified. Currently i
AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28).
Data as JSON: /api/errors/9ce7a574dc718cd3.
Report an issue: GitHub.