toToolset

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

Creates an McpToolset from this configuration.

Parameters

headerProvider

Optional suspending callback that, given a ReadonlyContext, returns a map of HTTP headers to attach to each MCP session. Because it is a suspend function, headers or tokens can be minted asynchronously at request time (e.g. fetching an OAuth bearer token) without blocking a thread. When non-null, sessions are not cached across invocations so that headers can vary per-context (e.g. per-user authentication). When null, a single session is opened lazily and reused.

progressConsumers

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

Throws