pub struct StdioTransport { /* private fields */ }Expand description
Unstable (feature: mcp-transport) — may change or be removed
Stdio transport for a spawned MCP server process.Implementations§
Source§impl StdioTransport
impl StdioTransport
Sourcepub fn spawn(
command: &str,
args: &[String],
env: &HashMap<String, String>,
cwd: Option<&str>,
debug: bool,
validator: Option<&dyn SpawnValidator>,
) -> Result<StdioTransport, Error>
pub fn spawn( command: &str, args: &[String], env: &HashMap<String, String>, cwd: Option<&str>, debug: bool, validator: Option<&dyn SpawnValidator>, ) -> Result<StdioTransport, Error>
Spawn a child process and return a connected transport.
validator, when Some, is invoked BEFORE the spawn with
SpawnValidator::validate_command; an Err is converted to
anyhow::Error and short-circuits the spawn. After the SDK’s
hardcoded BLOCKED_ENV_VARS filter is applied, the validator’s
SpawnValidator::sanitize_env runs over the remaining env so
consumers can apply additional policy (path normalization, custom
blocked vars, etc.).
None preserves the pre-validator behavior: only the SDK’s
BLOCKED_ENV_VARS floor applies. Existing call sites pass None.
Sourcepub fn from_parts(
child: Child,
stdin: ChildStdin,
stdout: ChildStdout,
) -> StdioTransport
pub fn from_parts( child: Child, stdin: ChildStdin, stdout: ChildStdout, ) -> StdioTransport
Wrap an already-spawned child process.
Used internally by the client to allow later take_child.
Sourcepub fn take_child(&mut self) -> Option<Child>
pub fn take_child(&mut self) -> Option<Child>
Take the child process out (for graceful shutdown via signal).
Trait Implementations§
Source§impl Debug for StdioTransport
impl Debug for StdioTransport
Source§impl McpTransport for StdioTransport
impl McpTransport for StdioTransport
Source§fn request<'life0, 'life1, 'async_trait>(
&'life0 mut self,
id: u64,
json: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<RawJsonRpcMessage, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StdioTransport: 'async_trait,
fn request<'life0, 'life1, 'async_trait>(
&'life0 mut self,
id: u64,
json: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<RawJsonRpcMessage, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StdioTransport: 'async_trait,
Send a JSON-RPC request and await the matching response. Read more
Source§fn notify<'life0, 'life1, 'async_trait>(
&'life0 mut self,
json: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StdioTransport: 'async_trait,
fn notify<'life0, 'life1, 'async_trait>(
&'life0 mut self,
json: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StdioTransport: 'async_trait,
Send a JSON-RPC notification (no response expected).
Source§fn set_inbound_handler(
&mut self,
handler: Box<dyn FnMut(RawJsonRpcMessage) -> Option<Value> + Send + Sync>,
)
fn set_inbound_handler( &mut self, handler: Box<dyn FnMut(RawJsonRpcMessage) -> Option<Value> + Send + Sync>, )
Install (or replace) the inbound handler. Called by the client before
the first
request so that any peer-sent message arriving during the
handshake is dispatched.Source§fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
StdioTransport: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
StdioTransport: 'async_trait,
Close the transport gracefully. Default is a no-op for transports
that close on drop.
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Whether the transport is currently connected.
Auto Trait Implementations§
impl !RefUnwindSafe for StdioTransport
impl !UnwindSafe for StdioTransport
impl Freeze for StdioTransport
impl Send for StdioTransport
impl Sync for StdioTransport
impl Unpin for StdioTransport
impl UnsafeUnpin for StdioTransport
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