pub struct DefaultClientHandler;Expand description
Default client handler that accepts all server-initiated messages.
The SDK’s ClientHandler trait provides default implementations that
handle ping, create_message, list_roots, elicitation, task, and custom requests.
Trait Implementations§
Source§impl ClientHandler for DefaultClientHandler
impl ClientHandler for DefaultClientHandler
Source§fn handle_ping_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<RequestParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<Result, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_ping_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<RequestParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<Result, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a ping, to check that the other party is still alive.
The receiver must promptly respond, or else may be disconnected.
Source§fn handle_create_message_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_create_message_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request from the server to sample an LLM via the client.
The client has full discretion over which model to select.
The client should also inform the user before beginning sampling,
to allow them to inspect the request (human in the loop) and decide whether to approve it.
Source§fn handle_task_augmented_create_message<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CreateTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_task_augmented_create_message<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CreateTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles requests to call a task-augmented sampling (sampling/createMessage).
you need to returns a CreateTaskResult containing task data.
The actual operation result becomes available later
through tasks/result after the task completes.
Source§fn handle_list_roots_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<RequestParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_list_roots_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<RequestParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request from the server to request a list of root URIs from the client. Roots allow
servers to ask for specific directories or files to operate on.
This request is typically used when the server needs to understand the file system
structure or access specific locations that the client has permission to read from.
Source§fn handle_elicit_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ElicitRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_elicit_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ElicitRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request from the server to elicit additional information from the user via the client.
Source§fn handle_task_augmented_elicit_request<'life0, 'life1, 'async_trait>(
&'life0 self,
task_creator: TaskCreator<ServerJsonrpcRequest, ResultFromClient>,
params: ElicitRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CreateTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_task_augmented_elicit_request<'life0, 'life1, 'async_trait>(
&'life0 self,
task_creator: TaskCreator<ServerJsonrpcRequest, ResultFromClient>,
params: ElicitRequestParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CreateTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles task-augmented elicitation, to elicit additional information from the user via the client.
you need to returns a CreateTaskResult containing task data.
The actual operation result becomes available later
through tasks/result after the task completes.
Source§fn handle_get_task_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: GetTaskParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<GetTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_get_task_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: GetTaskParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<GetTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request to retrieve the state of a task.
Source§fn handle_get_task_payload_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: GetTaskPayloadParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<Result, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_get_task_payload_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: GetTaskPayloadParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<Result, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request to retrieve the result of a completed task.
Source§fn handle_cancel_task_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CancelTaskParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CancelTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_cancel_task_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CancelTaskParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<CancelTaskResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request to cancel a task.
Source§fn handle_list_tasks_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<PaginatedRequestParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_list_tasks_request<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<PaginatedRequestParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a request to retrieve a list of tasks.
Source§fn handle_custom_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: CustomRequest,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_custom_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: CustomRequest,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult, RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handle a custom request
Source§fn handle_cancelled_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CancelledNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_cancelled_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: CancelledNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a notification that indicates that it is cancelling a previously-issued request.
it is always possible that this notification MAY arrive after the request has already finished.
This notification indicates that the result will be unused, so any associated processing SHOULD cease.
Source§fn handle_progress_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ProgressNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_progress_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ProgressNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles an out-of-band notification used to inform the receiver of a progress update for a long-running request.
Source§fn handle_resource_list_changed_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<NotificationParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_resource_list_changed_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<NotificationParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a notification from the server to the client, informing it that the list of resources it can read from has changed.
Source§fn handle_resource_updated_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ResourceUpdatedNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_resource_updated_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ResourceUpdatedNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
handles a notification from the server to the client, informing it that a resource has changed and may need to be read again.
Source§fn handle_prompt_list_changed_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<NotificationParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_prompt_list_changed_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<NotificationParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a notification from the server to the client, informing it that the list of prompts it offers has changed.
Source§fn handle_tool_list_changed_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<NotificationParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_tool_list_changed_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: Option<NotificationParams>,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a notification from the server to the client, informing it that the list of tools it offers has changed.
Source§fn handle_logging_message_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: LoggingMessageNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_logging_message_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: LoggingMessageNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles notification of a log message passed from server to client.
If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
Source§fn handle_task_status_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: TaskStatusNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_task_status_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: TaskStatusNotificationParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a notification from the receiver to the requestor, informing them that a task’s status has changed.
Receivers are not required to send these notifications.
Source§fn handle_elicitation_complete_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ElicitCompleteParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_elicitation_complete_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
params: ElicitCompleteParams,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a notification from the server to the client, informing it of a completion of a out-of-band elicitation request.
Source§fn handle_custom_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: CustomRequest,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_custom_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: CustomRequest,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handles a custom notification message
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
error: &'life1 RpcError,
runtime: &'life2 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn handle_process_error<'life0, 'life1, 'async_trait>(
&'life0 self,
error_message: String,
runtime: &'life1 dyn McpClient,
) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§impl Default for DefaultClientHandler
impl Default for DefaultClientHandler
Source§fn default() -> DefaultClientHandler
fn default() -> DefaultClientHandler
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DefaultClientHandler
impl RefUnwindSafe for DefaultClientHandler
impl Send for DefaultClientHandler
impl Sync for DefaultClientHandler
impl Unpin for DefaultClientHandler
impl UnsafeUnpin for DefaultClientHandler
impl UnwindSafe for DefaultClientHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more