ServerConfig

Struct ServerConfig 

Source
pub struct ServerConfig {
    pub transport: TransportType,
    pub command: String,
    pub args: Vec<String>,
    pub env: HashMap<String, String>,
    pub cwd: Option<PathBuf>,
    pub url: Option<String>,
    pub headers: HashMap<String, String>,
}
Expand description

MCP server configuration with command, arguments, and environment.

Represents the configuration needed to communicate with an MCP server, supporting both stdio (subprocess) and HTTP transports.

§Transport Types

  • Stdio: Launches a subprocess and communicates via stdin/stdout
  • HTTP: Connects to an HTTP/HTTPS API endpoint

§Security

This type is designed to be safe by construction. Use the builder pattern to construct instances, and call validate_server_config before execution to ensure security requirements are met.

§Examples

use mcp_execution_core::ServerConfig;

// Stdio transport
let config = ServerConfig::builder()
    .command("docker".to_string())
    .arg("run".to_string())
    .arg("mcp-server".to_string())
    .build();

assert_eq!(config.command, "docker");
assert_eq!(config.args.len(), 2);

// HTTP transport
let config = ServerConfig::builder()
    .http_transport("https://api.example.com/mcp".to_string())
    .header("Authorization".to_string(), "Bearer token".to_string())
    .build();

Fields§

§transport: TransportType

Transport type (stdio or http).

Determines how the client communicates with the MCP server.

§command: String

Command to execute (binary name or absolute path).

Only used for stdio transport.

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.

Only used for stdio transport.

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.

Only used for stdio transport.

These are added to (or override) the parent process environment. Security validation blocks dangerous variables like LD_PRELOAD.

§cwd: Option<PathBuf>

Working directory for the subprocess (optional).

Only used for stdio transport.

If None, inherits the parent process working directory.

§url: Option<String>

URL for HTTP transport.

Only used for HTTP transport.

Example: https://api.example.com/mcp

§headers: HashMap<String, String>

HTTP headers for HTTP transport.

Only used for HTTP transport.

Common headers include:

  • Authorization: Authentication token
  • Content-Type: Request content type

Implementations§

Source§

impl ServerConfig

Source

pub fn builder() -> ServerConfigBuilder

Creates a new builder for ServerConfig.

§Examples
use mcp_execution_core::ServerConfig;

let config = ServerConfig::builder()
    .command("docker".to_string())
    .build();
Source

pub const fn transport(&self) -> &TransportType

Returns the transport type.

Source

pub fn command(&self) -> &str

Returns the command as a string slice.

Source

pub fn args(&self) -> &[String]

Returns a slice of arguments.

Source

pub const fn env(&self) -> &HashMap<String, String>

Returns a reference to the environment variables map.

Source

pub const fn cwd(&self) -> Option<&PathBuf>

Returns the working directory, if set.

Source

pub fn url(&self) -> Option<&str>

Returns the URL for HTTP transport, if set.

Source

pub const fn headers(&self) -> &HashMap<String, String>

Returns a reference to the HTTP headers map.

Trait Implementations§

Source§

impl Clone for ServerConfig

Source§

fn clone(&self) -> ServerConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ServerConfig

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 PartialEq for ServerConfig

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ServerConfig

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 Eq for ServerConfig

Source§

impl StructuralPartialEq for ServerConfig

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> 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.
Source§

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