Skip to main content

McpSession

Struct McpSession 

Source
pub struct McpSession {
    pub id: String,
    pub initialized: bool,
    pub client_info: Option<Expr>,
    pub protocol_version: String,
    pub profile: McpProfile,
    pub native_cards: Vec<McpNativeCard>,
    pub granted_capabilities: Vec<CapabilityName>,
    pub deadline_ms: Option<u64>,
    pub rate_limit: Option<usize>,
    pub active_request_limit: Option<usize>,
    pub active_requests: BTreeSet<String>,
    pub shutdown_requested: bool,
    /* private fields */
}
Expand description

Mutable per-connection MCP session state.

Tracks the handshake, the visibility profile, granted capabilities, and the in-flight request bookkeeping used to enforce deadline, rate, and concurrency boundaries.

Fields§

§id: String

Stable session identifier.

§initialized: bool

Whether the initialize handshake has completed.

§client_info: Option<Expr>

Client info reported during initialization, if any.

§protocol_version: String

Negotiated MCP protocol version.

§profile: McpProfile

Visibility profile filtering the surface for this session.

§native_cards: Vec<McpNativeCard>

Native cards exposed through this session.

§granted_capabilities: Vec<CapabilityName>

Capabilities granted to this session.

§deadline_ms: Option<u64>

Optional per-request deadline budget, in milliseconds.

§rate_limit: Option<usize>

Optional cap on the total number of requests admitted.

§active_request_limit: Option<usize>

Optional cap on concurrently active requests.

§active_requests: BTreeSet<String>

Identifiers of currently in-flight requests.

§shutdown_requested: bool

Whether the peer has requested shutdown.

Implementations§

Source§

impl McpSession

Source

pub fn new(id: impl Into<String>, profile: McpProfile) -> Self

Creates a session with the given id and visibility profile.

Source

pub fn fixture() -> Self

Creates a permissive session for tests and fixtures.

Source

pub fn with_native_cards(self, cards: Vec<McpNativeCard>) -> Self

Returns the session with its native cards replaced by cards.

Source

pub fn with_granted_capability(self, capability: CapabilityName) -> Self

Returns the session with capability added to the granted set.

Source

pub fn with_deadline_ms(self, deadline_ms: u64) -> Self

Returns the session with a per-request deadline_ms budget.

Source

pub fn with_rate_limit(self, limit: usize) -> Self

Returns the session with a total request limit.

Source

pub fn with_active_request_limit(self, limit: usize) -> Self

Returns the session with a concurrent active-request limit.

Trait Implementations§

Source§

impl Clone for McpSession

Source§

fn clone(&self) -> McpSession

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.