Skip to main content

SamplingSender

Trait SamplingSender 

Source
pub trait SamplingSender: Send + Sync {
    // Required method
    fn create_message(
        &self,
        request: SamplingRequest,
    ) -> Pin<Box<dyn Future<Output = McpResult<SamplingResponse>> + Send + '_>>;
}
Expand description

Trait for sending sampling requests to the client.

Sampling allows the server to request LLM completions from the client. This enables agentic workflows where tools can leverage the client’s LLM capabilities.

Required Methods§

Source

fn create_message( &self, request: SamplingRequest, ) -> Pin<Box<dyn Future<Output = McpResult<SamplingResponse>> + Send + '_>>

Sends a sampling/createMessage request to the client.

§Arguments
  • request - The sampling request parameters
§Returns

The sampling response from the client, or an error if sampling failed or the client doesn’t support sampling.

Implementors§