get-room
Retrieve a Liveblocks room to access real-time collaboration data and manage collaborative sessions by providing the room identifier.
Instructions
Get a Liveblocks room
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roomId | Yes |
Implementation Reference
- src/server.ts:96-100 (handler)The core handler function for the 'get-room' tool. It takes roomId, calls getLiveblocks().getRoom via callLiveblocksApi utility.async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getRoom(roomId, { signal: extra.signal }) ); }
- src/server.ts:93-95 (schema)Zod input schema for the tool, requiring a 'roomId' string parameter.{ roomId: z.string(), },
- src/server.ts:90-101 (registration)Registration of the 'get-room' tool on the MCP server instance, specifying name, description, schema, and handler.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:19-28 (helper)Helper function to lazily initialize and return the singleton Liveblocks server client.let client: Liveblocks; function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }
- src/utils.ts:1-37 (helper)Utility function used by all tools to execute a Liveblocks API promise and format the result as MCP CallToolResult content (JSON or error).import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; 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, }, ], }; } }