Skip to main content

McpHttpClient

Trait McpHttpClient 

Source
pub trait McpHttpClient:
    Send
    + Sync
    + 'static {
    // Required methods
    fn post_message<'life0, 'async_trait>(
        &'life0 self,
        uri: Arc<str>,
        message: ClientJsonRpcMessage,
        session_id: Option<Arc<str>>,
        auth_header: Option<String>,
        custom_headers: HashMap<HeaderName, HeaderValue>,
    ) -> Pin<Box<dyn Future<Output = Result<StreamableHttpPostResponse, StreamableHttpError<Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_session<'life0, 'async_trait>(
        &'life0 self,
        uri: Arc<str>,
        session_id: Arc<str>,
        auth_header: Option<String>,
        custom_headers: HashMap<HeaderName, HeaderValue>,
    ) -> Pin<Box<dyn Future<Output = Result<(), StreamableHttpError<Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_stream<'life0, 'async_trait>(
        &'life0 self,
        uri: Arc<str>,
        session_id: Arc<str>,
        last_event_id: Option<String>,
        auth_header: Option<String>,
        custom_headers: HashMap<HeaderName, HeaderValue>,
    ) -> Pin<Box<dyn Future<Output = Result<McpSseStream, StreamableHttpError<Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Pluggable HTTP transport for the MCP Streamable HTTP client.

Mirrors rmcp::transport::streamable_http_client::StreamableHttpClient but is dyn-compatible (boxed via async_trait) so the configuration can store an Arc<dyn McpHttpClient> without genericizing every type that flows through McpServerConfig / McpTransportBinding.

The associated error type is fixed to reqwest::Error so that agentkit-mcp’s auth-challenge detection (which downcasts to StreamableHttpError<reqwest::Error>) keeps working — implementations that wrap a non-reqwest backend should map their failures into a reqwest::Error before returning.

All three methods are invoked by rmcp’s worker on every protocol op. auth_header and custom_headers carry the values resolved from StreamableHttpTransportConfig at connection time; implementations are free to ignore them and inject their own per-call values (e.g. a fresh bearer pulled from a runtime registry).

Required Methods§

Source

fn post_message<'life0, 'async_trait>( &'life0 self, uri: Arc<str>, message: ClientJsonRpcMessage, session_id: Option<Arc<str>>, auth_header: Option<String>, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> Pin<Box<dyn Future<Output = Result<StreamableHttpPostResponse, StreamableHttpError<Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

POSTs a single client→server JSON-RPC message. The response carries either a JSON body or an SSE stream depending on what the server negotiates.

Source

fn delete_session<'life0, 'async_trait>( &'life0 self, uri: Arc<str>, session_id: Arc<str>, auth_header: Option<String>, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> Pin<Box<dyn Future<Output = Result<(), StreamableHttpError<Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Tears down a server-issued session (HTTP DELETE).

Source

fn get_stream<'life0, 'async_trait>( &'life0 self, uri: Arc<str>, session_id: Arc<str>, last_event_id: Option<String>, auth_header: Option<String>, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> Pin<Box<dyn Future<Output = Result<McpSseStream, StreamableHttpError<Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Opens a server→client SSE stream (HTTP GET) for push notifications and reconnect resumes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§