validateSamplingMessages

Validate a sampling/createMessage request's messages against the tool-result message-content constraints in client/sampling §Tool Result Messages and §Tool Use and Result Balance:

- A user message that contains any tool_result content block MUST contain ONLY tool_result blocks (no text/image/audio mixed in). - Every assistant message that contains tool_use blocks MUST be immediately followed by a user message that consists entirely of tool_result blocks, with each tool_use id matched by a tool_result toolUseId, before any other message.

On violation throws an McpException with the spec's -32602 (Invalid params) code; the message distinguishes "Tool result missing in request" from "Tool results mixed with other content". A well-formed (or tool-free) request returns normally.

params is the raw sampling/createMessage params JSON — the same value passed to a client onSampling delegate — so a delegate can call this as a one-liner before forwarding to its model. Content blocks may be a single object or an array of blocks; both shapes are accepted.

@safe @safe
void
validateSamplingMessages
(
Json params
)