diff --git a/sgl-router/src/mcp/config.rs b/sgl-router/src/mcp/config.rs index 684f5e355..e5d913aa2 100644 --- a/sgl-router/src/mcp/config.rs +++ b/sgl-router/src/mcp/config.rs @@ -2,7 +2,7 @@ //! //! Defines configuration structures for MCP servers, transports, proxies, and inventory. -use std::collections::HashMap; +use std::{collections::HashMap, fmt}; pub use rmcp::model::{Prompt, RawResource, Tool}; use serde::{Deserialize, Serialize}; @@ -48,7 +48,7 @@ pub struct McpServerConfig { pub required: bool, } -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Clone, Deserialize, Serialize)] #[serde(tag = "protocol", rename_all = "lowercase")] pub enum McpTransport { Stdio { @@ -70,6 +70,33 @@ pub enum McpTransport { }, } +impl fmt::Debug for McpTransport { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + McpTransport::Stdio { + command, + args, + envs, + } => f + .debug_struct("Stdio") + .field("command", command) + .field("args", args) + .field("envs", envs) + .finish(), + McpTransport::Sse { url, token } => f + .debug_struct("Sse") + .field("url", url) + .field("token", &token.as_ref().map(|_| "****")) + .finish(), + McpTransport::Streamable { url, token } => f + .debug_struct("Streamable") + .field("url", url) + .field("token", &token.as_ref().map(|_| "****")) + .finish(), + } + } +} + /// MCP-specific proxy configuration (does NOT affect LLM API traffic) #[derive(Debug, Clone, Deserialize, Serialize)] pub struct McpProxyConfig {