Skip to main content
Glama
ffpy

GitLab MCP Code Review

by ffpy

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

Implementation Reference

  • 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()

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