# toToolset

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

Creates an McpToolset from this configuration.

#### Parameters

headerProvider

Optional callback that, given a ReadonlyContext, returns a map of HTTP headers to attach to each MCP session. 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

IllegalArgumentException

if zero or more than one of stdioConnectionParams, sseConnectionParams, and streamableHttpConnectionParams is set.