Skip to main content
Glama
ffpy

GitLab MCP Code Review

by ffpy

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
NameRequiredDescriptionDefault
project_idYes
merge_request_iidYes
discussion_idYes

Implementation Reference

  • 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."}

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/ffpy/gitlab-mcp-code-review'

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