toToolset
Creates an MCP Toolset.
headerProvider is resolved for the current ADK context before an operation, including before each tool call (matching ADK Python). It is intended for application-managed credentials such as an already refreshed bearer token; OAuth UI, token storage, and refresh policy remain application concerns. Headers returned by the provider override same-named static McpTransportConfig.StreamableHttp.headers. The provider can be called again when an operation is retried, so it should be safe to invoke repeatedly.
An IllegalArgumentException thrown by headerProvider or by a ToolFilter.Predicate during Toolset.getTools is wrapped in McpToolException.McpToolLoadingException.
Session reuse differs by platform. JVM keeps one session per distinct header set, so two users with different tokens do not share a connection. Android keeps one session for the toolset and applies the latest headers on that session: a second user's call can reuse the first user's HTTP connection. Multi-account Android apps must not overlap calls for different users on the same toolset if those calls must not share a connection.
Tool discovery failures surface as McpToolException.McpToolLoadingException. ADK resource-tool failures surface as McpToolException.McpToolExecutionException on both platforms. Server-tool run differs by platform: Android wraps the failure as McpToolException.McpToolExecutionException with the SDK or transport error as Throwable.cause; JVM rethrows that underlying error so existing callers keep catching SDK/transport types.
On Android, ADK declares the Kotlin MCP SDK and Ktor OkHttp engine as compileOnly. An app that uses this toolset must add those dependencies itself.