pub enum ProtocolVersion {
V2024_11_05,
V2025_03_26,
V2025_06_18,
V2025_11_25,
V2026_07_28,
Unknown(ReleaseDate),
}Expand description
A published MCP revision, or one published after this build was compiled.
Ordered oldest to newest, which is also publication order. See the module docs for why that is an invariant rather than a coincidence.
Variants§
V2024_11_05
The first published revision. Defines stdio and the legacy HTTP+SSE
transport, and is the only revision where TransportKind::LegacySse
is defined at all.
V2025_03_26
Replaced the legacy HTTP+SSE transport with Streamable HTTP.
V2025_06_18
Removed JSON-RPC batching and added structured tool output.
V2025_11_25
Added URL-mode elicitation, icons, and experimental tasks.
V2026_07_28
Made the protocol stateless: the initialize handshake is gone and every
request carries its version in _meta.
Unknown(ReleaseDate)
A revision published after this build, identified by its release date.
Only ever holds a date at or after ReleaseDate::V2024_11_05, and in
practice only one newer than ProtocolVersion::V2026_07_28 — see the
module docs.
Implementations§
Source§impl ProtocolVersion
impl ProtocolVersion
Sourcepub const KNOWN: [Self; 5]
pub const KNOWN: [Self; 5]
Every revision this build has wire types for, oldest first.
draft is not a separate version: upstream’s floating draft schema
declares LATEST_PROTOCOL_VERSION = "2026-07-28", the same as the final
revision, so it negotiates as that revision. The two differ in schema
shape, not in version string, and T08 keys the codec off the version.
Sourcepub const fn latest_known() -> Self
pub const fn latest_known() -> Self
The newest revision this build knows.
Sourcepub const fn earliest_known() -> Self
pub const fn earliest_known() -> Self
The oldest revision this build supports.
Sourcepub const fn date(self) -> ReleaseDate
pub const fn date(self) -> ReleaseDate
The revision’s release date.
Sourcepub fn as_wire(self) -> Cow<'static, str>
pub fn as_wire(self) -> Cow<'static, str>
The string this revision is negotiated as, borrowed when it is a known one.
Cow rather than &'static str because Unknown has no static
spelling; the six known revisions, which is what a codec asks about on
the hot path, allocate nothing.
Sourcepub fn is_newer_than_all_known(self) -> bool
pub fn is_newer_than_all_known(self) -> bool
Whether this revision was published after the newest one this build knows.
Not const: the comparison comes from a derived Ord, and a derived
Ord is not a const-callable operator.
Sourcepub fn unknown_after_known(
date: ReleaseDate,
) -> Result<Self, UnknownVersionError>
pub fn unknown_after_known( date: ReleaseDate, ) -> Result<Self, UnknownVersionError>
Builds an Unknown from a date, refusing one that would break the
ordering invariant.
The public enum variant means this cannot be the only way in, so the function is not private; making it the obvious one is what keeps the invariant from being broken by accident.
§Errors
Returns UnknownVersionError::NotAfterKnown when date is at or
before Self::latest_known — a date this build should have a variant
for, and FromStr would have matched it exactly.
§Examples
use protocol_droid::domain::{ProtocolVersion, ReleaseDate};
let future = ProtocolVersion::unknown_after_known("2027-01-01".parse().unwrap())?;
assert!(future.is_newer_than_all_known());Trait Implementations§
Source§impl Clone for ProtocolVersion
impl Clone for ProtocolVersion
impl Copy for ProtocolVersion
Source§impl Debug for ProtocolVersion
impl Debug for ProtocolVersion
Source§impl Display for ProtocolVersion
impl Display for ProtocolVersion
impl Eq for ProtocolVersion
Source§impl FromStr for ProtocolVersion
impl FromStr for ProtocolVersion
Source§fn from_str(text: &str) -> Result<Self, Self::Err>
fn from_str(text: &str) -> Result<Self, Self::Err>
Parses a negotiated version string.
Three outcomes, in order:
- A known revision’s string becomes that variant. Matched on the whole
string first, because that is the only way to reject
2025-03-26xwithout first having to date-parse it. - A well-formed date this build has not heard of becomes
Unknown, provided it is at or after the first revision. - Everything else is an error.