use schemars::JsonSchema;
#[derive(Debug, serde::Deserialize, JsonSchema)]
#[schemars(rename = "mcp.JsonRpcRequest")]
pub struct JsonRpcRequest {
pub jsonrpc: String,
pub id: serde_json::Value,
pub method: String,
#[serde(default)]
pub params: Option<serde_json::Value>,
}
#[derive(Debug, serde::Serialize, serde::Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "mcp.JsonRpcResponse.{T}", bound = "T: JsonSchema")]
pub enum JsonRpcResponse<T> {
Success {
jsonrpc: String,
id: serde_json::Value,
result: T,
},
Error {
jsonrpc: String,
id: serde_json::Value,
error: JsonRpcError,
},
}
#[derive(Debug, serde::Serialize, serde::Deserialize, JsonSchema)]
#[schemars(rename = "mcp.JsonRpcError")]
pub struct JsonRpcError {
pub code: i64,
pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(extend("omitempty" = true))]
pub data: Option<serde_json::Value>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, JsonSchema)]
#[schemars(rename = "mcp.JsonRpcNotification")]
pub struct JsonRpcNotification {
pub jsonrpc: String,
pub method: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schemars(extend("omitempty" = true))]
pub params: Option<serde_json::Value>,
}