toToolset

fun toToolset(headerProvider: suspend (ReadonlyContext) -> Map<String, String>? = null, progressConsumers: List<(McpSchema.ProgressNotification) -> Unit> = emptyList()): McpToolset

Creates an McpToolset from this configuration.

headerProvider is resolved for the current ADK context before tool discovery and again before each tool call (matching ADK Python). Because it is a suspend function, headers or tokens can be minted asynchronously at request time. When non-null, discovered tools are not cached across invocations so that headers can vary per-context. When null, a single session is opened lazily and reused. 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 McpToolset.getTools is wrapped in McpToolLoadingException.

Parameters

headerProvider

Optional suspending callback that, given a ReadonlyContext, returns a map of HTTP headers to attach to each MCP session.

progressConsumers

Callbacks invoked for every McpSchema.ProgressNotification received from the MCP server during long-running tool executions.

Throws