pub struct McpSession { /* private fields */ }Expand description
An MCP session that manages the protocol lifecycle over a transport.
Implementations§
Source§impl McpSession
impl McpSession
Sourcepub async fn initialize(&mut self) -> Result<InitializeResult, SessionError>
pub async fn initialize(&mut self) -> Result<InitializeResult, SessionError>
Perform the MCP initialize handshake.
Sourcepub async fn list_tools(&mut self) -> Result<Vec<Tool>, SessionError>
pub async fn list_tools(&mut self) -> Result<Vec<Tool>, SessionError>
List all tools, following pagination cursors.
Sourcepub async fn call_tool(
&mut self,
name: &str,
arguments: Value,
) -> Result<CallToolResult, SessionError>
pub async fn call_tool( &mut self, name: &str, arguments: Value, ) -> Result<CallToolResult, SessionError>
Call a specific tool.
Sourcepub async fn send_raw(
&mut self,
raw: &str,
) -> Result<Option<String>, TransportError>
pub async fn send_raw( &mut self, raw: &str, ) -> Result<Option<String>, TransportError>
Send a raw string message (bypasses all type checking). Used for fuzzing.
Sourcepub async fn send_request(
&mut self,
req: &JsonRpcRequest,
) -> Result<JsonRpcResponse, TransportError>
pub async fn send_request( &mut self, req: &JsonRpcRequest, ) -> Result<JsonRpcResponse, TransportError>
Send a typed request and get the raw JSON-RPC response.
Sourcepub fn server_capabilities(&self) -> Option<&ServerCapabilities>
pub fn server_capabilities(&self) -> Option<&ServerCapabilities>
Get the server capabilities (available after initialize).
Sourcepub fn server_info(&self) -> Option<&Implementation>
pub fn server_info(&self) -> Option<&Implementation>
Get the server info (available after initialize).
Sourcepub fn protocol_version(&self) -> Option<&str>
pub fn protocol_version(&self) -> Option<&str>
Get the negotiated protocol version.
Sourcepub async fn shutdown(&mut self) -> Result<(), TransportError>
pub async fn shutdown(&mut self) -> Result<(), TransportError>
Shut down the session and underlying transport.
Auto Trait Implementations§
impl !Freeze for McpSession
impl !RefUnwindSafe for McpSession
impl Send for McpSession
impl Sync for McpSession
impl Unpin for McpSession
impl UnsafeUnpin for McpSession
impl !UnwindSafe for McpSession
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