Returns the live handle for the MCP call in flight. Only available inside an MCP tool, resource, or prompt handler. The handle lets a long-running tool report progress, emit structured logs, inspect the client and session, ask the client for sampling or input, and send tool-change notifications. Each handle method returns a boolean saying whether the notification was actually delivered, so a tool can tell when nobody is listening.
mcp()
→ returns any
Inside a tool that declares streaming=true, use mcp() to push progress notifications and structured log messages back to the client.
function reindex( numeric batches = 10 ) tool="reindex" streaming=true {
for ( var i = 1; i <= arguments.batches; i++ ) {
indexBatch( i );
mcp().progress( i, arguments.batches, "batch #i# of #arguments.batches#" );
mcp().log( "info", "indexed batch #i#" );
}
return "reindexed #arguments.batches# batches";
}
mcp().session(), mcp().server(), mcp().client(), and mcp().streaming() expose the conversation/server identifiers, the client's initialize details and capabilities, and whether this call has a stream.
function whoami() tool="whoami" {
var info = {
session = mcp().session(),
server = mcp().server(),
streaming = mcp().streaming(),
client = mcp().client()
};
return info;
}
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.