mcpResource

Builds a resource MCP content block. The resource argument is the embedded resource content (typically a struct with a uri and the resource payload). The block passes through the automatic result coercion untouched, so use it when a tool wants exact control over what the client renders.

mcpResource( resource ) → returns struct

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

Argument Reference

resource any
Required

The embedded resource, usually a struct describing the resource's uri and content.

Links more information about mcpResource

Examples
Sample code invoking the mcpResource function

Embed a resource directly in a tool response.

function page() tool="page" {
    var bytes = fileRead( expandPath( "/pages/intro.txt" ) );
    return mcpResource( {
        uri    = "doc://pages/intro",
        mimeType = "text/plain",
        text     = toString( bytes )
    } );
}

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

Fork me on GitHub