Skip to content

chore: make mcpmessage super-trait #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/generated_schema/2024_11_05/mcp_schema.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// ----------------------------------------------------------------------------
/// This file is auto-generated by mcp-schema-gen v0.1.4.
/// This file is auto-generated by mcp-schema-gen v0.1.5.
/// WARNING:
/// It is not recommended to modify this file directly. You are free to
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7
/// Generated at : 2025-02-19 06:30:55
/// Generated at : 2025-02-19 17:00:34
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
6 changes: 3 additions & 3 deletions src/generated_schema/2024_11_05/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ fn detect_message_type(value: &serde_json::Value) -> MessageTypes {

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

pub trait MCPMessage: RPCMessage {
fn message_type(&self) -> MessageTypes;
pub trait MCPMessage {
fn is_response(&self) -> bool;
fn is_request(&self) -> bool;
fn is_notification(&self) -> bool;
fn is_error(&self) -> bool;
fn message_type(&self) -> MessageTypes;
}

//*******************************//
Expand Down
4 changes: 2 additions & 2 deletions src/generated_schema/draft/mcp_schema.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// ----------------------------------------------------------------------------
/// This file is auto-generated by mcp-schema-gen v0.1.4.
/// This file is auto-generated by mcp-schema-gen v0.1.5.
/// WARNING:
/// It is not recommended to modify this file directly. You are free to
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : bb1446ff1810a0df57989d78366d626d2c01b9d7
/// Generated at : 2025-02-19 06:30:55
/// Generated at : 2025-02-19 17:00:35
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
24 changes: 12 additions & 12 deletions src/generated_schema/draft/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ fn detect_message_type(value: &serde_json::Value) -> MessageTypes {

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

pub trait MCPMessage: RPCMessage {
fn message_type(&self) -> MessageTypes;
pub trait MCPMessage {
fn is_response(&self) -> bool;
fn is_request(&self) -> bool;
fn is_notification(&self) -> bool;
fn is_error(&self) -> bool;
fn message_type(&self) -> MessageTypes;
}

//*******************************//
Expand Down Expand Up @@ -134,11 +134,11 @@ impl RPCMessage for ClientMessage {
}
}

fn jsonrpc_version(&self) -> &str {
fn jsonrpc(&self) -> &str {
match self {
ClientMessage::Request(client_jsonrpc_request) => client_jsonrpc_request.jsonrpc.as_str(),
ClientMessage::Notification(notification) => notification.jsonrpc.as_str(),
ClientMessage::Response(client_jsonrpc_response) => client_jsonrpc_response.jsonrpc.as_str(),
ClientMessage::Request(client_jsonrpc_request) => client_jsonrpc_request.jsonrpc(),
ClientMessage::Notification(notification) => notification.jsonrpc(),
ClientMessage::Response(client_jsonrpc_response) => client_jsonrpc_response.jsonrpc(),
ClientMessage::Error(jsonrpc_error) => jsonrpc_error.jsonrpc(),
}
}
Expand Down Expand Up @@ -534,14 +534,14 @@ impl RPCMessage for ServerMessage {
}
}

fn jsonrpc_version(&self) -> &str {
fn jsonrpc(&self) -> &str {
match self {
// If the message is a request, return the associated request ID
ServerMessage::Request(client_jsonrpc_request) => client_jsonrpc_request.jsonrpc.as_str(),
ServerMessage::Request(client_jsonrpc_request) => client_jsonrpc_request.jsonrpc(),
// Notifications do not have request IDs
ServerMessage::Notification(notification) => notification.jsonrpc.as_str(),
ServerMessage::Notification(notification) => notification.jsonrpc(),
// If the message is a response, return the associated request ID
ServerMessage::Response(client_jsonrpc_response) => client_jsonrpc_response.jsonrpc.as_str(),
ServerMessage::Response(client_jsonrpc_response) => client_jsonrpc_response.jsonrpc(),
// If the message is an error, return the associated request ID
ServerMessage::Error(jsonrpc_error) => jsonrpc_error.jsonrpc(),
}
Expand Down
Loading