Skip to main content
Glama
zalab-inc
by zalab-inc

create_comment

Add comments to Linear issues to provide updates, share information, or collaborate with team members on project tasks.

Instructions

A tool that creates a comment on an issue in Linear

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commentYesThe comment to send to the issue
issueIdYesThe ID of the issue to send a comment to

Implementation Reference

  • The async handler function that implements the create_comment tool logic: validates inputs, calls linearClient.createComment, handles various response formats from Linear SDK, extracts comment ID, and returns formatted success/error messages.
    handler: async (args: z.infer<typeof createCommentSchema>) => {
      try {
        // Validate input
        if (!args.issueId || args.issueId.trim() === "") {
          return {
            content: [{
              type: "text",
              text: "Error: Issue ID cannot be empty",
            }],
          };
        }
        
        if (!args.comment || args.comment.trim() === "") {
          return {
            content: [{
              type: "text",
              text: "Error: Comment content cannot be empty",
            }],
          };
        }
        
        // Create the comment
        const createCommentResponse = await linearClient.createComment({
          body: args.comment,
          issueId: args.issueId,
        });
        
        if (!createCommentResponse) {
          return {
            content: [{
              type: "text",
              text: "Failed to create comment. Please check the issue ID and try again.",
            }],
          };
        }
        
        // Mendapatkan ID komentar dari respons
        // Linear SDK mengembalikan hasil dalam pola success dan entity
        if (createCommentResponse.success) {
          // Mengakses komentar dan mendapatkan ID dengan tipe data yang benar
          const comment = await createCommentResponse.comment;
          if (comment && comment.id) {
            return {
              content: [{
                type: "text",
                text: `Status: Success\nMessage: Linear comment created\nComment ID: ${comment.id}`,
              }],
            };
          }
        }
        
        // Extract data from response to check for success
        const commentResponse = createCommentResponse as unknown as LinearCommentResponse;
        
        // If the response indicates failure, return an error
        if (commentResponse.success === false) {
          return {
            content: [{
              type: "text",
              text: "Failed to create comment. Please check the issue ID and try again.",
            }],
          };
        }
        
        // Extract comment data from the correct property
        const commentData: CommentResponseData = commentResponse.comment || createCommentResponse as unknown as CommentResponseData;
        
        // Langsung cek hasil respons yang telah diparsing
        const commentId = commentData?.id || (createCommentResponse as unknown as { id?: string })?.id;
        if (commentId) {
          return {
            content: [{
              type: "text",
              text: `Status: Success\nMessage: Linear comment created\nComment ID: ${commentId}`,
            }],
          };
        }
        
        if (!commentData) {
          // Tampilkan pesan sukses meski data tidak lengkap
          return {
            content: [{
              type: "text",
              text: "Status: Success\nMessage: Linear comment created",
            }],
          };
        }
        
        if (!commentData.id) {
          // Data komentar ada tapi tidak ada ID
          return {
            content: [{
              type: "text",
              text: "Status: Success\nMessage: Linear comment created (ID not available)",
            }],
          };
        }
        
        // Kasus sukses dengan ID tersedia
        return {
          content: [{
            type: "text",
            text: `Status: Success\nMessage: Linear comment created\nComment ID: ${commentData.id}`,
          }],
        };
      } catch (error) {
        // Handle errors gracefully
        const errorMessage = error instanceof Error ? error.message : "Unknown error";
        return {
          content: [{
            type: "text",
            text: `An error occurred while creating the comment:\n${errorMessage}`,
          }],
        };
      }
    }
  • Zod schema defining input parameters for the create_comment tool: issueId (string) and comment (string).
    const createCommentSchema = z.object({
      issueId: z.string().describe("The ID of the issue to send a comment to"),
      comment: z.string().describe("The comment to send to the issue"),
    });
  • src/index.ts:31-41 (registration)
    Registers the LinearCreateCommentTool (which has name: "create_comment") on the MCP server using registerTool.
    registerTool(server, [
      LinearSearchIssuesTool,
      LinearGetProfileTool,
      LinearCreateIssueTool,
      LinearCreateCommentTool,
      LinearUpdateCommentTool,
      LinearGetIssueTool,
      LinearGetTeamIdTool,
      LinearUpdateIssueTool,
      LinearGetCommentTool,
    ]);
  • Re-exports LinearCreateCommentTool for use in index.ts registration.
    export { 
      LinearGetProfileTool, 
      LinearSearchIssuesTool,
      LinearCreateIssueTool,
      LinearUpdateIssueTool,
      LinearCreateCommentTool,
  • Full tool definition including name 'create_comment', schema, and handler implementation using createSafeTool.
    export const LinearCreateCommentTool = createSafeTool({
      name: "create_comment",
      description: "A tool that creates a comment on an issue in Linear",
      schema: createCommentSchema.shape,
      handler: async (args: z.infer<typeof createCommentSchema>) => {
        try {
          // Validate input
          if (!args.issueId || args.issueId.trim() === "") {
            return {
              content: [{
                type: "text",
                text: "Error: Issue ID cannot be empty",
              }],
            };
          }
          
          if (!args.comment || args.comment.trim() === "") {
            return {
              content: [{
                type: "text",
                text: "Error: Comment content cannot be empty",
              }],
            };
          }
          
          // Create the comment
          const createCommentResponse = await linearClient.createComment({
            body: args.comment,
            issueId: args.issueId,
          });
          
          if (!createCommentResponse) {
            return {
              content: [{
                type: "text",
                text: "Failed to create comment. Please check the issue ID and try again.",
              }],
            };
          }
          
          // Mendapatkan ID komentar dari respons
          // Linear SDK mengembalikan hasil dalam pola success dan entity
          if (createCommentResponse.success) {
            // Mengakses komentar dan mendapatkan ID dengan tipe data yang benar
            const comment = await createCommentResponse.comment;
            if (comment && comment.id) {
              return {
                content: [{
                  type: "text",
                  text: `Status: Success\nMessage: Linear comment created\nComment ID: ${comment.id}`,
                }],
              };
            }
          }
          
          // Extract data from response to check for success
          const commentResponse = createCommentResponse as unknown as LinearCommentResponse;
          
          // If the response indicates failure, return an error
          if (commentResponse.success === false) {
            return {
              content: [{
                type: "text",
                text: "Failed to create comment. Please check the issue ID and try again.",
              }],
            };
          }
          
          // Extract comment data from the correct property
          const commentData: CommentResponseData = commentResponse.comment || createCommentResponse as unknown as CommentResponseData;
          
          // Langsung cek hasil respons yang telah diparsing
          const commentId = commentData?.id || (createCommentResponse as unknown as { id?: string })?.id;
          if (commentId) {
            return {
              content: [{
                type: "text",
                text: `Status: Success\nMessage: Linear comment created\nComment ID: ${commentId}`,
              }],
            };
          }
          
          if (!commentData) {
            // Tampilkan pesan sukses meski data tidak lengkap
            return {
              content: [{
                type: "text",
                text: "Status: Success\nMessage: Linear comment created",
              }],
            };
          }
          
          if (!commentData.id) {
            // Data komentar ada tapi tidak ada ID
            return {
              content: [{
                type: "text",
                text: "Status: Success\nMessage: Linear comment created (ID not available)",
              }],
            };
          }
          
          // Kasus sukses dengan ID tersedia
          return {
            content: [{
              type: "text",
              text: `Status: Success\nMessage: Linear comment created\nComment ID: ${commentData.id}`,
            }],
          };
        } catch (error) {
          // Handle errors gracefully
          const errorMessage = error instanceof Error ? error.message : "Unknown error";
          return {
            content: [{
              type: "text",
              text: `An error occurred while creating the comment:\n${errorMessage}`,
            }],
          };
        }
      }
    }); 
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'creates a comment', implying a write operation, but doesn't address permissions, side effects, rate limits, or response format. This is a significant gap for a mutation tool, making it inadequate for safe usage.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly, with no wasted content.

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 tool's complexity as a write operation with no annotations and no output schema, the description is incomplete. It lacks behavioral details (e.g., permissions, response), usage context, and output information, failing to provide enough guidance for reliable agent invocation.

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?

The schema description coverage is 100%, with clear descriptions for both parameters ('comment' and 'issueId'). The description doesn't add any semantic details beyond what the schema provides, such as format constraints or examples, so it meets the baseline of 3 without compensating or enhancing.

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 action ('creates a comment') and target resource ('on an issue in Linear'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'update_comment' or 'get_comment', missing an opportunity for sibling differentiation that would warrant a score of 5.

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 no guidance on when to use this tool versus alternatives. There's no mention of prerequisites (e.g., needing an existing issue), exclusions, or comparisons to siblings like 'update_comment' for editing or 'get_comment' for reading, leaving the agent without usage context.

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/zalab-inc/mcp-linear-app'

If you have feedback or need assistance with the MCP directory API, please join our Discord server