Skip to main content

html_content

Function html_content 

Source
pub fn html_content(html: impl Into<String>) -> Value
Expand description

Helper to create an HTML content response

Creates a standard MCP HTML content response:

{
  "content": [{
    "type": "html",
    "html": "<div>...</div>"
  }]
}

Use case: Rich HTML content for UIs

§Example

fn handle_get_formatted(args: &Value) -> Result<Value, String> {
    let html = format!("<div><h1>{}</h1><p>{}</p></div>", title, body);
    Ok(html_content(html))
}