Skip to main content

synwire_core/mcp/
config.rs

1//! MCP server configuration variants.
2
3use serde::{Deserialize, Serialize};
4
5/// Configuration for connecting to an MCP server.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[non_exhaustive]
8pub enum McpServerConfig {
9    /// Launch a subprocess and communicate over its stdin/stdout.
10    Stdio {
11        /// Executable path.
12        command: String,
13        /// Command-line arguments.
14        args: Vec<String>,
15        /// Environment variables to pass to the subprocess.
16        env: std::collections::HashMap<String, String>,
17    },
18
19    /// Connect to an HTTP MCP server.
20    Http {
21        /// Base URL of the server (e.g. `http://localhost:3000`).
22        url: String,
23        /// Optional bearer token for authentication.
24        auth_token: Option<String>,
25        /// Connection timeout in seconds.
26        timeout_secs: Option<u64>,
27    },
28
29    /// Connect via Server-Sent Events (SSE) transport.
30    Sse {
31        /// SSE endpoint URL.
32        url: String,
33        /// Optional bearer token for authentication.
34        auth_token: Option<String>,
35        /// Connection timeout in seconds.
36        timeout_secs: Option<u64>,
37    },
38
39    /// An in-process MCP server created from tool definitions.
40    InProcess {
41        /// Logical name for the in-process server.
42        name: String,
43    },
44}
45
46impl McpServerConfig {
47    /// Returns the human-readable transport type name.
48    #[must_use]
49    pub const fn transport_kind(&self) -> &'static str {
50        match self {
51            Self::Stdio { .. } => "stdio",
52            Self::Http { .. } => "http",
53            Self::Sse { .. } => "sse",
54            Self::InProcess { .. } => "in-process",
55        }
56    }
57}