pub trait SamplingHandler:
Send
+ Sync
+ Debug {
// Required method
fn handle_create_message<'life0, 'async_trait>(
&'life0 self,
request: CreateMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
MCP-compliant sampling handler trait
The client receives sampling requests and delegates to configured LLM services. This maintains perfect separation of concerns per MCP specification.
Required Methods§
Sourcefn handle_create_message<'life0, 'async_trait>(
&'life0 self,
request: CreateMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_create_message<'life0, 'async_trait>(
&'life0 self,
request: CreateMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a sampling/createMessage request from a server
This method should:
- Present the request to the user for approval
- Delegate to an external LLM service (could be another MCP server)
- Present the result to the user for review
- Return the approved result
Implementors§
impl SamplingHandler for LLMRegistry
Implement SamplingHandler for LLMRegistry