pub trait ClientHandler:
Sized
+ Send
+ Sync
+ 'static {
Show 14 methods
// Provided methods
fn ping(
&self,
context: RequestContext<RoleClient>,
) -> impl Future<Output = Result<(), McpError>> + Send + '_ { ... }
fn create_message(
&self,
params: CreateMessageRequestParams,
context: RequestContext<RoleClient>,
) -> impl Future<Output = Result<CreateMessageResult, McpError>> + Send + '_ { ... }
fn list_roots(
&self,
context: RequestContext<RoleClient>,
) -> impl Future<Output = Result<ListRootsResult, McpError>> + Send + '_ { ... }
fn create_elicitation(
&self,
request: CreateElicitationRequestParams,
context: RequestContext<RoleClient>,
) -> impl Future<Output = Result<CreateElicitationResult, McpError>> + Send + '_ { ... }
fn on_custom_request(
&self,
request: CustomRequest,
context: RequestContext<RoleClient>,
) -> impl Future<Output = Result<CustomResult, McpError>> + Send + '_ { ... }
fn on_cancelled(
&self,
params: CancelledNotificationParam,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_progress(
&self,
params: ProgressNotificationParam,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_logging_message(
&self,
params: LoggingMessageNotificationParam,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_resource_updated(
&self,
params: ResourceUpdatedNotificationParam,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_resource_list_changed(
&self,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_tool_list_changed(
&self,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_prompt_list_changed(
&self,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn on_custom_notification(
&self,
notification: CustomNotification,
context: NotificationContext<RoleClient>,
) -> impl Future<Output = ()> + Send + '_ { ... }
fn get_info(&self) -> ClientInfo { ... }
}Available on crate feature
client only.Provided Methods§
fn ping( &self, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<(), McpError>> + Send + '_
fn create_message( &self, params: CreateMessageRequestParams, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CreateMessageResult, McpError>> + Send + '_
fn list_roots( &self, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<ListRootsResult, McpError>> + Send + '_
Sourcefn create_elicitation(
&self,
request: CreateElicitationRequestParams,
context: RequestContext<RoleClient>,
) -> impl Future<Output = Result<CreateElicitationResult, McpError>> + Send + '_
fn create_elicitation( &self, request: CreateElicitationRequestParams, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CreateElicitationResult, McpError>> + Send + '_
Handle an elicitation request from a server asking for user input.
This method is called when a server needs interactive input from the user during tool execution. Implementations should present the message to the user, collect their input according to the requested schema, and return the result.
§Arguments
request- The elicitation request with message and schemacontext- The request context
§Returns
The user’s response including action (accept/decline/cancel) and optional data
§Default Behavior
The default implementation automatically declines all elicitation requests. Real clients should override this to provide user interaction.
fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CustomResult, McpError>> + Send + '_
fn on_cancelled( &self, params: CancelledNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_progress( &self, params: ProgressNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_logging_message( &self, params: LoggingMessageNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_resource_updated( &self, params: ResourceUpdatedNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_resource_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_tool_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_prompt_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn get_info(&self) -> ClientInfo
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl ClientHandler for ()
Do nothing, with default client info.
Source§impl<T: ClientHandler> ClientHandler for Box<T>
impl<T: ClientHandler> ClientHandler for Box<T>
fn ping( &self, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<(), McpError>> + Send + '_
fn create_message( &self, params: CreateMessageRequestParams, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CreateMessageResult, McpError>> + Send + '_
fn list_roots( &self, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<ListRootsResult, McpError>> + Send + '_
fn create_elicitation( &self, request: CreateElicitationRequestParams, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CreateElicitationResult, McpError>> + Send + '_
fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CustomResult, McpError>> + Send + '_
fn on_cancelled( &self, params: CancelledNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_progress( &self, params: ProgressNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_logging_message( &self, params: LoggingMessageNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_resource_updated( &self, params: ResourceUpdatedNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_resource_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_tool_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_prompt_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn get_info(&self) -> ClientInfo
Source§impl<T: ClientHandler> ClientHandler for Arc<T>
impl<T: ClientHandler> ClientHandler for Arc<T>
fn ping( &self, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<(), McpError>> + Send + '_
fn create_message( &self, params: CreateMessageRequestParams, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CreateMessageResult, McpError>> + Send + '_
fn list_roots( &self, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<ListRootsResult, McpError>> + Send + '_
fn create_elicitation( &self, request: CreateElicitationRequestParams, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CreateElicitationResult, McpError>> + Send + '_
fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleClient>, ) -> impl Future<Output = Result<CustomResult, McpError>> + Send + '_
fn on_cancelled( &self, params: CancelledNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_progress( &self, params: ProgressNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_logging_message( &self, params: LoggingMessageNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_resource_updated( &self, params: ResourceUpdatedNotificationParam, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_resource_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_tool_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_prompt_list_changed( &self, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleClient>, ) -> impl Future<Output = ()> + Send + '_
fn get_info(&self) -> ClientInfo
Implementors§
impl ClientHandler for ClientInfo
Do nothing, with a specific client info.