add_issue_comment
Add comments to GitLab issues to provide updates, ask questions, or document progress within project workflows.
Instructions
Add a comment to an issue in a GitLab project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or URL-encoded path | |
| issue_iid | Yes | Issue internal ID | |
| body | Yes | Content of the comment |
Implementation Reference
- src/api/issues.ts:149-164 (handler)Implementation of addIssueComment which makes a POST request to the GitLab API to add a comment to an issue.
export async function addIssueComment(projectId: string, issueIid: number, body: string): Promise<GitLabComment> { if (!projectId?.trim()) { throw new Error("Project ID is required"); } if (!issueIid || issueIid < 1) { throw new Error("Valid issue IID is required"); } if (!body?.trim()) { throw new Error("Comment body is required"); } const endpoint = `/projects/${encodeProjectId(projectId)}/issues/${issueIid}/notes`; const comment = await gitlabPost<GitLabComment>(endpoint, { body }); return GitLabCommentSchema.parse(comment); } - src/schemas.ts:448-452 (schema)Zod schema for validating add_issue_comment arguments.
export const AddIssueCommentSchema = z.object({ project_id: z.string().describe("Project ID or URL-encoded path"), issue_iid: z.number().describe("Issue internal ID"), body: z.string().describe("Content of the comment") }); - src/server.ts:412-416 (registration)Registration/Handler block in the MCP server switch statement.
case "add_issue_comment": { const args = AddIssueCommentSchema.parse(request.params.arguments); const comment = await api.addIssueComment(args.project_id, args.issue_iid, args.body); return { content: [{ type: "text", text: JSON.stringify(comment, null, 2) }] }; }