Skip to main content

Overview

Use Google ADK McpToolset 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

Set MCP_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, install python -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.

Automatic reconnection after session interruption

VeADK re-establishes disconnected MCP sessions and retries eligible tool discovery or calls once. A second failure returns an error, and cancellation does not trigger a retry. Services must still provide idempotency for tools that change external data: a connection retry does not guarantee exactly-once business execution.
Last modified on September 19, 2026