pub struct LocalSessionManager {
pub sessions: RwLock<HashMap<Arc<str>, LocalSessionHandle>>,
pub session_config: SessionConfig,
}Fields§
§sessions: RwLock<HashMap<Arc<str>, LocalSessionHandle>>§session_config: SessionConfigTrait Implementations§
Source§impl Debug for LocalSessionManager
impl Debug for LocalSessionManager
Source§impl Default for LocalSessionManager
impl Default for LocalSessionManager
Source§fn default() -> LocalSessionManager
fn default() -> LocalSessionManager
Returns the “default value” for a type. Read more
Source§impl SessionManager for LocalSessionManager
impl SessionManager for LocalSessionManager
type Error = LocalSessionManagerError
type Transport = WorkerTransport<LocalSessionWorker>
Source§async fn create_session(
&self,
) -> Result<(Arc<str>, <LocalSessionManager as SessionManager>::Transport), <LocalSessionManager as SessionManager>::Error>
async fn create_session( &self, ) -> Result<(Arc<str>, <LocalSessionManager as SessionManager>::Transport), <LocalSessionManager as SessionManager>::Error>
Create a new session and return its ID together with the transport
that will be used to exchange MCP messages within this session.
Source§async fn initialize_session(
&self,
id: &Arc<str>,
message: JsonRpcMessage<ClientRequest, ClientResult, ClientNotification>,
) -> Result<JsonRpcMessage<ServerRequest, ServerResult, ServerNotification>, <LocalSessionManager as SessionManager>::Error>
async fn initialize_session( &self, id: &Arc<str>, message: JsonRpcMessage<ClientRequest, ClientResult, ClientNotification>, ) -> Result<JsonRpcMessage<ServerRequest, ServerResult, ServerNotification>, <LocalSessionManager as SessionManager>::Error>
Forward the first message (the
initialize request) to the session.Source§async fn close_session(
&self,
id: &Arc<str>,
) -> Result<(), <LocalSessionManager as SessionManager>::Error>
async fn close_session( &self, id: &Arc<str>, ) -> Result<(), <LocalSessionManager as SessionManager>::Error>
Close and remove the session. Corresponds to an HTTP DELETE request
with
Mcp-Session-Id.Source§async fn has_session(
&self,
id: &Arc<str>,
) -> Result<bool, <LocalSessionManager as SessionManager>::Error>
async fn has_session( &self, id: &Arc<str>, ) -> Result<bool, <LocalSessionManager as SessionManager>::Error>
Return
true if a session with the given ID exists and is active.Source§async fn create_stream(
&self,
id: &Arc<str>,
message: JsonRpcMessage<ClientRequest, ClientResult, ClientNotification>,
) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, <LocalSessionManager as SessionManager>::Error>
async fn create_stream( &self, id: &Arc<str>, message: JsonRpcMessage<ClientRequest, ClientResult, ClientNotification>, ) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, <LocalSessionManager as SessionManager>::Error>
Route a client request into the session and return an SSE stream
carrying the server’s response(s).
Source§async fn create_standalone_stream(
&self,
id: &Arc<str>,
) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, <LocalSessionManager as SessionManager>::Error>
async fn create_standalone_stream( &self, id: &Arc<str>, ) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, <LocalSessionManager as SessionManager>::Error>
Create an SSE stream not tied to a specific client request (HTTP GET).
Source§async fn resume(
&self,
id: &Arc<str>,
last_event_id: String,
) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, <LocalSessionManager as SessionManager>::Error>
async fn resume( &self, id: &Arc<str>, last_event_id: String, ) -> Result<impl Stream<Item = ServerSseMessage> + Send + 'static, <LocalSessionManager as SessionManager>::Error>
Resume an SSE stream from the given
Last-Event-ID, replaying any
events the client missed.Source§async fn accept_message(
&self,
id: &Arc<str>,
message: JsonRpcMessage<ClientRequest, ClientResult, ClientNotification>,
) -> Result<(), <LocalSessionManager as SessionManager>::Error>
async fn accept_message( &self, id: &Arc<str>, message: JsonRpcMessage<ClientRequest, ClientResult, ClientNotification>, ) -> Result<(), <LocalSessionManager as SessionManager>::Error>
Accept a notification, response, or error message from the client
without producing a response stream.
Auto Trait Implementations§
impl !Freeze for LocalSessionManager
impl !RefUnwindSafe for LocalSessionManager
impl Send for LocalSessionManager
impl Sync for LocalSessionManager
impl Unpin for LocalSessionManager
impl UnsafeUnpin for LocalSessionManager
impl UnwindSafe for LocalSessionManager
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