Skip to main content

image_url_content

Function image_url_content 

Source
pub fn image_url_content(
    url: impl Into<String>,
    mime_type: Option<String>,
) -> Value
Expand description

Helper to create an image content response with URL

Creates a standard MCP image content response with image URL:

{
  "content": [{
    "type": "image",
    "imageUrl": "https://example.com/image.png",
    "mimeType": "image/png"
  }]
}

Use case: Return image by URL reference

§Example

fn handle_get_product_image(args: &Value) -> Result<Value, String> {
    let url = format!("https://cdn.example.com/products/{}.jpg", product_id);
    Ok(image_url_content(url, Some("image/jpeg".to_string())))
}