[model-gateway] Avoid logging MCP connection token (#13887)

This commit is contained in:
Wenyi Xu
2025-12-01 20:44:31 +08:00
committed by GitHub
parent 45264554f3
commit e55731b6e8

View File

@@ -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 {