Skip to main content

DraftLifecycle

Struct DraftLifecycle 

Source
pub struct DraftLifecycle<'a> { /* private fields */ }
Expand description

The stateless lifecycle, folded over a trace’s message events in order.

use mcp_trace_validator::context::draft::{DraftLifecycle, DraftPhase};
use mcp_conformance_core::trace::TraceEvent;

// A stateless session: the first message is an ordinary request, with no handshake.
let events: Vec<TraceEvent> = serde_json::from_str::<Vec<_>>(r#"[
    {"seq":0,"direction":"client-to-server","transport":"stdio","kind":"message",
     "payload":{"jsonrpc":"2.0","id":1,"method":"tools/list"}}
]"#).unwrap();

let lifecycle = DraftLifecycle::new(&events);
// Operational immediately — no `initialize` required (contrast `2025-11-25`).
assert_eq!(lifecycle.phases()[0], DraftPhase::Active);
assert_eq!(lifecycle.final_phase(), DraftPhase::Active);
assert!(lifecycle.discover().request.is_none());

Implementations§

Source§

impl<'a> DraftLifecycle<'a>

Source

pub fn new(events: &'a [TraceEvent]) -> Self

Folds the stateless lifecycle over events in one pass, recording the phase before each event and the server/discover exchange.

Source

pub fn phases(&self) -> &[DraftPhase]

The phase before each event, in trace order (one entry per event).

Source

pub const fn final_phase(&self) -> DraftPhase

The lifecycle phase after the entire trace has been processed.

Source

pub const fn discover(&self) -> &DiscoverExchange<'a>

The observed server/discover exchange.

Source

pub fn server_capabilities(&self) -> Option<&'a Value>

The server’s declared capabilities, from the server/discover result — the stateless analogue of the initialize result’s capabilities. None when no discovery completed (the client capability surface lives in each request’s _meta in this revision, which is a per-request concern, not a lifecycle one).

Trait Implementations§

Source§

impl<'a> Debug for DraftLifecycle<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DraftLifecycle<'a>

§

impl<'a> RefUnwindSafe for DraftLifecycle<'a>

§

impl<'a> Send for DraftLifecycle<'a>

§

impl<'a> Sync for DraftLifecycle<'a>

§

impl<'a> Unpin for DraftLifecycle<'a>

§

impl<'a> UnsafeUnpin for DraftLifecycle<'a>

§

impl<'a> UnwindSafe for DraftLifecycle<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.