From 5d3f57cc69de911e0cdaf8c3b2f0e3ccfdd1cb9a Mon Sep 17 00:00:00 2001 From: Dale Seo <5466341+DaleSeo@users.noreply.github.com> Date: Mon, 9 Mar 2026 17:56:05 -0400 Subject: [PATCH 1/2] feat: add constructors for Root and ListRootsResult --- crates/rmcp/src/model.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/rmcp/src/model.rs b/crates/rmcp/src/model.rs index 2a79dc74..d2efe09a 100644 --- a/crates/rmcp/src/model.rs +++ b/crates/rmcp/src/model.rs @@ -2378,6 +2378,22 @@ pub struct Root { pub name: Option, } +impl Root { + /// Creates a new `Root` with the given URI. `name` defaults to `None`. + pub fn new(uri: impl Into) -> Self { + Self { + uri: uri.into(), + name: None, + } + } + + /// Sets the human-readable name for this root. + pub fn with_name(mut self, name: impl Into) -> Self { + self.name = Some(name.into()); + self + } +} + const_string!(ListRootsRequestMethod = "roots/list"); pub type ListRootsRequest = RequestNoParam; @@ -2389,6 +2405,13 @@ pub struct ListRootsResult { pub roots: Vec, } +impl ListRootsResult { + /// Creates a new `ListRootsResult` with the given roots. + pub fn new(roots: Vec) -> Self { + Self { roots } + } +} + const_string!(RootsListChangedNotificationMethod = "notifications/roots/list_changed"); pub type RootsListChangedNotification = NotificationNoParam; From 34dccb5cf202642ea3a24fbd3200173ceff8a50a Mon Sep 17 00:00:00 2001 From: Dale Seo <5466341+DaleSeo@users.noreply.github.com> Date: Mon, 9 Mar 2026 17:56:36 -0400 Subject: [PATCH 2/2] feat: add constructors for UnsubscribeRequestParams and PromptReference --- crates/rmcp/src/model.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/rmcp/src/model.rs b/crates/rmcp/src/model.rs index d2efe09a..f6cc5fb3 100644 --- a/crates/rmcp/src/model.rs +++ b/crates/rmcp/src/model.rs @@ -1262,6 +1262,16 @@ pub struct UnsubscribeRequestParams { pub uri: String, } +impl UnsubscribeRequestParams { + /// Creates a new `UnsubscribeRequestParams` for the given URI. + pub fn new(uri: impl Into) -> Self { + Self { + meta: None, + uri: uri.into(), + } + } +} + impl RequestParamsMeta for UnsubscribeRequestParams { fn meta(&self) -> Option<&Meta> { self.meta.as_ref() @@ -2356,6 +2366,22 @@ pub struct PromptReference { pub title: Option, } +impl PromptReference { + /// Creates a new `PromptReference` with the given name. `title` defaults to `None`. + pub fn new(name: impl Into) -> Self { + Self { + name: name.into(), + title: None, + } + } + + /// Sets the human-readable title for this prompt reference. + pub fn with_title(mut self, title: impl Into) -> Self { + self.title = Some(title.into()); + self + } +} + const_string!(CompleteRequestMethod = "completion/complete"); #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(rename_all = "camelCase")]