Skip to content

Commit c1999b2

Browse files
authored
chore: make mcpmessage super-trait (#29)
1 parent 3822538 commit c1999b2

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/generated_schema/2024_11_05/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// ----------------------------------------------------------------------------
2-
/// This file is auto-generated by mcp-schema-gen v0.1.4.
2+
/// This file is auto-generated by mcp-schema-gen v0.1.5.
33
/// WARNING:
44
/// It is not recommended to modify this file directly. You are free to
55
/// modify or extend the implementations as needed, but please do so at your own risk.
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
88
/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7
9-
/// Generated at : 2025-02-19 06:30:55
9+
/// Generated at : 2025-02-19 17:00:34
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

src/generated_schema/2024_11_05/schema_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ fn detect_message_type(value: &serde_json::Value) -> MessageTypes {
5858

5959
/// Represents a generic MCP (Model Content Protocol) message.
6060
/// This trait defines methods to classify and extract information from messages.
61-
pub trait RPCMessage {
61+
pub trait RPCMessage: MCPMessage {
6262
fn request_id(&self) -> Option<&RequestId>;
6363
fn jsonrpc(&self) -> &str;
6464
}
6565

66-
pub trait MCPMessage: RPCMessage {
67-
fn message_type(&self) -> MessageTypes;
66+
pub trait MCPMessage {
6867
fn is_response(&self) -> bool;
6968
fn is_request(&self) -> bool;
7069
fn is_notification(&self) -> bool;
7170
fn is_error(&self) -> bool;
71+
fn message_type(&self) -> MessageTypes;
7272
}
7373

7474
//*******************************//

src/generated_schema/draft/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// ----------------------------------------------------------------------------
2-
/// This file is auto-generated by mcp-schema-gen v0.1.4.
2+
/// This file is auto-generated by mcp-schema-gen v0.1.5.
33
/// WARNING:
44
/// It is not recommended to modify this file directly. You are free to
55
/// modify or extend the implementations as needed, but please do so at your own risk.
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
88
/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7
9-
/// Generated at : 2025-02-19 06:30:55
9+
/// Generated at : 2025-02-19 17:00:35
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version

src/generated_schema/draft/schema_utils.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ fn detect_message_type(value: &serde_json::Value) -> MessageTypes {
5858

5959
/// Represents a generic MCP (Model Content Protocol) message.
6060
/// This trait defines methods to classify and extract information from messages.
61-
pub trait RPCMessage {
61+
pub trait RPCMessage: MCPMessage {
6262
fn request_id(&self) -> Option<&RequestId>;
63-
fn jsonrpc_version(&self) -> &str;
63+
fn jsonrpc(&self) -> &str;
6464
}
6565

66-
pub trait MCPMessage: RPCMessage {
67-
fn message_type(&self) -> MessageTypes;
66+
pub trait MCPMessage {
6867
fn is_response(&self) -> bool;
6968
fn is_request(&self) -> bool;
7069
fn is_notification(&self) -> bool;
7170
fn is_error(&self) -> bool;
71+
fn message_type(&self) -> MessageTypes;
7272
}
7373

7474
//*******************************//
@@ -134,11 +134,11 @@ impl RPCMessage for ClientMessage {
134134
}
135135
}
136136

137-
fn jsonrpc_version(&self) -> &str {
137+
fn jsonrpc(&self) -> &str {
138138
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(),
142142
ClientMessage::Error(jsonrpc_error) => jsonrpc_error.jsonrpc(),
143143
}
144144
}
@@ -534,14 +534,14 @@ impl RPCMessage for ServerMessage {
534534
}
535535
}
536536

537-
fn jsonrpc_version(&self) -> &str {
537+
fn jsonrpc(&self) -> &str {
538538
match self {
539539
// 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(),
541541
// Notifications do not have request IDs
542-
ServerMessage::Notification(notification) => notification.jsonrpc.as_str(),
542+
ServerMessage::Notification(notification) => notification.jsonrpc(),
543543
// 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(),
545545
// If the message is an error, return the associated request ID
546546
ServerMessage::Error(jsonrpc_error) => jsonrpc_error.jsonrpc(),
547547
}

0 commit comments

Comments
 (0)