get-storage-document
Retrieve collaborative document data from a Liveblocks room using its unique room ID to access stored content.
Instructions
Get a Liveblocks storage document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roomId | Yes |
Implementation Reference
- src/server.ts:197-203 (handler)Handler function that retrieves the Liveblocks storage document for the given roomId by calling the Liveblocks API through callLiveblocksApi.async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getStorageDocument(roomId, "json", { signal: extra.signal, }) ); }
- src/server.ts:194-196 (schema)Input schema defining the required 'roomId' parameter as a string.{ roomId: z.string(), },
- src/server.ts:191-204 (registration)Full registration of the 'get-storage-document' tool using McpServer.tool(), including name, description, input schema, and handler.server.tool( "get-storage-document", "Get a Liveblocks storage document", { roomId: z.string(), }, async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getStorageDocument(roomId, "json", { signal: extra.signal, }) ); } );
- src/utils.ts:3-37 (helper)Utility function used by all tools to call Liveblocks APIs and format the response as an MCP CallToolResult, handling success and error cases.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, }, ], }; } }
- src/server.ts:21-28 (helper)Helper function to lazily initialize and return the Liveblocks client instance using the secret key from environment.function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }