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: TransportTypeTransport type (stdio or http).
Determines how the client communicates with the MCP server.
command: StringCommand 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 tokenContent-Type: Request content type
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn builder() -> ServerConfigBuilder
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();Sourcepub const fn transport(&self) -> &TransportType
pub const fn transport(&self) -> &TransportType
Returns the transport type.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more