use crate::mcp::{GenericMeta, IntoMcpNotification, IntoMcpRequest, McpNotification, RequestMeta};
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum LoggingLevel {
Debug,
Info,
Notice,
Warning,
Error,
Critical,
Alert,
Emergency,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetLevelParams {
#[serde(rename = "_meta")]
pub meta: Option<RequestMeta>,
pub level: LoggingLevel,
}
impl SetLevelParams {
pub fn new(level: LoggingLevel) -> Self {
Self { meta: None, level }
}
pub fn with_meta(mut self, meta: RequestMeta) -> Self {
self.meta = Some(meta);
self
}
}
impl IntoMcpRequest<SetLevelParams> for SetLevelParams {
const METHOD: &'static str = "logging/setLevel";
type McpResult = ();
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoggingMessageNotificationParams {
#[serde(rename = "_meta")]
pub meta: Option<GenericMeta>,
pub level: LoggingLevel,
pub logger: Option<String>,
pub data: Value,
}
impl LoggingMessageNotificationParams {
pub fn new(level: LoggingLevel, data: impl Into<Value>) -> Self {
Self {
meta: None,
level,
logger: None,
data: data.into(),
}
}
pub fn with_meta(mut self, meta: GenericMeta) -> Self {
self.meta = Some(meta);
self
}
pub fn with_logger(mut self, logger: impl Into<String>) -> Self {
self.logger = Some(logger.into());
self
}
}
impl IntoMcpNotification for LoggingMessageNotificationParams {
const METHOD: &'static str = "notifications/message";
}
pub type LoggingMessageNotification = McpNotification<LoggingMessageNotificationParams>;