Skip to content

Commit c468742

Browse files
committed
chore: update sse client core example
1 parent 0d0b1ba commit c468742

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

examples/simple-mcp-client-core-sse/src/handler.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,25 @@ impl ClientHandlerCore for MyClientHandler {
4141

4242
async fn handle_notification(
4343
&self,
44-
_notification: NotificationFromServer,
44+
notification: NotificationFromServer,
4545
_runtime: &dyn McpClient,
4646
) -> std::result::Result<(), RpcError> {
47-
Err(RpcError::internal_error()
48-
.with_message("handle_notification() Not implemented".to_string()))
47+
if let NotificationFromServer::ServerNotification(
48+
schema::ServerNotification::LoggingMessageNotification(logging_message_notification),
49+
) = notification
50+
{
51+
println!(
52+
"Notification from server: {}",
53+
logging_message_notification.params.data.to_string()
54+
);
55+
} else {
56+
println!(
57+
"A {} notification received from the server",
58+
notification.method()
59+
);
60+
};
61+
62+
Ok(())
4963
}
5064

5165
async fn handle_error(

0 commit comments

Comments
 (0)