pub struct McpTransport { /* private fields */ }Expand description
How an McpClient reaches its server (McpTransport).
Built-in transports (stdio, sse) start afresh on every connect,
so a client can reconnect. A transport passed to new starts once; use
from_fn to build a fresh one on every connect. A streamable HTTP client is
configured with McpClientConfig::url instead.
Implementations§
Source§impl McpTransport
impl McpTransport
Sourcepub fn sse(url: &str, headers: Option<BTreeMap<String, String>>) -> Result<Self>
pub fn sse(url: &str, headers: Option<BTreeMap<String, String>>) -> Result<Self>
Connects over the legacy HTTP+SSE protocol (SSEClientTransport): url serves the event
stream, and headers go on every request.
use strands::mcp::McpTransport;
let transport = McpTransport::sse("http://localhost:8000/sse", None)?;§Errors
An invalid URL, header name or header value.
Source§impl McpTransport
impl McpTransport
Sourcepub fn new<T, E, A>(transport: T) -> Self
pub fn new<T, E, A>(transport: T) -> Self
Wraps any rmcp client transport, such as one end of an in-memory duplex stream. It can
start only once; a reconnect fails.
Sourcepub fn from_fn<F, Fut, T, E, A>(factory: F) -> Self
pub fn from_fn<F, Fut, T, E, A>(factory: F) -> Self
Builds a fresh rmcp client transport on every connect.
Sourcepub fn stdio(params: StdioServerParameters) -> Self
pub fn stdio(params: StdioServerParameters) -> Self
Spawns the server as a child process and talks to it over stdin and stdout.
Trait Implementations§
Source§impl Clone for McpTransport
impl Clone for McpTransport
Auto Trait Implementations§
impl !RefUnwindSafe for McpTransport
impl !UnwindSafe for McpTransport
impl Freeze for McpTransport
impl Send for McpTransport
impl Sync for McpTransport
impl Unpin for McpTransport
impl UnsafeUnpin for McpTransport
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.