Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

create-comment

Add comments to collaborative documents in Liveblocks rooms. Specify room, thread, user ID, and comment content to enable real-time discussion.

Instructions

Create a Liveblocks comment. Always ask for a userId.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roomIdYes
threadIdYes
dataYes

Implementation Reference

  • src/server.ts:452-472 (registration)
    Full registration of the 'create-comment' MCP tool, including inline schema definition and handler function that delegates to Liveblocks client.
    server.tool(
      "create-comment",
      `Create a Liveblocks comment. Always ask for a userId.`,
      {
        roomId: z.string(),
        threadId: z.string(),
        data: z.object({
          body: CommentBody,
          userId: z.string(),
          createdAt: z.date().optional(),
        }),
      },
      async ({ roomId, threadId, data }, extra) => {
        return await callLiveblocksApi(
          getLiveblocks().createComment(
            { roomId, threadId, data },
            { signal: extra.signal }
          )
        );
      }
    );
  • Zod schema definition for CommentBody, used in the input parameters for creating a comment (body field). Supports rich text with text, mentions, links, formatting.
    const CommentBodyText = z.object({
      text: z.string(),
      bold: z.boolean().optional(),
      italic: z.boolean().optional(),
      strikethrough: z.boolean().optional(),
      code: z.boolean().optional(),
    });
    
    const CommentBodyMention = z.object({
      type: z.literal("mention"),
      id: z.string(),
    });
    
    const CommentBodyLink = z.object({
      type: z.literal("link"),
      url: z.string(),
      text: z.string().optional(),
    });
    
    const CommentBodyInlineElement = z.union([
      CommentBodyText,
      CommentBodyMention,
      CommentBodyLink,
    ]);
    
    const CommentBodyParagraph = z.object({
      type: z.literal("paragraph"),
      children: z.array(CommentBodyInlineElement),
    });
    
    export const CommentBody = z.object({
      version: z.literal(1),
      content: z.array(CommentBodyParagraph),
    });
  • Utility function used by the handler to call Liveblocks API promises and format the response as MCP CallToolResult, including JSON stringification of data or error handling.
    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 to lazily initialize and return the Liveblocks client instance used in all tool handlers, including create-comment.
    function getLiveblocks() {
      if (!client) {
        client = new Liveblocks({
          secret: process.env.LIVEBLOCKS_SECRET_KEY as string,
        });
      }
      return client;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'Always ask for a userId,' implying a behavioral constraint (user input requirement), but lacks details on permissions, side effects (e.g., if it triggers notifications), rate limits, or error handling. For a creation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with two short sentences, front-loading the core action and a specific instruction. Every word serves a purpose, with no redundant or verbose language, making it efficient for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (3 parameters with nested objects, 0% schema coverage, no annotations, no output schema), the description is inadequate. It doesn't cover parameter meanings beyond a hint for 'userId,' behavioral aspects like mutations or returns, or how it fits with siblings. For a creation tool in this rich context, more detail is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds minimal value by hinting at 'userId' as a required parameter but doesn't explain 'roomId,' 'threadId,' or the complex 'data' object structure. Baseline is 3 since the description partially addresses one parameter but leaves others undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('a Liveblocks comment'), making the purpose evident. It distinguishes from siblings like 'edit-comment' or 'delete-comment' by specifying creation. However, it doesn't explicitly differentiate from 'add-comment-reaction' or other comment-related tools beyond the basic action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance with 'Always ask for a userId,' which hints at a required parameter but doesn't explain when to use this tool versus alternatives. No context is given about prerequisites (e.g., needing an existing room/thread), exclusions, or comparisons to sibling tools like 'create-thread' or 'edit-comment'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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