pub enum McpTransport {
Stdio {
command: String,
args: Vec<String>,
env: HashMap<String, String>,
cwd: Option<PathBuf>,
},
Http {
url: String,
headers: HashMap<String, String>,
},
Sse {
url: String,
headers: HashMap<String, String>,
},
}Expand description
Canonical in-crate representation of an MCP server’s transport.
This is the single source of truth for “stdio vs http vs sse”, shared by
both the mcp.json config path (McpServerEntry) and the CLI-flag path
(TransportArgs converts into this via TryFrom).
§Examples
use mcp_execution_cli::commands::common::McpTransport;
use std::collections::HashMap;
let transport = McpTransport::Http {
url: "https://api.example.com/mcp".to_string(),
headers: HashMap::new(),
};
assert!(matches!(transport, McpTransport::Http { .. }));Debug output redacts header/env values (keeping keys), args wholesale,
and URL userinfo/query strings, mirroring mcp_execution_core::ServerConfig:
use mcp_execution_cli::commands::common::McpTransport;
use std::collections::HashMap;
let transport = McpTransport::Http {
url: "https://api.example.com/mcp".to_string(),
headers: HashMap::from([("Authorization".to_string(), "Bearer sk-secret".to_string())]),
};
let debug_output = format!("{transport:?}");
assert!(debug_output.contains("Authorization"));
assert!(!debug_output.contains("sk-secret"));Variants§
Stdio
Stdio transport: spawn a subprocess and speak MCP over stdin/stdout.
Fields
Http
Streamable HTTP transport.
Fields
Sse
Server-Sent Events transport.
Trait Implementations§
Source§impl Clone for McpTransport
impl Clone for McpTransport
Source§fn clone(&self) -> McpTransport
fn clone(&self) -> McpTransport
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for McpTransport
impl Debug for McpTransport
Source§impl TryFrom<TransportArgs> for McpTransport
impl TryFrom<TransportArgs> for McpTransport
Auto Trait Implementations§
impl Freeze for McpTransport
impl RefUnwindSafe for McpTransport
impl Send for McpTransport
impl Sync for McpTransport
impl Unpin for McpTransport
impl UnsafeUnpin for McpTransport
impl UnwindSafe 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