Pushes an MCP notification to connected clients from anywhere: an ordinary page, a cfthread, or a scheduled job. This is the emit-from-anywhere ergonomic that wsPublish provides for WebSockets. The server argument is optional inside a handler (it defaults to the server the call is running on). When to is given, the notification is delivered only to that session; otherwise it is delivered to every session of the server that has a stream open. Returns the number of sessions reached. Always recorded into the mcp test log so the CFML test suite can assert on it with no client attached.
mcpNotify( server [, method [, params [, to]]] )
→ returns numeric
From any page or background job, publish a resource-changed notification to all open sessions of a server.
mcpNotify( server = "/mcp/docs", method = "notifications/resources/updated"
, params = { uri = "doc://pages/intro" } );
Expected Result: Returns the number of sessions the notification reached.
Use mcpSessions() to get live ids, then target one of them with the to argument.
var sessions = mcpSessions( "/mcp/docs" );
mcpNotify( server = "/mcp/docs", method = "notifications/announcement"
, params = { text = "redeployed" }, to = sessions[ 1 ] );
Expected Result: Returns 1 when the target session had a stream open.
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.