edit-comment
Modify an existing comment within a Liveblocks room by specifying the room, thread, and comment IDs. Update the comment body, user ID, and edit timestamp to reflect changes.
Instructions
Edit a Liveblocks comment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commentId | Yes | ||
| data | Yes | ||
| roomId | Yes | ||
| threadId | Yes |
Implementation Reference
- src/server.ts:505-512 (handler)The handler function for the 'edit-comment' tool. It calls the Liveblocks 'editComment' API method via 'callLiveblocksApi', passing roomId, threadId, commentId, and update data.async ({ roomId, threadId, commentId, data }, extra) => { return await callLiveblocksApi( getLiveblocks().editComment( { roomId, threadId, commentId, data }, { signal: extra.signal } ) ); }
- src/server.ts:495-504 (schema)Input schema validation for the 'edit-comment' tool using Zod. Includes roomId, threadId, commentId, and data object with body (CommentBody), userId, and optional editedAt.{ roomId: z.string(), threadId: z.string(), commentId: z.string(), data: z.object({ body: CommentBody, userId: z.string(), editedAt: z.date().optional(), }), },
- src/server.ts:492-513 (registration)Registration of the 'edit-comment' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.server.tool( "edit-comment", `Edit a Liveblocks comment`, { roomId: z.string(), threadId: z.string(), commentId: z.string(), data: z.object({ body: CommentBody, userId: z.string(), editedAt: z.date().optional(), }), }, async ({ roomId, threadId, commentId, data }, extra) => { return await callLiveblocksApi( getLiveblocks().editComment( { roomId, threadId, commentId, data }, { signal: extra.signal } ) ); } );
- src/zod.ts:33-36 (schema)Zod schema for CommentBody, which defines the rich text structure (versioned paragraphs with inline text, mentions, links) used in the 'edit-comment' tool input.export const CommentBody = z.object({ version: z.literal(1), content: z.array(CommentBodyParagraph), });
- src/utils.ts:3-37 (helper)Helper utility 'callLiveblocksApi' used by the handler to execute Liveblocks API calls and format the response as MCP tool result (JSON stringified content or error).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, }, ], }; } }