use crate::mcp::{Cursor, GenericMeta, IntoMcpRequest, PaginationParams, Prompt, PromptMessage, RequestMeta};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use std::collections::HashMap;
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ListPromptsParams {
#[serde(rename = "_meta")]
pub meta: Option<RequestMeta>,
#[serde(flatten)]
pub pagination: PaginationParams,
}
impl ListPromptsParams {
pub fn new() -> Self {
Self::default()
}
pub fn with_meta(mut self, meta: RequestMeta) -> Self {
self.meta = Some(meta);
self
}
pub fn with_pagination(mut self, pagination: PaginationParams) -> Self {
self.pagination = pagination;
self
}
pub fn with_cursor(mut self, cursor: impl Into<Cursor>) -> Self {
self.pagination.cursor = Some(cursor.into());
self
}
}
impl IntoMcpRequest<ListPromptsParams> for ListPromptsParams {
const METHOD: &'static str = "prompts/list";
type McpResult = ListPromptsResult;
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListPromptsResult {
#[serde(rename = "_meta")]
pub meta: Option<GenericMeta>,
pub next_cursor: Option<Cursor>,
pub prompts: Vec<Prompt>,
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetPromptParams {
#[serde(rename = "_meta")]
pub meta: Option<RequestMeta>,
pub name: String,
pub arguments: Option<HashMap<String, String>>,
}
impl GetPromptParams {
pub fn new(name: impl Into<String>) -> Self {
Self {
meta: None,
name: name.into(),
arguments: None,
}
}
pub fn with_meta(mut self, meta: RequestMeta) -> Self {
self.meta = Some(meta);
self
}
pub fn with_arguments(mut self, arguments: HashMap<String, String>) -> Self {
self.arguments = Some(arguments);
self
}
pub fn append_argument(mut self, name: impl Into<String>, value: impl Into<String>) -> Self {
self.arguments
.get_or_insert_with(HashMap::new)
.insert(name.into(), value.into());
self
}
}
impl IntoMcpRequest<GetPromptParams> for GetPromptParams {
const METHOD: &'static str = "prompts/get";
type McpResult = GetPromptResult;
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetPromptResult {
#[serde(rename = "_meta")]
pub meta: Option<GenericMeta>,
pub description: Option<String>,
pub messages: Vec<PromptMessage>,
}