Skip to content
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
5 changes: 3 additions & 2 deletions src/generated_schema/2024_11_05/mcp_schema.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/// ----------------------------------------------------------------------------
/// WARNING: This file is auto-generated by mcp-schema-gen v0.0.1.
/// This file is auto-generated by mcp-schema-gen v0.1.1.
/// 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 : 3d4877e69cbc9921e1b511a90cdf17d42483036b
/// Generated at : 2025-02-06 11:59:05
/// Generated at : 2025-02-09 16:55:01
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
59 changes: 55 additions & 4 deletions src/generated_schema/2024_11_05/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,26 @@ impl From<RootsListChangedNotification> for NotificationFromClient {
Self::ClientNotification(value.into())
}
}
impl From<CancelledNotification> for ClientJsonrpcNotification {
fn from(value: CancelledNotification) -> Self {
Self::new(value.into())
}
}
impl From<InitializedNotification> for ClientJsonrpcNotification {
fn from(value: InitializedNotification) -> Self {
Self::new(value.into())
}
}
impl From<ProgressNotification> for ClientJsonrpcNotification {
fn from(value: ProgressNotification) -> Self {
Self::new(value.into())
}
}
impl From<RootsListChangedNotification> for ClientJsonrpcNotification {
fn from(value: RootsListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<Result> for ResultFromClient {
fn from(value: Result) -> Self {
Self::ClientResult(value.into())
Expand Down Expand Up @@ -1093,6 +1113,41 @@ impl From<LoggingMessageNotification> for NotificationFromServer {
Self::ServerNotification(value.into())
}
}
impl From<CancelledNotification> for ServerJsonrpcNotification {
fn from(value: CancelledNotification) -> Self {
Self::new(value.into())
}
}
impl From<ProgressNotification> for ServerJsonrpcNotification {
fn from(value: ProgressNotification) -> Self {
Self::new(value.into())
}
}
impl From<ResourceListChangedNotification> for ServerJsonrpcNotification {
fn from(value: ResourceListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<ResourceUpdatedNotification> for ServerJsonrpcNotification {
fn from(value: ResourceUpdatedNotification) -> Self {
Self::new(value.into())
}
}
impl From<PromptListChangedNotification> for ServerJsonrpcNotification {
fn from(value: PromptListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<ToolListChangedNotification> for ServerJsonrpcNotification {
fn from(value: ToolListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<LoggingMessageNotification> for ServerJsonrpcNotification {
fn from(value: LoggingMessageNotification) -> Self {
Self::new(value.into())
}
}
impl From<PingRequest> for RequestFromServer {
fn from(value: PingRequest) -> Self {
Self::ServerRequest(value.into())
Expand Down Expand Up @@ -1223,9 +1278,5 @@ mod tests {
);
let result = detect_message_type(&json!(message));
assert!(matches!(result, MessageTypes::Error));

// default
let result = detect_message_type(&json!({}));
assert!(matches!(result, MessageTypes::Request));
}
}
5 changes: 3 additions & 2 deletions src/generated_schema/draft/mcp_schema.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/// ----------------------------------------------------------------------------
/// WARNING: This file is auto-generated by mcp-schema-gen v0.0.1.
/// This file is auto-generated by mcp-schema-gen v0.1.1.
/// 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 : 3d4877e69cbc9921e1b511a90cdf17d42483036b
/// Generated at : 2025-02-06 11:59:05
/// Generated at : 2025-02-09 16:55:01
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
55 changes: 55 additions & 0 deletions src/generated_schema/draft/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,26 @@ impl From<RootsListChangedNotification> for NotificationFromClient {
Self::ClientNotification(value.into())
}
}
impl From<CancelledNotification> for ClientJsonrpcNotification {
fn from(value: CancelledNotification) -> Self {
Self::new(value.into())
}
}
impl From<InitializedNotification> for ClientJsonrpcNotification {
fn from(value: InitializedNotification) -> Self {
Self::new(value.into())
}
}
impl From<ProgressNotification> for ClientJsonrpcNotification {
fn from(value: ProgressNotification) -> Self {
Self::new(value.into())
}
}
impl From<RootsListChangedNotification> for ClientJsonrpcNotification {
fn from(value: RootsListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<Result> for ResultFromClient {
fn from(value: Result) -> Self {
Self::ClientResult(value.into())
Expand Down Expand Up @@ -1087,6 +1107,41 @@ impl From<LoggingMessageNotification> for NotificationFromServer {
Self::ServerNotification(value.into())
}
}
impl From<CancelledNotification> for ServerJsonrpcNotification {
fn from(value: CancelledNotification) -> Self {
Self::new(value.into())
}
}
impl From<ProgressNotification> for ServerJsonrpcNotification {
fn from(value: ProgressNotification) -> Self {
Self::new(value.into())
}
}
impl From<ResourceListChangedNotification> for ServerJsonrpcNotification {
fn from(value: ResourceListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<ResourceUpdatedNotification> for ServerJsonrpcNotification {
fn from(value: ResourceUpdatedNotification) -> Self {
Self::new(value.into())
}
}
impl From<PromptListChangedNotification> for ServerJsonrpcNotification {
fn from(value: PromptListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<ToolListChangedNotification> for ServerJsonrpcNotification {
fn from(value: ToolListChangedNotification) -> Self {
Self::new(value.into())
}
}
impl From<LoggingMessageNotification> for ServerJsonrpcNotification {
fn from(value: LoggingMessageNotification) -> Self {
Self::new(value.into())
}
}
impl From<PingRequest> for RequestFromServer {
fn from(value: PingRequest) -> Self {
Self::ServerRequest(value.into())
Expand Down
40 changes: 34 additions & 6 deletions tests/test_serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,37 @@ mod test_serialize {

#[test]
fn test_client_initialized_notification() {
let message: ClientMessage = ClientMessage::Notification(ClientJsonrpcNotification::new(
NotificationFromClient::ClientNotification(ClientNotification::InitializedNotification(
InitializedNotification::new(Some(InitializedNotificationParams { meta: None, extra: None })),
)),
));
let init_notification =
InitializedNotification::new(Some(InitializedNotificationParams { meta: None, extra: None }));

let message: ClientMessage =
ClientMessage::Notification(ClientJsonrpcNotification::new(NotificationFromClient::ClientNotification(
ClientNotification::InitializedNotification(init_notification.clone()),
)));

let message: ClientMessage = re_serialize(message);

assert!(matches!(message, ClientMessage::Notification(client_message)
if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification)
if matches!( client_notification, ClientNotification::InitializedNotification(_)))
));

// test From<InitializedNotification> for NotificationFromClient
let message: ClientMessage =
ClientMessage::Notification(ClientJsonrpcNotification::new(init_notification.clone().into()));

assert!(matches!(message, ClientMessage::Notification(client_message)
if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification)
if matches!( client_notification, ClientNotification::InitializedNotification(_)))
));

// test From<InitializedNotification> for ClientJsonrpcNotification
let message: ClientMessage = ClientMessage::Notification(init_notification.into());

assert!(matches!(message, ClientMessage::Notification(client_message)
if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification)
if matches!( client_notification, ClientNotification::InitializedNotification(_)))
));
}

#[test]
Expand Down Expand Up @@ -460,7 +479,16 @@ mod test_serialize {
));

// test From<CancelledNotification> for NotificationFromServer
let message: ServerMessage = ServerMessage::Notification(ServerJsonrpcNotification::new(cancel_notification.into()));
let message: ServerMessage =
ServerMessage::Notification(ServerJsonrpcNotification::new(cancel_notification.clone().into()));

assert!(matches!(message, ServerMessage::Notification(client_message)
if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification)
if matches!( client_notification, ServerNotification::CancelledNotification(_)))
));

// test From<CancelledNotification> for ServerNotification
let message: ServerMessage = ServerMessage::Notification(cancel_notification.into());

assert!(matches!(message, ServerMessage::Notification(client_message)
if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification)
Expand Down