Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

delete-thread

Remove a specific thread from a Liveblocks room to manage collaborative content and maintain organized workspaces.

Instructions

Delete a Liveblocks thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roomIdYes
threadIdYes

Implementation Reference

  • The handler function for the 'delete-thread' tool. It destructures roomId and threadId from input, then calls the Liveblocks SDK's deleteThread method wrapped in callLiveblocksApi to handle the API response formatting.
    async ({ roomId, threadId }, extra) => {
      return await callLiveblocksApi(
        getLiveblocks().deleteThread(
          { roomId, threadId },
          { signal: extra.signal }
        )
      );
    }
  • Zod input schema for the 'delete-thread' tool, requiring roomId and threadId as strings.
    {
      roomId: z.string(),
      threadId: z.string(),
    },
  • src/server.ts:378-393 (registration)
    Registration of the 'delete-thread' tool on the McpServer instance, including name, description, schema, and handler.
    server.tool(
      "delete-thread",
      "Delete a Liveblocks thread",
      {
        roomId: z.string(),
        threadId: z.string(),
      },
      async ({ roomId, threadId }, extra) => {
        return await callLiveblocksApi(
          getLiveblocks().deleteThread(
            { roomId, threadId },
            { signal: extra.signal }
          )
        );
      }
    );
  • Helper function that lazily initializes and returns the Liveblocks Node.js SDK client used by the handler.
    function getLiveblocks() {
      if (!client) {
        client = new Liveblocks({
          secret: process.env.LIVEBLOCKS_SECRET_KEY as string,
        });
      }
      return client;
    }
  • Helper function that wraps Liveblocks API promises, formatting successful responses as MCP CallToolResult with JSON and handling 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,
            },
          ],
        };
      }
    }

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