get-room
Retrieve a specific Liveblocks room using its unique room ID to enable real-time collaboration and data synchronization within the platform.
Instructions
Get a Liveblocks room
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roomId | Yes |
Implementation Reference
- src/server.ts:90-101 (registration)Full registration of the 'get-room' MCP tool, including inline input schema, description, and handler function that calls the Liveblocks SDK's getRoom method.server.tool( "get-room", "Get a Liveblocks room", { roomId: z.string(), }, async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getRoom(roomId, { signal: extra.signal }) ); } );
- src/server.ts:96-100 (handler)The handler function for 'get-room' which fetches the specified room using the Liveblocks client, passing the abort signal, and wraps the result with callLiveblocksApi.async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getRoom(roomId, { signal: extra.signal }) ); }
- src/server.ts:93-95 (schema)Input schema for 'get-room' tool: requires a 'roomId' string.{ roomId: z.string(), },
- src/server.ts:21-28 (helper)Helper function to lazily initialize and return the Liveblocks client instance using the LIVEBLOCKS_SECRET_KEY environment variable.function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }
- src/utils.ts:3-37 (helper)Shared helper utility that wraps Liveblocks API promise calls, formats successful responses as MCP CallToolResult with JSON stringified data, or error text on failure.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, }, ], }; } }