Overview
Use Google ADKMcpToolset to connect to an MCP server and register it with Agent(tools=[toolset]). The older MCPToolset name remains compatible. Remote servers require a supported MCP URL and credentials; local servers require an executable command and its dependencies.
Usage
SetMCP_SERVER_URL and MCP_SERVER_TOKEN, then verify tool discovery below. Discovery requires no reasoning model; complete model configuration before invoking tools through an agent.
mcp_connection.py
Local standard input/output connection
Save these files in the same directory, installpython -m pip install "mcp[cli]", and run python check_local_mcp.py. The output should include add. The client starts the server and closes it when the example ends.
local_mcp_server.py
check_local_mcp.py
Parameters
These constructor parameters correspond to Google ADK 2.2.0; other versions may support a different set.
Streamable HTTP connections accept required
url, headers=None, timeout=5.0, sse_read_timeout=300.0, and terminate_on_close=True. Timeouts are in seconds. httpx_client_factory defaults to the SDK HTTP client factory; override it only for a custom transport. Local connections use StdioConnectionParams(server_params=..., timeout=5.0). Use SseConnectionParams for SSE servers; SSE and Streamable HTTP endpoints are not interchangeable.