Skip to main content

McpTransport

Trait McpTransport 

Source
pub trait McpTransport: Send + Sync {
    // Required methods
    fn list_tools<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, McpTransportError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn call_tool<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, McpTransportError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), McpTransportError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_alive(&self) -> bool;
    fn transport_type(&self) -> TransportTypeId;
}
Expand description

Abstract transport interface for MCP server communication.

All MCP transports (stdio, HTTP, SSE) implement this trait to provide a uniform interface for tool discovery, execution, and shutdown.

Required Methods§

Source

fn list_tools<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, McpTransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the list of available tools from the server.

Source

fn call_tool<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, McpTransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a tool with the given arguments.

Source

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

Perform a clean shutdown of the transport.

Source

fn is_alive(&self) -> bool

Check if the transport is still connected/alive.

Source

fn transport_type(&self) -> TransportTypeId

Get the transport type identifier.

Implementors§

Source§

impl McpTransport for HttpTransportAdapter

Available on crate feature http only.
Source§

impl McpTransport for StdioTransportAdapter

Available on crate feature stdio only.