#[non_exhaustive]pub struct SessionRecord {
pub id: String,
pub protocol_version: String,
pub client_info: Option<Implementation>,
pub client_capabilities: Option<ClientCapabilities>,
pub created_at: SystemTime,
pub last_accessed: SystemTime,
pub expires_at: SystemTime,
}Expand description
Serializable session metadata persisted by a SessionStore.
Contains everything needed to reconstruct a session after a restart or across server instances. Does not contain runtime state (channels, pending requests) – those are rebuilt locally on restore.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringSession ID (as used in the mcp-session-id header).
protocol_version: StringNegotiated MCP protocol version (e.g. "2025-11-25").
client_info: Option<Implementation>Client implementation info from the initialize request.
client_capabilities: Option<ClientCapabilities>Client capabilities from the initialize request.
created_at: SystemTimeWhen this session was created.
last_accessed: SystemTimeWhen this session was last accessed.
expires_at: SystemTimeWhen this session expires. Implementations may remove expired records.
Implementations§
Source§impl SessionRecord
impl SessionRecord
Sourcepub fn new(
id: impl Into<String>,
protocol_version: impl Into<String>,
ttl: Duration,
) -> Self
pub fn new( id: impl Into<String>, protocol_version: impl Into<String>, ttl: Duration, ) -> Self
Create a new record with a generated ID and timestamps.
ttl is used to derive expires_at from now.
Sourcepub fn touch(&mut self, ttl: Duration)
pub fn touch(&mut self, ttl: Duration)
Refresh last_accessed and expires_at using the given TTL.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if expires_at is in the past.
Trait Implementations§
Source§impl Clone for SessionRecord
impl Clone for SessionRecord
Source§fn clone(&self) -> SessionRecord
fn clone(&self) -> SessionRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more