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
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or URL-encoded path | |
| merge_request_iid | Yes | Merge request internal ID | |
| body | Yes | Content of the comment |
Implementation Reference
- src/api/merge-requests.ts:120-135 (handler)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); } - src/schemas.ts:497-503 (schema)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) } ]