Skip to main content
Glama
liveblocks
by liveblocks

create-thread

Initiate a thread within a Liveblocks room by specifying a roomId and including a structured comment with userId, enabling collaborative discussions.

Instructions

Create a Liveblocks thread. Always ask for a userId.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYes
roomIdYes

Implementation Reference

  • src/server.ts:259-280 (registration)
    Registration of the 'create-thread' MCP tool, including inline schema definition and handler function that delegates to Liveblocks SDK's createThread method.
    server.tool( "create-thread", `Create a Liveblocks thread. Always ask for a userId.`, { roomId: z.string(), data: z.object({ comment: z.object({ body: CommentBody, userId: z.string(), createdAt: z.date().optional(), }), metadata: z .record(z.string(), z.union([z.string(), z.boolean(), z.number()])) .optional(), }), }, async ({ roomId, data }, extra) => { return await callLiveblocksApi( getLiveblocks().createThread({ roomId, data }, { signal: extra.signal }) ); } );
  • Zod schema definition for CommentBody, referenced in the create-thread tool's input schema.
    export const CommentBody = z.object({ version: z.literal(1), content: z.array(CommentBodyParagraph), });
  • Helper utility function callLiveblocksApi used by the create-thread handler to execute the Liveblocks API call and format the MCP tool response.
    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, }, ], }; } }
  • Helper function getLiveblocks() used in create-thread handler to initialize and return the Liveblocks client instance.
    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