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§
Sourcefn 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 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
Sourcefn 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<'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
Sourcefn disconnect_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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,
Disconnect all connections
Sourcefn 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<'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
Sourcefn 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_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
Sourcefn 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 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
Sourcefn 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 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
Sourcefn get_connection(&self, id: &str) -> Option<McpConnection>
fn get_connection(&self, id: &str) -> Option<McpConnection>
Get a connection by ID
Sourcefn get_connection_by_server(&self, server_name: &str) -> Option<McpConnection>
fn get_connection_by_server(&self, server_name: &str) -> Option<McpConnection>
Get a connection by server name
Sourcefn get_all_connections(&self) -> Vec<McpConnection>
fn get_all_connections(&self) -> Vec<McpConnection>
Get all connections
Sourcefn subscribe(&self) -> Receiver<ConnectionEvent>
fn subscribe(&self) -> Receiver<ConnectionEvent>
Subscribe to connection events