Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

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
NameRequiredDescriptionDefault
roomIdYes
eventYes

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 })
        );
      }
    );
  • 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 })
      );
    }
  • Input schema for 'broadcast-event' tool: requires roomId (string) and event (arbitrary record).
    {
      roomId: z.string(),
      event: z.record(z.string(), z.any()),
    },
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liveblocks/liveblocks-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server