pub struct StreamableHttpTransport { /* private fields */ }mcp only.Expand description
Streamable-HTTP MCP transport.
Construct with StreamableHttpTransport::new for a live connection, or
StreamableHttpTransport::with_poster to inject a custom HttpPoster
(used by tests).
Implementations§
Source§impl StreamableHttpTransport
impl StreamableHttpTransport
Sourcepub fn new(endpoint: impl Into<String>, auth: McpAuth) -> Result<Arc<Self>>
pub fn new(endpoint: impl Into<String>, auth: McpAuth) -> Result<Arc<Self>>
Create a transport that talks to endpoint over real HTTP.
§Errors
Returns an error if the underlying HTTP client cannot be built.
Sourcepub fn with_poster(poster: Arc<dyn HttpPoster>, auth: McpAuth) -> Arc<Self>
pub fn with_poster(poster: Arc<dyn HttpPoster>, auth: McpAuth) -> Arc<Self>
Create a transport backed by a custom HttpPoster.
This is the seam tests use to script JSON / SSE responses without a network.
Sourcepub fn builder(endpoint: impl Into<String>, auth: McpAuth) -> Result<Self>
pub fn builder(endpoint: impl Into<String>, auth: McpAuth) -> Result<Self>
Create an un-wrapped transport over real HTTP for further builder-style
configuration (e.g. StreamableHttpTransport::with_header).
Wrap the result in Arc before handing it to McpClient::new:
use std::sync::Arc;
use agent_sdk::mcp::{McpAuth, StreamableHttpTransport};
let transport = Arc::new(
StreamableHttpTransport::builder("https://example.com/mcp", McpAuth::None)?
.with_header("X-Tenant-Id", "acme"),
);§Errors
Returns an error if the underlying HTTP client cannot be built.
Sourcepub fn with_poster_owned(poster: Arc<dyn HttpPoster>, auth: McpAuth) -> Self
pub fn with_poster_owned(poster: Arc<dyn HttpPoster>, auth: McpAuth) -> Self
Create an un-wrapped transport backed by a custom HttpPoster, for
further builder-style configuration before wrapping in Arc.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Add a static custom header sent on every request (e.g. a tenant id).
Call this on an un-wrapped transport from StreamableHttpTransport::builder
(or StreamableHttpTransport::with_poster_owned) before wrapping it in
Arc.