pub trait MessageHandler: Send + Sync {
Show 23 methods
// Required method
fn handle_initialize<'life0, 'async_trait>(
&'life0 self,
request: InitializeRequest,
) -> Pin<Box<dyn Future<Output = Result<InitializeResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn handle_initialized<'life0, 'async_trait>(
&'life0 self,
_notification: InitializedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_ping<'life0, 'async_trait>(
&'life0 self,
request: PingRequest,
) -> Pin<Box<dyn Future<Output = Result<PingResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_resources_list<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesListRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesListResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_resources_read<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesReadRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesReadResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_resources_subscribe<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesSubscribeRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesSubscribeResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_resources_unsubscribe<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesUnsubscribeRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesUnsubscribeResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_tools_list<'life0, 'async_trait>(
&'life0 self,
_request: ToolsListRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolsListResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_tools_call<'life0, 'async_trait>(
&'life0 self,
_request: ToolsCallRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolsCallResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_prompts_list<'life0, 'async_trait>(
&'life0 self,
_request: PromptsListRequest,
) -> Pin<Box<dyn Future<Output = Result<PromptsListResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_prompts_get<'life0, 'async_trait>(
&'life0 self,
_request: PromptsGetRequest,
) -> Pin<Box<dyn Future<Output = Result<PromptsGetResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_logging_set_level<'life0, 'async_trait>(
&'life0 self,
_request: LoggingSetLevelRequest,
) -> Pin<Box<dyn Future<Output = Result<LoggingSetLevelResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_sampling_create_message<'life0, 'async_trait>(
&'life0 self,
_request: CreateMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_roots_list<'life0, 'async_trait>(
&'life0 self,
_request: RootsListRequest,
) -> Pin<Box<dyn Future<Output = Result<RootsListResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_progress_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ProgressNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_logging_notification<'life0, 'async_trait>(
&'life0 self,
_notification: LoggingNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_cancelled_notification<'life0, 'async_trait>(
&'life0 self,
_notification: CancelledNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_resources_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ResourcesUpdatedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_tools_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ToolsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_prompts_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: PromptsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_roots_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: RootsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn handle_custom_request<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
_params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn handle_custom_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
_params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Trait for handling MCP protocol messages
Required Methods§
Sourcefn handle_initialize<'life0, 'async_trait>(
&'life0 self,
request: InitializeRequest,
) -> Pin<Box<dyn Future<Output = Result<InitializeResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_initialize<'life0, 'async_trait>(
&'life0 self,
request: InitializeRequest,
) -> Pin<Box<dyn Future<Output = Result<InitializeResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle an initialize request
Provided Methods§
Sourcefn handle_initialized<'life0, 'async_trait>(
&'life0 self,
_notification: InitializedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_initialized<'life0, 'async_trait>(
&'life0 self,
_notification: InitializedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle an initialized notification
Sourcefn handle_ping<'life0, 'async_trait>(
&'life0 self,
request: PingRequest,
) -> Pin<Box<dyn Future<Output = Result<PingResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_ping<'life0, 'async_trait>(
&'life0 self,
request: PingRequest,
) -> Pin<Box<dyn Future<Output = Result<PingResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle a ping request
Sourcefn handle_resources_list<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesListRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_resources_list<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesListRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle resources/list request
Sourcefn handle_resources_read<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesReadRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesReadResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_resources_read<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesReadRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesReadResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle resources/read request
Sourcefn handle_resources_subscribe<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesSubscribeRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesSubscribeResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_resources_subscribe<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesSubscribeRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesSubscribeResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle resources/subscribe request
Sourcefn handle_resources_unsubscribe<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesUnsubscribeRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesUnsubscribeResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_resources_unsubscribe<'life0, 'async_trait>(
&'life0 self,
_request: ResourcesUnsubscribeRequest,
) -> Pin<Box<dyn Future<Output = Result<ResourcesUnsubscribeResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle resources/unsubscribe request
Sourcefn handle_tools_list<'life0, 'async_trait>(
&'life0 self,
_request: ToolsListRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolsListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_tools_list<'life0, 'async_trait>(
&'life0 self,
_request: ToolsListRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolsListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle tools/list request
Sourcefn handle_tools_call<'life0, 'async_trait>(
&'life0 self,
_request: ToolsCallRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolsCallResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_tools_call<'life0, 'async_trait>(
&'life0 self,
_request: ToolsCallRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolsCallResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle tools/call request
Sourcefn handle_prompts_list<'life0, 'async_trait>(
&'life0 self,
_request: PromptsListRequest,
) -> Pin<Box<dyn Future<Output = Result<PromptsListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_prompts_list<'life0, 'async_trait>(
&'life0 self,
_request: PromptsListRequest,
) -> Pin<Box<dyn Future<Output = Result<PromptsListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle prompts/list request
Sourcefn handle_prompts_get<'life0, 'async_trait>(
&'life0 self,
_request: PromptsGetRequest,
) -> Pin<Box<dyn Future<Output = Result<PromptsGetResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_prompts_get<'life0, 'async_trait>(
&'life0 self,
_request: PromptsGetRequest,
) -> Pin<Box<dyn Future<Output = Result<PromptsGetResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle prompts/get request
Sourcefn handle_logging_set_level<'life0, 'async_trait>(
&'life0 self,
_request: LoggingSetLevelRequest,
) -> Pin<Box<dyn Future<Output = Result<LoggingSetLevelResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_logging_set_level<'life0, 'async_trait>(
&'life0 self,
_request: LoggingSetLevelRequest,
) -> Pin<Box<dyn Future<Output = Result<LoggingSetLevelResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle logging/setLevel request
Sourcefn handle_sampling_create_message<'life0, 'async_trait>(
&'life0 self,
_request: CreateMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_sampling_create_message<'life0, 'async_trait>(
&'life0 self,
_request: CreateMessageRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle sampling/createMessage request (client capability)
Sourcefn handle_roots_list<'life0, 'async_trait>(
&'life0 self,
_request: RootsListRequest,
) -> Pin<Box<dyn Future<Output = Result<RootsListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_roots_list<'life0, 'async_trait>(
&'life0 self,
_request: RootsListRequest,
) -> Pin<Box<dyn Future<Output = Result<RootsListResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle roots/list request (client capability)
Sourcefn handle_progress_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ProgressNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_progress_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ProgressNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle progress notification
Sourcefn handle_logging_notification<'life0, 'async_trait>(
&'life0 self,
_notification: LoggingNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_logging_notification<'life0, 'async_trait>(
&'life0 self,
_notification: LoggingNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle logging notification
Sourcefn handle_cancelled_notification<'life0, 'async_trait>(
&'life0 self,
_notification: CancelledNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_cancelled_notification<'life0, 'async_trait>(
&'life0 self,
_notification: CancelledNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle cancelled notification
Sourcefn handle_resources_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ResourcesUpdatedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_resources_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ResourcesUpdatedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle resources updated notification
Sourcefn handle_tools_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ToolsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_tools_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: ToolsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle tools updated notification
Sourcefn handle_prompts_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: PromptsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_prompts_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: PromptsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle prompts updated notification
Sourcefn handle_roots_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: RootsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle_roots_updated_notification<'life0, 'async_trait>(
&'life0 self,
_notification: RootsListChangedNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle roots updated notification
Sourcefn handle_custom_request<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
_params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_custom_request<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
_params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handle custom/unknown requests
Sourcefn handle_custom_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
_params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn handle_custom_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
_params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Handle custom/unknown notifications
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".