pub enum ServerMessage {
Request(ServerJsonrpcRequest),
Notification(ServerJsonrpcNotification),
Response(ServerJsonrpcResponse),
Error(JsonrpcError),
}
Expand description
“Similar to JsonrpcMessage, but with the variants restricted to client-side messages.” ServerMessage represents a message sent by an MCP Server and received by an MCP Client.
Variants§
Request(ServerJsonrpcRequest)
Notification(ServerJsonrpcNotification)
Response(ServerJsonrpcResponse)
Error(JsonrpcError)
Implementations§
Source§impl ServerMessage
impl ServerMessage
Sourcepub fn as_response(self) -> Result<ServerJsonrpcResponse, RpcError>
pub fn as_response(self) -> Result<ServerJsonrpcResponse, RpcError>
Converts the current message into a ServerJsonrpcResponse
if it’s of the correct type.
This function checks if the current message is of type Response
. If so, it returns the
ServerJsonrpcResponse
wrapped in a Result::Ok
. If the message is not a Response
,
it returns an error with a descriptive message indicating the mismatch in expected message types.
§Returns
Ok(ServerJsonrpcResponse)
if the message is a validResponse
.Err(RpcError)
if the message type is invalid
Sourcepub fn as_request(self) -> Result<ServerJsonrpcRequest, RpcError>
pub fn as_request(self) -> Result<ServerJsonrpcRequest, RpcError>
Converts the current message into a ServerJsonrpcRequest
if it’s of the correct type.
This function checks if the current message is of type Request
. If so, it returns the
ServerJsonrpcRequest
wrapped in a Result::Ok
. If the message is not a Request
,
it returns an error with a descriptive message indicating the mismatch in expected message types.
§Returns
Ok(ServerJsonrpcRequest)
if the message is a validRequest
.Err(RpcError)
if the message type is invalid
Sourcepub fn as_notification(self) -> Result<ServerJsonrpcNotification, RpcError>
pub fn as_notification(self) -> Result<ServerJsonrpcNotification, RpcError>
Converts the current message into a ServerJsonrpcNotification
if it’s of the correct type.
This function checks if the current message is of type Notification
. If so, it returns the
ServerJsonrpcNotification
wrapped in a Result::Ok
. If the message is not a Notification
,
it returns an error with a descriptive message indicating the mismatch in expected message types.
§Returns
Ok(ServerJsonrpcNotification)
if the message is a validNotification
.Err(RpcError)
if the message type is invalid
Sourcepub fn as_error(self) -> Result<JsonrpcError, RpcError>
pub fn as_error(self) -> Result<JsonrpcError, RpcError>
Converts the current message into a JsonrpcError
if it’s of the correct type.
This function checks if the current message is of type Error
. If so, it returns the
JsonrpcError
wrapped in a Result::Ok
. If the message is not a Error
,
it returns an error with a descriptive message indicating the mismatch in expected message types.
§Returns
Ok(JsonrpcError)
if the message is a validError
.Err(RpcError)
if the message type is invalid
Trait Implementations§
Source§impl Clone for ServerMessage
impl Clone for ServerMessage
Source§fn clone(&self) -> ServerMessage
fn clone(&self) -> ServerMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ServerMessage
impl Debug for ServerMessage
Source§impl<'de> Deserialize<'de> for ServerMessage
impl<'de> Deserialize<'de> for ServerMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ServerMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ServerMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for ServerMessage
impl Display for ServerMessage
Source§impl From<ServerJsonrpcNotification> for ServerMessage
impl From<ServerJsonrpcNotification> for ServerMessage
Source§fn from(value: ServerJsonrpcNotification) -> ServerMessage
fn from(value: ServerJsonrpcNotification) -> ServerMessage
Source§impl From<ServerJsonrpcRequest> for ServerMessage
impl From<ServerJsonrpcRequest> for ServerMessage
Source§fn from(value: ServerJsonrpcRequest) -> ServerMessage
fn from(value: ServerJsonrpcRequest) -> ServerMessage
Source§impl From<ServerJsonrpcResponse> for ServerMessage
impl From<ServerJsonrpcResponse> for ServerMessage
Source§fn from(value: ServerJsonrpcResponse) -> ServerMessage
fn from(value: ServerJsonrpcResponse) -> ServerMessage
Source§impl From<ServerMessage> for ServerMessages
impl From<ServerMessage> for ServerMessages
Source§fn from(value: ServerMessage) -> ServerMessages
fn from(value: ServerMessage) -> ServerMessages
Source§impl FromMessage<CallToolResult> for ServerMessage
impl FromMessage<CallToolResult> for ServerMessage
fn from_message( message: CallToolResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<CancelledNotification> for ServerMessage
impl FromMessage<CancelledNotification> for ServerMessage
fn from_message( message: CancelledNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<CompleteResult> for ServerMessage
impl FromMessage<CompleteResult> for ServerMessage
fn from_message( message: CompleteResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<CreateMessageRequest> for ServerMessage
impl FromMessage<CreateMessageRequest> for ServerMessage
fn from_message( message: CreateMessageRequest, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ElicitRequest> for ServerMessage
impl FromMessage<ElicitRequest> for ServerMessage
fn from_message( message: ElicitRequest, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<GetPromptResult> for ServerMessage
impl FromMessage<GetPromptResult> for ServerMessage
fn from_message( message: GetPromptResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<InitializeResult> for ServerMessage
impl FromMessage<InitializeResult> for ServerMessage
fn from_message( message: InitializeResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ListPromptsResult> for ServerMessage
impl FromMessage<ListPromptsResult> for ServerMessage
fn from_message( message: ListPromptsResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ListResourceTemplatesResult> for ServerMessage
impl FromMessage<ListResourceTemplatesResult> for ServerMessage
fn from_message( message: ListResourceTemplatesResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ListResourcesResult> for ServerMessage
impl FromMessage<ListResourcesResult> for ServerMessage
fn from_message( message: ListResourcesResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ListRootsRequest> for ServerMessage
impl FromMessage<ListRootsRequest> for ServerMessage
fn from_message( message: ListRootsRequest, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ListToolsResult> for ServerMessage
impl FromMessage<ListToolsResult> for ServerMessage
fn from_message( message: ListToolsResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<LoggingMessageNotification> for ServerMessage
impl FromMessage<LoggingMessageNotification> for ServerMessage
fn from_message( message: LoggingMessageNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<MessageFromServer> for ServerMessage
impl FromMessage<MessageFromServer> for ServerMessage
fn from_message( message: MessageFromServer, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<PingRequest> for ServerMessage
impl FromMessage<PingRequest> for ServerMessage
fn from_message( message: PingRequest, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ProgressNotification> for ServerMessage
impl FromMessage<ProgressNotification> for ServerMessage
fn from_message( message: ProgressNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<PromptListChangedNotification> for ServerMessage
impl FromMessage<PromptListChangedNotification> for ServerMessage
fn from_message( message: PromptListChangedNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ReadResourceResult> for ServerMessage
impl FromMessage<ReadResourceResult> for ServerMessage
fn from_message( message: ReadResourceResult, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ResourceListChangedNotification> for ServerMessage
impl FromMessage<ResourceListChangedNotification> for ServerMessage
fn from_message( message: ResourceListChangedNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ResourceUpdatedNotification> for ServerMessage
impl FromMessage<ResourceUpdatedNotification> for ServerMessage
fn from_message( message: ResourceUpdatedNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<Result> for ServerMessage
impl FromMessage<Result> for ServerMessage
fn from_message( message: Result, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromMessage<ToolListChangedNotification> for ServerMessage
impl FromMessage<ToolListChangedNotification> for ServerMessage
fn from_message( message: ToolListChangedNotification, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl FromStr for ServerMessage
impl FromStr for ServerMessage
Source§impl McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage> for MessageDispatcher<ClientMessage>
impl McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage> for MessageDispatcher<ClientMessage>
Source§fn send_message<'life0, 'async_trait>(
&'life0 self,
messages: ServerMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ClientMessage>: 'async_trait,
fn send_message<'life0, 'async_trait>(
&'life0 self,
messages: ServerMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ClientMessage>: 'async_trait,
Sends a message from the server to the client and awaits a response if applicable.
Serializes the ServerMessages
to JSON, writes it to the transport, and waits for a
ClientMessages
response if the message is a request. Notifications and responses return
Ok(None)
.
§Arguments
messages
- The client message to send, coulld be a single message or batch.
§Returns
A TransportResult
containing Some(ClientMessages)
for requests with a response,
or None
for notifications/responses, or an error if the operation fails.
§Errors
Returns a TransportError
if serialization, writing, or timeout occurs.
Source§fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MessageDispatcher<ClientMessage>: 'async_trait,
fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MessageDispatcher<ClientMessage>: 'async_trait,
Writes a string payload to the underlying asynchronous writable stream, appending a newline character and flushing the stream afterward.
fn send<'life0, 'async_trait>(
&'life0 self,
message: ServerMessage,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessage>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ClientMessage>: 'async_trait,
fn send_batch<'life0, 'async_trait>(
&'life0 self,
message: Vec<ServerMessage>,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ClientMessage>>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ClientMessage>: 'async_trait,
Source§impl McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage> for SseTransport<ClientMessage>
impl McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage> for SseTransport<ClientMessage>
Source§fn send_message<'life0, 'async_trait>(
&'life0 self,
message: ServerMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn send_message<'life0, 'async_trait>(
&'life0 self,
message: ServerMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
S
and optionally includes a request_id
.
The request_id
is used when sending a message in response to an MCP request.
It should match the request_id
of the original request.fn send<'life0, 'async_trait>(
&'life0 self,
message: ServerMessage,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessage>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn send_batch<'life0, 'async_trait>(
&'life0 self,
message: Vec<ServerMessage>,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ClientMessage>>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
Source§fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
Source§impl McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage> for StdioTransport<ClientMessage>
impl McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage> for StdioTransport<ClientMessage>
Source§fn send_message<'life0, 'async_trait>(
&'life0 self,
message: ServerMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
StdioTransport<ClientMessage>: 'async_trait,
fn send_message<'life0, 'async_trait>(
&'life0 self,
message: ServerMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
StdioTransport<ClientMessage>: 'async_trait,
S
and optionally includes a request_id
.
The request_id
is used when sending a message in response to an MCP request.
It should match the request_id
of the original request.fn send<'life0, 'async_trait>(
&'life0 self,
message: ServerMessage,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ClientMessage>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
StdioTransport<ClientMessage>: 'async_trait,
fn send_batch<'life0, 'async_trait>(
&'life0 self,
message: Vec<ServerMessage>,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ClientMessage>>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
StdioTransport<ClientMessage>: 'async_trait,
Source§fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StdioTransport<ClientMessage>: 'async_trait,
fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StdioTransport<ClientMessage>: 'async_trait,
Source§impl McpDispatch<ServerMessages, ClientMessages, ServerMessage, ClientMessage> for MessageDispatcher<ServerMessage>
impl McpDispatch<ServerMessages, ClientMessages, ServerMessage, ClientMessage> for MessageDispatcher<ServerMessage>
Source§fn send_message<'life0, 'async_trait>(
&'life0 self,
messages: ClientMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ServerMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ServerMessage>: 'async_trait,
fn send_message<'life0, 'async_trait>(
&'life0 self,
messages: ClientMessages,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ServerMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ServerMessage>: 'async_trait,
Sends a message from the client to the server and awaits a response if applicable.
Serializes the ClientMessages
to JSON, writes it to the transport, and waits for a
ServerMessages
response if the message is a request. Notifications and responses return
Ok(None)
.
§Arguments
messages
- The client message to send, coulld be a single message or batch.
§Returns
A TransportResult
containing Some(ServerMessages)
for requests with a response,
or None
for notifications/responses, or an error if the operation fails.
§Errors
Returns a TransportError
if serialization, writing, or timeout occurs.
Source§fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MessageDispatcher<ServerMessage>: 'async_trait,
fn write_str<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MessageDispatcher<ServerMessage>: 'async_trait,
Writes a string payload to the underlying asynchronous writable stream, appending a newline character and flushing the stream afterward.
fn send<'life0, 'async_trait>(
&'life0 self,
message: ClientMessage,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<ServerMessage>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ServerMessage>: 'async_trait,
fn send_batch<'life0, 'async_trait>(
&'life0 self,
message: Vec<ClientMessage>,
request_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ServerMessage>>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ServerMessage>: 'async_trait,
Source§impl McpMessage for ServerMessage
impl McpMessage for ServerMessage
Source§fn message_type(&self) -> MessageTypes
fn message_type(&self) -> MessageTypes
Determines the type of the message and returns the corresponding MessageTypes
variant.
fn is_response(&self) -> bool
fn is_request(&self) -> bool
fn is_notification(&self) -> bool
fn is_error(&self) -> bool
Source§impl RpcMessage for ServerMessage
impl RpcMessage for ServerMessage
Source§impl Serialize for ServerMessage
impl Serialize for ServerMessage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl ToMessage<ServerMessage> for CallToolResult
impl ToMessage<ServerMessage> for CallToolResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for CancelledNotification
impl ToMessage<ServerMessage> for CancelledNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for CompleteResult
impl ToMessage<ServerMessage> for CompleteResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for CreateMessageRequest
impl ToMessage<ServerMessage> for CreateMessageRequest
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ElicitRequest
impl ToMessage<ServerMessage> for ElicitRequest
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for GetPromptResult
impl ToMessage<ServerMessage> for GetPromptResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for InitializeResult
impl ToMessage<ServerMessage> for InitializeResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ListPromptsResult
impl ToMessage<ServerMessage> for ListPromptsResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ListResourceTemplatesResult
impl ToMessage<ServerMessage> for ListResourceTemplatesResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ListResourcesResult
impl ToMessage<ServerMessage> for ListResourcesResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ListRootsRequest
impl ToMessage<ServerMessage> for ListRootsRequest
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ListToolsResult
impl ToMessage<ServerMessage> for ListToolsResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for LoggingMessageNotification
impl ToMessage<ServerMessage> for LoggingMessageNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for PingRequest
impl ToMessage<ServerMessage> for PingRequest
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ProgressNotification
impl ToMessage<ServerMessage> for ProgressNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for PromptListChangedNotification
impl ToMessage<ServerMessage> for PromptListChangedNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ReadResourceResult
impl ToMessage<ServerMessage> for ReadResourceResult
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ResourceListChangedNotification
impl ToMessage<ServerMessage> for ResourceListChangedNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ResourceUpdatedNotification
impl ToMessage<ServerMessage> for ResourceUpdatedNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for Result
impl ToMessage<ServerMessage> for Result
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl ToMessage<ServerMessage> for ToolListChangedNotification
impl ToMessage<ServerMessage> for ToolListChangedNotification
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Source§impl Transport<ClientMessages, MessageFromServer, ClientMessage, ServerMessages, ServerMessage> for SseTransport<ClientMessage>
impl Transport<ClientMessages, MessageFromServer, ClientMessage, ServerMessages, ServerMessage> for SseTransport<ClientMessage>
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ReceiverStream<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ClientMessage>: McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage>,
SseTransport<ClientMessage>: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ReceiverStream<ClientMessages>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
MessageDispatcher<ClientMessage>: McpDispatch<ClientMessages, ServerMessages, ClientMessage, ServerMessage>,
SseTransport<ClientMessage>: 'async_trait,
Starts the transport, initializing streams and message dispatcher
Sets up the MCP stream and dispatcher using the provided duplex streams.
§Returns
TransportResult<(Pin<Box<dyn Stream<Item = R> + Send>>, MessageDispatcher<R>, IoStream)>
- The message stream, dispatcher, and error stream
§Errors
- Returns
TransportError
if streams are already taken or not initialized
Source§fn is_shut_down<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn is_shut_down<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
Checks if the transport has been shut down
§Returns
bool
- True if the transport is shut down, false otherwise
Source§fn shut_down<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn shut_down<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
Shuts down the transport, terminating tasks and signaling closure
Cancels any running tasks and clears the cancellation source.
§Returns
TransportResult<()>
- Ok if shutdown is successful, Err if cancellation fails
fn message_sender( &self, ) -> Arc<RwLock<Option<MessageDispatcher<ClientMessage>>>>
fn error_stream(&self) -> &RwLock<Option<IoStream>>
fn consume_string_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn keep_alive<'life0, 'async_trait>(
&'life0 self,
interval: Duration,
disconnect_tx: Sender<()>,
) -> Pin<Box<dyn Future<Output = Result<JoinHandle<()>, TransportError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
fn pending_request_tx<'life0, 'life1, 'async_trait>(
&'life0 self,
request_id: &'life1 RequestId,
) -> Pin<Box<dyn Future<Output = Option<Sender<ClientMessage>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
SseTransport<ClientMessage>: 'async_trait,
impl TransportDispatcher<ClientMessages, MessageFromServer, ClientMessage, ServerMessages, ServerMessage> for SseTransport<ClientMessage>
impl TransportDispatcher<ClientMessages, MessageFromServer, ClientMessage, ServerMessages, ServerMessage> for StdioTransport<ClientMessage>
Auto Trait Implementations§
impl Freeze for ServerMessage
impl RefUnwindSafe for ServerMessage
impl Send for ServerMessage
impl Sync for ServerMessage
impl Unpin for ServerMessage
impl UnwindSafe for ServerMessage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.