Skip to main content

resource_content

Function resource_content 

Source
pub fn resource_content(
    uri: impl Into<String>,
    mime_type: Option<String>,
    text: Option<String>,
) -> Value
Expand description

Helper to create a resource content response

Creates a standard MCP resource content response:

{
  "content": [{
    "type": "resource",
    "uri": "https://example.com/resource",
    "mimeType": "text/html",  // optional
    "text": "content"         // optional
  }]
}

§Example

fn handle_get_resource(args: &Value) -> Result<Value, String> {
    Ok(resource_content(
        "https://example.com/docs",
        Some("text/html".to_string()),
        None
    ))
}