mcpSessions

Returns the live session ids for an MCP server as an array of strings, so a page can see which clients are connected and target one of them with mcpNotify( to= ). The server argument is optional inside a handler (it defaults to the server of the current call). When no server is running or no session matches, an empty array is returned.

mcpSessions( [ server ] ) → returns array

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

Argument Reference

server string

The MCP server whose sessions to list, e.g. "/mcp/docs". Inside a handler this defaults to the server of the current call.

Links more information about mcpSessions

Examples
Sample code invoking the mcpSessions function

Use mcpSessions() to see who is connected, then target a specific session with mcpNotify( to= ).

var sessions = mcpSessions( "/mcp/docs" );
writeOutput( "connected sessions: #arrayLen( sessions )#\n" );

Expected Result: An array of session id strings; empty when nobody is connected.

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

Fork me on GitHub