From 49eba18b371c9f99edd6949d9fcae5b828c64b73 Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Tue, 29 Apr 2025 15:16:29 +0000 Subject: [PATCH] stderr-notification-handler --- crates/rmcp/src/handler/client.rs | 9 +++++++++ crates/rmcp/src/model.rs | 9 +++++++++ crates/rmcp/src/model/meta.rs | 1 + 3 files changed, 19 insertions(+) diff --git a/crates/rmcp/src/handler/client.rs b/crates/rmcp/src/handler/client.rs index 13bd9677..2f051599 100644 --- a/crates/rmcp/src/handler/client.rs +++ b/crates/rmcp/src/handler/client.rs @@ -28,6 +28,9 @@ impl Service for H { notification: ::PeerNot, ) -> Result<(), McpError> { match notification { + ServerNotification::StderrNotification(notification) => { + self.on_stderr(notification.params).await + } ServerNotification::CancelledNotification(notification) => { self.on_cancelled(notification.params).await } @@ -98,6 +101,12 @@ pub trait ClientHandler: Sized + Send + Sync + 'static { ) -> impl Future + Send + '_ { std::future::ready(()) } + fn on_stderr( + &self, + params: StderrNotificationParam, + ) -> impl Future + Send + '_ { + std::future::ready(()) + } fn on_progress( &self, params: ProgressNotificationParam, diff --git a/crates/rmcp/src/model.rs b/crates/rmcp/src/model.rs index 7ff035ee..d1cd6585 100644 --- a/crates/rmcp/src/model.rs +++ b/crates/rmcp/src/model.rs @@ -569,6 +569,14 @@ pub struct PaginatedRequestParam { const_string!(PingRequestMethod = "ping"); pub type PingRequest = RequestNoParam; +const_string!(StderrNotificationMethod = "notifications/stderr"); +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct StderrNotificationParam { + pub content: String, +} +pub type StderrNotification = Notification; + const_string!(ProgressNotificationMethod = "notifications/progress"); #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(rename_all = "camelCase")] @@ -981,6 +989,7 @@ ts_union!( | ResourceUpdatedNotification | ResourceListChangedNotification | ToolListChangedNotification + | StderrNotification | PromptListChangedNotification; ); diff --git a/crates/rmcp/src/model/meta.rs b/crates/rmcp/src/model/meta.rs index 010dd8ca..5bfcd08b 100644 --- a/crates/rmcp/src/model/meta.rs +++ b/crates/rmcp/src/model/meta.rs @@ -95,6 +95,7 @@ variant_extension! { ResourceListChangedNotification ToolListChangedNotification PromptListChangedNotification + StderrNotification } } #[derive(Debug, Serialize, Deserialize, Clone, Default)]