#[non_exhaustive]pub enum Connection {
Stdio {
command: String,
args: Vec<String>,
env: HashMap<String, String>,
},
Sse {
url: String,
auth_token: Option<String>,
timeout_secs: Option<u64>,
},
StreamableHttp {
url: String,
auth_token: Option<String>,
timeout_secs: Option<u64>,
},
WebSocket {
url: String,
auth_token: Option<String>,
},
}Expand description
Configuration for connecting to a single MCP server.
Each variant describes a different transport mechanism.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Stdio
Launch a subprocess and communicate over its stdin/stdout.
Fields
Sse
Connect via Server-Sent Events (SSE) transport.
Fields
StreamableHttp
Connect via Streamable HTTP (MCP 2025-03-26 spec).
Fields
WebSocket
Connect via WebSocket.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn into_transport(
self,
name: &str,
) -> Result<Box<dyn McpTransport>, AgentError>
pub fn into_transport( self, name: &str, ) -> Result<Box<dyn McpTransport>, AgentError>
Creates a transport for this connection configuration.
Returns a Box<dyn McpTransport> suitable for use with
McpClientSession.
§Errors
Returns an error if the underlying transport cannot be initialised (e.g. HTTP client TLS failure).
Trait Implementations§
Source§impl Clone for Connection
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
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 Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl UnwindSafe for Connection
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