@@ -58,17 +58,17 @@ fn detect_message_type(value: &serde_json::Value) -> MessageTypes {
58
58
59
59
/// Represents a generic MCP (Model Content Protocol) message.
60
60
/// This trait defines methods to classify and extract information from messages.
61
- pub trait RPCMessage {
61
+ pub trait RPCMessage : MCPMessage {
62
62
fn request_id ( & self ) -> Option < & RequestId > ;
63
- fn jsonrpc_version ( & self ) -> & str ;
63
+ fn jsonrpc ( & self ) -> & str ;
64
64
}
65
65
66
- pub trait MCPMessage : RPCMessage {
67
- fn message_type ( & self ) -> MessageTypes ;
66
+ pub trait MCPMessage {
68
67
fn is_response ( & self ) -> bool ;
69
68
fn is_request ( & self ) -> bool ;
70
69
fn is_notification ( & self ) -> bool ;
71
70
fn is_error ( & self ) -> bool ;
71
+ fn message_type ( & self ) -> MessageTypes ;
72
72
}
73
73
74
74
//*******************************//
@@ -134,11 +134,11 @@ impl RPCMessage for ClientMessage {
134
134
}
135
135
}
136
136
137
- fn jsonrpc_version ( & self ) -> & str {
137
+ fn jsonrpc ( & self ) -> & str {
138
138
match self {
139
- ClientMessage :: Request ( client_jsonrpc_request) => client_jsonrpc_request. jsonrpc . as_str ( ) ,
140
- ClientMessage :: Notification ( notification) => notification. jsonrpc . as_str ( ) ,
141
- ClientMessage :: Response ( client_jsonrpc_response) => client_jsonrpc_response. jsonrpc . as_str ( ) ,
139
+ ClientMessage :: Request ( client_jsonrpc_request) => client_jsonrpc_request. jsonrpc ( ) ,
140
+ ClientMessage :: Notification ( notification) => notification. jsonrpc ( ) ,
141
+ ClientMessage :: Response ( client_jsonrpc_response) => client_jsonrpc_response. jsonrpc ( ) ,
142
142
ClientMessage :: Error ( jsonrpc_error) => jsonrpc_error. jsonrpc ( ) ,
143
143
}
144
144
}
@@ -534,14 +534,14 @@ impl RPCMessage for ServerMessage {
534
534
}
535
535
}
536
536
537
- fn jsonrpc_version ( & self ) -> & str {
537
+ fn jsonrpc ( & self ) -> & str {
538
538
match self {
539
539
// If the message is a request, return the associated request ID
540
- ServerMessage :: Request ( client_jsonrpc_request) => client_jsonrpc_request. jsonrpc . as_str ( ) ,
540
+ ServerMessage :: Request ( client_jsonrpc_request) => client_jsonrpc_request. jsonrpc ( ) ,
541
541
// Notifications do not have request IDs
542
- ServerMessage :: Notification ( notification) => notification. jsonrpc . as_str ( ) ,
542
+ ServerMessage :: Notification ( notification) => notification. jsonrpc ( ) ,
543
543
// If the message is a response, return the associated request ID
544
- ServerMessage :: Response ( client_jsonrpc_response) => client_jsonrpc_response. jsonrpc . as_str ( ) ,
544
+ ServerMessage :: Response ( client_jsonrpc_response) => client_jsonrpc_response. jsonrpc ( ) ,
545
545
// If the message is an error, return the associated request ID
546
546
ServerMessage :: Error ( jsonrpc_error) => jsonrpc_error. jsonrpc ( ) ,
547
547
}
0 commit comments