Skip to main content

DefaultClientHandler

Struct DefaultClientHandler 

Source
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

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Handles a custom notification message
Source§

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,

Source§

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

Source§

fn default() -> DefaultClientHandler

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToMcpClientHandler for T
where T: ClientHandler + 'static,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more