#[cfg(feature = "documents")]
use rmcp::ErrorData as McpError;
#[cfg(feature = "documents")]
use rmcp::model::{CallToolResult, Content};
#[cfg(feature = "documents")]
pub(crate) fn format_response<T: serde::Serialize>(
value: &T,
fmt: crate::config::OutputFormat,
) -> Result<CallToolResult, McpError> {
match fmt {
crate::config::OutputFormat::Json => super::helpers::json_result(value),
crate::config::OutputFormat::Toon => {
let body = serde_toon::to_string(value)
.map_err(|e| McpError::internal_error(format!("toon: {e}"), None))?;
Ok(CallToolResult::success(vec![Content::text(body)]))
}
}
}