diff --git a/crates/rmcp/src/model.rs b/crates/rmcp/src/model.rs index 2a79dc74..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")] @@ -2378,6 +2404,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 +2431,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;