sampling

Attribute Macro sampling 

Source
#[sampling]
Expand description

Mark a method as a sampling handler.

This handler is called when servers request LLM completions. The method should accept a CreateMessageRequest and return Result<CreateMessageResult, McpError> or CreateMessageResult.

§Example

#[sampling]
async fn handle_sampling(
    &self,
    request: CreateMessageRequest,
) -> Result<CreateMessageResult, McpError> {
    // Process the request and generate a response
}