pub struct RequestContext {
pub client_info: Option<ClientInfo>,
pub request_id: Value,
pub initialized: bool,
pub metadata: HashMap<String, Value>,
}Expand description
Context for an MCP request.
Fields§
§client_info: Option<ClientInfo>Connected client info, if available.
request_id: ValueJSON-RPC request ID.
initialized: boolWhether the connection has been initialized.
metadata: HashMap<String, Value>Arbitrary key-value metadata.
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn with_client_info(self, info: ClientInfo) -> Self
pub fn with_client_info(self, info: ClientInfo) -> Self
Set the client info.
Sourcepub fn set_initialized(&mut self)
pub fn set_initialized(&mut self)
Mark this context as initialized.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&Value>
pub fn get_metadata(&self, key: &str) -> Option<&Value>
Get a metadata value by key.
Sourcepub fn set_metadata(&mut self, key: String, value: Value)
pub fn set_metadata(&mut self, key: String, value: Value)
Set a metadata key-value pair.
Trait Implementations§
Source§impl Clone for RequestContext
impl Clone for RequestContext
Source§fn clone(&self) -> RequestContext
fn clone(&self) -> RequestContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RequestContext
impl RefUnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnsafeUnpin for RequestContext
impl UnwindSafe for RequestContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more