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
16 changes: 13 additions & 3 deletions crates/rmcp/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,19 @@ impl std::fmt::Display for ProtocolVersion {
}

impl ProtocolVersion {
pub const V_2025_11_25: Self = Self(Cow::Borrowed("2025-11-25"));
pub const V_2025_06_18: Self = Self(Cow::Borrowed("2025-06-18"));
pub const V_2025_03_26: Self = Self(Cow::Borrowed("2025-03-26"));
pub const V_2024_11_05: Self = Self(Cow::Borrowed("2024-11-05"));
pub const LATEST: Self = Self::V_2025_06_18;
pub const LATEST: Self = Self::V_2025_11_25;

/// All protocol versions known to this SDK.
pub const KNOWN_VERSIONS: &[Self] =
&[Self::V_2024_11_05, Self::V_2025_03_26, Self::V_2025_06_18];
pub const KNOWN_VERSIONS: &[Self] = &[
Self::V_2024_11_05,
Self::V_2025_03_26,
Self::V_2025_06_18,
Self::V_2025_11_25,
];

/// Returns the string representation of this protocol version.
pub fn as_str(&self) -> &str {
Expand Down Expand Up @@ -187,6 +192,7 @@ impl<'de> Deserialize<'de> for ProtocolVersion {
"2024-11-05" => return Ok(ProtocolVersion::V_2024_11_05),
"2025-03-26" => return Ok(ProtocolVersion::V_2025_03_26),
"2025-06-18" => return Ok(ProtocolVersion::V_2025_06_18),
"2025-11-25" => return Ok(ProtocolVersion::V_2025_11_25),
_ => {}
}
Ok(ProtocolVersion(Cow::Owned(s)))
Expand Down Expand Up @@ -3739,7 +3745,11 @@ mod tests {
fn test_protocol_version_order() {
let v1 = ProtocolVersion::V_2024_11_05;
let v2 = ProtocolVersion::V_2025_03_26;
let v3 = ProtocolVersion::V_2025_06_18;
let v4 = ProtocolVersion::V_2025_11_25;
assert!(v1 < v2);
assert!(v2 < v3);
assert!(v3 < v4);
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion crates/rmcp/tests/test_custom_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,14 +866,16 @@ async fn test_server_rejects_unsupported_protocol_version() {
fn test_protocol_version_utilities() {
use rmcp::model::ProtocolVersion;

assert_eq!(ProtocolVersion::V_2025_11_25.as_str(), "2025-11-25");
assert_eq!(ProtocolVersion::V_2025_06_18.as_str(), "2025-06-18");
assert_eq!(ProtocolVersion::V_2025_03_26.as_str(), "2025-03-26");
assert_eq!(ProtocolVersion::V_2024_11_05.as_str(), "2024-11-05");

assert_eq!(ProtocolVersion::KNOWN_VERSIONS.len(), 3);
assert_eq!(ProtocolVersion::KNOWN_VERSIONS.len(), 4);
assert!(ProtocolVersion::KNOWN_VERSIONS.contains(&ProtocolVersion::V_2024_11_05));
assert!(ProtocolVersion::KNOWN_VERSIONS.contains(&ProtocolVersion::V_2025_03_26));
assert!(ProtocolVersion::KNOWN_VERSIONS.contains(&ProtocolVersion::V_2025_06_18));
assert!(ProtocolVersion::KNOWN_VERSIONS.contains(&ProtocolVersion::V_2025_11_25));
}

/// Integration test: Verify server validates only the Host header for DNS rebinding protection
Expand Down
Loading