use super::types::McpContent;
pub fn transform_mcp_content(content: &[McpContent]) -> String {
let mut parts = Vec::new();
for item in content {
match item {
McpContent::Text { text } => {
parts.push(text.clone());
}
McpContent::Image { mime_type, .. } => {
parts.push(format!(
"[Image content: {}]",
mime_type.as_deref().unwrap_or("image/*")
));
}
McpContent::Resource { resource } => {
let uri = &resource.uri;
if let Some(text) = &resource.text {
parts.push(format!("[Resource: {uri}]\n{text}"));
} else if resource.blob.is_some() {
parts.push(format!("[Resource: {uri}] (binary)"));
} else {
parts.push(format!("[Resource: {uri}] (empty)"));
}
}
}
}
if parts.is_empty() {
"(empty result)".to_string()
} else {
parts.join("\n")
}
}