oxicode_agent/mcp/
content.rs1use super::types::McpContent;
7
8pub fn transform_mcp_content(content: &[McpContent]) -> String {
13 let mut parts = Vec::new();
14
15 for item in content {
16 match item {
17 McpContent::Text { text } => {
18 parts.push(text.clone());
19 }
20 McpContent::Image { mime_type, .. } => {
21 parts.push(format!(
22 "[Image content: {}]",
23 mime_type.as_deref().unwrap_or("image/*")
24 ));
25 }
26 McpContent::Resource { resource } => {
27 let uri = &resource.uri;
28 if let Some(text) = &resource.text {
29 parts.push(format!("[Resource: {uri}]\n{text}"));
30 } else if resource.blob.is_some() {
31 parts.push(format!("[Resource: {uri}] (binary)"));
32 } else {
33 parts.push(format!("[Resource: {uri}] (empty)"));
34 }
35 }
36 }
37 }
38
39 if parts.is_empty() {
40 "(empty result)".to_string()
41 } else {
42 parts.join("\n")
43 }
44}