Skip to main content
Glama

add_merge_request_comment

Add a comment to a GitLab merge request by specifying the project ID, merge request internal ID, and comment content for collaboration and feedback.

Instructions

Add a comment to a merge request in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or URL-encoded path
merge_request_iidYesMerge request internal ID
bodyYesContent of the comment

Implementation Reference

  • The core handler implementation for add_merge_request_comment.
    export async function addMergeRequestComment(projectId: string, mergeRequestIid: number, body: string): Promise<GitLabComment> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (!mergeRequestIid || mergeRequestIid < 1) {
        throw new Error("Valid merge request IID is required");
      }
      if (!body?.trim()) {
        throw new Error("Comment body is required");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/merge_requests/${mergeRequestIid}/notes`;
    
      const comment = await gitlabPost<GitLabComment>(endpoint, { body });
      return GitLabCommentSchema.parse(comment);
    }
  • Input schema definition for the add_merge_request_comment tool.
    export const AddMergeRequestCommentSchema = z.object({
      project_id: z.string().describe("Project ID or URL-encoded path"),
      merge_request_iid: z.number().describe("Merge request internal ID"),
      body: z.string().describe("Content of the comment")
    });
    
    // Comment response schema
  • src/server.ts:206-210 (registration)
    Tool registration in the MCP server.
        name: "add_merge_request_comment",
        description: "Add a comment to a merge request in a GitLab project",
        inputSchema: zodToJsonSchema(AddMergeRequestCommentSchema)
      }
    ]

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/TheRealChrisThomas/gitlab-mcp-server'

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