add_merge_request_comment
Add a comment to a GitLab merge request to provide feedback, ask questions, or share information during code review.
Instructions
Add a general comment to a merge request.
Args:
project_id: The GitLab project ID or URL-encoded path
merge_request_iid: The merge request IID (project-specific ID)
body: The comment text
Returns:
Dict containing the created comment information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| merge_request_iid | Yes | ||
| body | Yes |
Implementation Reference
- server.py:345-363 (handler)The handler function implementing the 'add_merge_request_comment' tool. It uses the GitLab client to retrieve the project and merge request, then creates a note (comment) on the merge request and returns its data. The @mcp.tool() decorator handles registration and schema inference from the signature and docstring.@mcp.tool() def add_merge_request_comment(ctx: Context, project_id: str, merge_request_iid: str, body: str) -> Dict[str, Any]: """ Add a general comment to a merge request. Args: project_id: The GitLab project ID or URL-encoded path merge_request_iid: The merge request IID (project-specific ID) body: The comment text Returns: Dict containing the created comment information """ gl = ctx.request_context.lifespan_context project = gl.projects.get(project_id) mr = project.mergerequests.get(merge_request_iid) note = mr.notes.create({'body': body}) return note.asdict()