pub struct StdioClientTransport { /* private fields */ }Expand description
STDIO transport for MCP clients
This transport communicates with an MCP server via STDIO (standard input/output). It’s typically used when the server is a separate process.
Implementations§
Source§impl StdioClientTransport
impl StdioClientTransport
Sourcepub async fn new_with_command(command: &str, args: &[String]) -> McpResult<Self>
pub async fn new_with_command(command: &str, args: &[String]) -> McpResult<Self>
Sourcepub async fn with_env<S: AsRef<str>>(
command: S,
args: Vec<S>,
env: HashMap<String, String>,
) -> McpResult<Self>
pub async fn with_env<S: AsRef<str>>( command: S, args: Vec<S>, env: HashMap<String, String>, ) -> McpResult<Self>
Sourcepub async fn with_config<S: AsRef<str>>(
command: S,
args: Vec<S>,
config: TransportConfig,
) -> McpResult<Self>
pub async fn with_config<S: AsRef<str>>( command: S, args: Vec<S>, config: TransportConfig, ) -> McpResult<Self>
Sourcepub async fn with_config_and_env<S: AsRef<str>>(
command: S,
args: Vec<S>,
config: TransportConfig,
env: Option<HashMap<String, String>>,
) -> McpResult<Self>
pub async fn with_config_and_env<S: AsRef<str>>( command: S, args: Vec<S>, config: TransportConfig, env: Option<HashMap<String, String>>, ) -> McpResult<Self>
Create a new STDIO client transport with custom configuration and environment
§Arguments
command- Command to execute for the MCP serverargs- Arguments to pass to the commandconfig- Transport configurationenv- Optional environment variables to set for the process
§Returns
Result containing the transport or an error
Trait Implementations§
Source§impl Debug for StdioClientTransport
impl Debug for StdioClientTransport
Source§impl Drop for StdioClientTransport
impl Drop for StdioClientTransport
Source§impl Transport for StdioClientTransport
impl Transport for StdioClientTransport
Source§fn send_request<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<JsonRpcResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_request<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<JsonRpcResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a JSON-RPC request and wait for a response Read more
Source§fn send_notification<'life0, 'async_trait>(
&'life0 mut self,
notification: JsonRpcNotification,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_notification<'life0, 'async_trait>(
&'life0 mut self,
notification: JsonRpcNotification,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a JSON-RPC notification (no response expected) Read more
Source§fn receive_notification<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<Option<JsonRpcNotification>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive_notification<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<Option<JsonRpcNotification>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive a notification from the server (non-blocking) Read more
Source§fn open_subscription<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<ClientSubscription>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open_subscription<'life0, 'async_trait>(
&'life0 mut self,
request: JsonRpcRequest,
) -> Pin<Box<dyn Future<Output = McpResult<ClientSubscription>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Open a modern long-lived subscription stream.
Source§fn cancel_subscription<'life0, 'life1, 'async_trait>(
&'life0 mut self,
request_id: &'life1 Value,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_subscription<'life0, 'life1, 'async_trait>(
&'life0 mut self,
request_id: &'life1 Value,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel an open subscription. HTTP implementations close the response
stream; STDIO implementations send
notifications/cancelled.Source§fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close the transport connection Read more
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if the transport is connected Read more
Source§fn connection_info(&self) -> String
fn connection_info(&self) -> String
Get connection information for debugging Read more
Auto Trait Implementations§
impl !RefUnwindSafe for StdioClientTransport
impl !UnwindSafe for StdioClientTransport
impl Freeze for StdioClientTransport
impl Send for StdioClientTransport
impl Sync for StdioClientTransport
impl Unpin for StdioClientTransport
impl UnsafeUnpin for StdioClientTransport
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
§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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].