delete_merge_request_discussion
Remove a specific discussion thread from a GitLab merge request to clean up resolved comments or outdated feedback.
Instructions
Delete a merge request discussion.
Args:
project_id: The GitLab project ID or URL-encoded path
merge_request_iid: The merge request IID (project-specific ID)
discussion_id: The ID of the discussion to delete
Returns:
Dict containing the status of the deletion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| merge_request_iid | Yes | ||
| discussion_id | Yes |
Implementation Reference
- server.py:453-477 (handler)The main handler function for the 'delete_merge_request_discussion' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function deletes a merge request discussion by deleting its first note using the GitLab API.@mcp.tool() def delete_merge_request_discussion(ctx: Context, project_id: str, merge_request_iid: str, discussion_id: str) -> Dict[str, Any]: """ Delete a merge request discussion. Args: project_id: The GitLab project ID or URL-encoded path merge_request_iid: The merge request IID (project-specific ID) discussion_id: The ID of the discussion to delete Returns: Dict containing the status of the deletion """ gl = ctx.request_context.lifespan_context project = gl.projects.get(project_id) mr = project.mergerequests.get(merge_request_iid) discussion = mr.discussions.get(discussion_id) # To delete a discussion, we delete its first note. # If the discussion only has one note, the discussion will be deleted. if discussion.notes: first_note_id = discussion.notes[0]['id'] discussion.notes.delete(first_note_id) return {"status": "success", "deleted_note_id": first_note_id} return {"status": "failed", "message": "Discussion has no notes to delete."}