MCP (Model Context Protocol) integration is provided through ToolCollection.from_mcp() in src/smolagents/tools.py and the dedicated src/smolagents/mcp_client.py. The from_mcp method is a context manager that spawns a background thread running an asyncio event loop to handle the MCP server connection.
Three MCP transport types are supported:
mcp.StdioServerParameters— launches a subprocess and communicates over stdin/stdout{"url": "...", "transport": "streamable-http"}— Streamable HTTP (default for dict input){"url": "...", "transport": "sse"}— legacy HTTP+SSE (deprecated)
The structured_output parameter controls whether MCP tool outputSchema and structuredContent responses are forwarded to the agent. It currently defaults to False for backwards compatibility, but a FutureWarning is emitted indicating the default will change to True in version 1.25.
Depends on mcpadapt>=0.1.13 and mcp; available via smolagents[mcp].
src/smolagents/tools.pysrc/smolagents/mcp_client.pypyproject.toml