Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

edit-thread-metadata

Modify or remove metadata for threads in Liveblocks collaborative applications to organize and manage conversation data.

Instructions

Edit a Liveblocks thread's metadata. null can be used to remove a key.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roomIdYes
threadIdYes
dataYes

Implementation Reference

  • src/server.ts:313-336 (registration)
    Registration of the 'edit-thread-metadata' MCP tool, including inline input schema (Zod) and handler function that proxies to Liveblocks API via callLiveblocksApi.
    server.tool(
      "edit-thread-metadata",
      `Edit a Liveblocks thread's metadata. \`null\` can be used to remove a key.`,
      {
        roomId: z.string(),
        threadId: z.string(),
        data: z.object({
          metadata: z.record(
            z.string(),
            z.union([z.string(), z.boolean(), z.number(), z.null()])
          ),
          userId: z.string(),
          updatedAt: z.date().optional(),
        }),
      },
      async ({ roomId, threadId, data }, extra) => {
        return await callLiveblocksApi(
          getLiveblocks().editThreadMetadata(
            { roomId, threadId, data },
            { signal: extra.signal }
          )
        );
      }
    );
  • The handler function executes the tool logic by calling the Liveblocks editThreadMetadata API and formatting the response.
    async ({ roomId, threadId, data }, extra) => {
      return await callLiveblocksApi(
        getLiveblocks().editThreadMetadata(
          { roomId, threadId, data },
          { signal: extra.signal }
        )
      );
    }
  • Inline Zod schema defining the input parameters for the edit-thread-metadata tool.
      roomId: z.string(),
      threadId: z.string(),
      data: z.object({
        metadata: z.record(
          z.string(),
          z.union([z.string(), z.boolean(), z.number(), z.null()])
        ),
        userId: z.string(),
        updatedAt: z.date().optional(),
      }),
    },
  • Shared helper function used by the handler to execute Liveblocks API calls and format MCP tool responses.
    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