pub enum Transport {
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
Transport-specific configuration for connecting to an MCP server.
Each variant carries exactly the fields meaningful for that transport, so a config with
stdio’s command/args/env/cwd set alongside http/sse’s url/headers — or a
Stdio variant missing command, or an Http/Sse variant missing url — cannot be
constructed at all; the combination is unrepresentable rather than merely unvalidated
(issue #313). ServerConfig::builder is the normal way to construct one; a bare
Transport value is mostly useful for matching on ServerConfig::transport.
§Examples
use mcp_execution_core::{ServerConfig, Transport};
let config = ServerConfig::builder()
.command("docker".to_string())
.build()
.unwrap();
assert!(matches!(config.transport(), Transport::Stdio { .. }));Variants§
Stdio
Stdio transport: subprocess communication via stdin/stdout.
Fields
command: StringCommand to execute (binary name or absolute path).
Can be either:
- Binary name (e.g., “docker”, “python”) - resolved via PATH
- Absolute path (e.g., “/usr/local/bin/mcp-server”)
args: Vec<String>Arguments to pass to command.
Each argument is passed separately to avoid shell interpretation. Do not include the command itself in arguments.
env: HashMap<String, String>Environment variables to set for the subprocess.
These are added to (or override) the parent process environment.
Security validation blocks dangerous variables like LD_PRELOAD.
Values routinely hold secrets (e.g. GITHUB_PERSONAL_ACCESS_TOKEN); see
the redaction note on ServerConfig’s own doc comment.
Http
HTTP transport: communication via HTTP/HTTPS API.
Fields
url: StringURL for HTTP transport.
Example: https://api.example.com/mcp
This crate does not apply SSRF allowlisting to this URL — it is
treated like a curl target, appropriate for a local CLI tool.
Embedders that expose this config in a multi-tenant or server context
should apply their own URL allowlisting before connecting.
headers: HashMap<String, String>HTTP headers for HTTP transport.
Common headers include:
Authorization: Authentication tokenContent-Type: Request content type
Values routinely hold secrets (e.g. a bearer token); see the redaction
note on ServerConfig’s own doc comment.
Sse
SSE transport: Server-Sent Events for streaming communication.
Fields
url: StringURL for SSE transport.
Same shape and SSRF caveat as Transport::Http’s url.
headers: HashMap<String, String>HTTP headers for SSE transport.
Same shape and redaction guarantee as Transport::Http’s headers.
Trait Implementations§
Source§impl Debug for Transport
impl Debug for Transport
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Redacts the same fields, the same way, as ServerConfig’s own hand-written impl —
see the “Security” section on that type’s doc comment for the full rationale. Kept as a
standalone impl (rather than ServerConfig delegating to it) so each type’s Debug
output stays exactly what it was already documented and tested to be.
§Examples
use mcp_execution_core::Transport;
use std::collections::HashMap;
let transport = Transport::Http {
url: "https://user:sk-secret@api.example.com/mcp?token=sk-secret".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("api.example.com/mcp"));
assert!(!debug_output.contains("sk-secret"));