broadcast-event
Send real-time events to all users in a Liveblocks room to enable synchronized collaboration and communication.
Instructions
Broadcast an event to a Liveblocks room
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roomId | Yes | ||
| event | Yes |
Implementation Reference
- src/server.ts:175-187 (registration)Registration of the 'broadcast-event' MCP tool, including inline input schema (roomId: string, event: record) and handler function that calls Liveblocks API to broadcast the event to the specified room.server.tool( "broadcast-event", "Broadcast an event to a Liveblocks room", { roomId: z.string(), event: z.record(z.string(), z.any()), }, async ({ roomId, event }, extra) => { return await callLiveblocksApi( getLiveblocks().broadcastEvent(roomId, event, { signal: extra.signal }) ); } );
- src/server.ts:182-186 (handler)Handler function for 'broadcast-event' tool: destructures roomId and event from input, calls getLiveblocks().broadcastEvent with the parameters and extra.signal for abort handling.async ({ roomId, event }, extra) => { return await callLiveblocksApi( getLiveblocks().broadcastEvent(roomId, event, { signal: extra.signal }) ); }
- src/server.ts:178-181 (schema)Input schema for 'broadcast-event' tool: requires roomId (string) and event (arbitrary record).{ roomId: z.string(), event: z.record(z.string(), z.any()), },
- src/server.ts:21-28 (helper)Helper function getLiveblocks() that lazily initializes and returns the Liveblocks client instance used in the handler.function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }