mcpImage

Builds an image MCP content block. data is a base64-encoded string of the image bytes and mimeType is the image's MIME type (e.g. "image/png"). The block passes through the automatic result coercion untouched, so use it when a tool wants exact control over what the client renders. An omitted mimeType is left out rather than written as null.

mcpImage( data [, mimeType] ) → returns struct

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

data string
Required

Base64-encoded image bytes.

mimeType string

The MIME type of the image, e.g. "image/png".

Links more information about mcpImage

Examples
Sample code invoking the mcpImage function

Pair a text block with an image block in a single content list.

function chart() tool="chart" {
    var bytes = renderChart();
    return [
        mcpText( "Here is the chart:" ),
        mcpImage( toBase64( bytes ), "image/png" )
    ];
}

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub