Skip to main content
Glama
liveblocks
by liveblocks

broadcast-event

Send real-time events to a specified room in Liveblocks, enabling instant communication and updates for collaborative applications.

Instructions

Broadcast an event to a Liveblocks room

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventYes
roomIdYes

Implementation Reference

  • Executes the broadcast-event tool by calling Liveblocks broadcastEvent method wrapped in callLiveblocksApi.
    async ({ roomId, event }, extra) => { return await callLiveblocksApi( getLiveblocks().broadcastEvent(roomId, event, { signal: extra.signal }) ); }
  • Zod input schema for roomId (string) and event (any object).
    { roomId: z.string(), event: z.record(z.string(), z.any()), },
  • src/server.ts:175-187 (registration)
    Registers the 'broadcast-event' tool on the McpServer instance.
    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 }) ); } );
  • Utility function that wraps Liveblocks API promises, formats successful responses as JSON in MCP format, and handles errors.
    export async function callLiveblocksApi( liveblocksPromise: Promise<any> ): Promise<CallToolResult> { try { const data = await liveblocksPromise; if (!data) { return { content: [{ type: "text", text: "Success. No data returned." }], }; } return { content: [ { type: "text", text: "Here is the data. If the user has no specific questions, return it in a JSON code block", }, { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { return { content: [ { type: "text", text: "" + err, }, ], }; } }
  • Singleton factory for the Liveblocks client using the secret key from environment.
    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