Skip to main content

Transport

Enum Transport 

Source
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: String

Command 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.

§cwd: Option<PathBuf>

Working directory for the subprocess (optional).

If None, inherits the parent process working directory.

§

Http

HTTP transport: communication via HTTP/HTTPS API.

Fields

§url: String

URL 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 token
  • Content-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: String

URL 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 Clone for Transport

Source§

fn clone(&self) -> Transport

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transport

Source§

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"));
Source§

impl<'de> Deserialize<'de> for Transport

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Transport

Source§

impl PartialEq for Transport

Source§

fn eq(&self, other: &Transport) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Transport

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Transport

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.