Skip to main content

ConnectionManager

Trait ConnectionManager 

Source
pub trait ConnectionManager: Send + Sync {
    // Required methods
    fn connect<'life0, 'async_trait>(
        &'life0 self,
        server: McpServerInfo,
    ) -> Pin<Box<dyn Future<Output = McpResult<McpConnection>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn disconnect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn disconnect_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection_id: &'life1 str,
        request: McpRequest,
    ) -> Pin<Box<dyn Future<Output = McpResult<McpResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send_with_timeout<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection_id: &'life1 str,
        request: McpRequest,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = McpResult<McpResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send_with_retry<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection_id: &'life1 str,
        request: McpRequest,
    ) -> Pin<Box<dyn Future<Output = McpResult<McpResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn cancel_request<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        connection_id: &'life1 str,
        request_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_connection(&self, id: &str) -> Option<McpConnection>;
    fn get_connection_by_server(
        &self,
        server_name: &str,
    ) -> Option<McpConnection>;
    fn get_all_connections(&self) -> Vec<McpConnection>;
    fn subscribe(&self) -> Receiver<ConnectionEvent>;
}
Expand description

Connection manager trait

Defines the interface for managing MCP server connections.

Required Methods§

Source

fn connect<'life0, 'async_trait>( &'life0 self, server: McpServerInfo, ) -> Pin<Box<dyn Future<Output = McpResult<McpConnection>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Connect to an MCP server

Source

fn disconnect<'life0, 'life1, 'async_trait>( &'life0 self, connection_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Disconnect from a server

Source

fn disconnect_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disconnect all connections

Source

fn send<'life0, 'life1, 'async_trait>( &'life0 self, connection_id: &'life1 str, request: McpRequest, ) -> Pin<Box<dyn Future<Output = McpResult<McpResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a request to a server

Source

fn send_with_timeout<'life0, 'life1, 'async_trait>( &'life0 self, connection_id: &'life1 str, request: McpRequest, timeout: Duration, ) -> Pin<Box<dyn Future<Output = McpResult<McpResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a request with timeout

Source

fn send_with_retry<'life0, 'life1, 'async_trait>( &'life0 self, connection_id: &'life1 str, request: McpRequest, ) -> Pin<Box<dyn Future<Output = McpResult<McpResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a request with retry

Source

fn cancel_request<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, connection_id: &'life1 str, request_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Cancel a pending request by sending a cancellation notification

Source

fn get_connection(&self, id: &str) -> Option<McpConnection>

Get a connection by ID

Source

fn get_connection_by_server(&self, server_name: &str) -> Option<McpConnection>

Get a connection by server name

Source

fn get_all_connections(&self) -> Vec<McpConnection>

Get all connections

Source

fn subscribe(&self) -> Receiver<ConnectionEvent>

Subscribe to connection events

Implementors§