Skip to main content
Glama

gitlab_add_merge_request_comment

Add comments to GitLab merge requests for code review feedback and discussions. Supports Markdown formatting, user mentions, and slash commands.

Instructions

Add comment to merge request Returns: Created comment object Use when: Code review feedback, discussions Supports: Markdown, mentions, slash commands

Example: "LGTM! 👍 Just one minor suggestion..."

Related tools:

  • gitlab_get_merge_request_notes: Read existing

  • gitlab_get_merge_request_discussions: Threaded view

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoProject identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted
mr_iidYesMerge request number (IID - Internal ID) Type: integer Format: Project-specific MR number (without !) Required: Yes Examples: - 456 (for MR !456) - 7890 (for MR !7890) How to find: Look at MR URL or title - URL: https://gitlab.com/group/project/-/merge_requests/456 → use 456 - Title: "Add new feature (!456)" → use 456 Note: This is NOT the global MR ID
bodyYesComment content Type: string Required: Yes Format: GitLab Flavored Markdown Features: - Mentions: @username - References: #123, !456 - Code blocks: ```language - Task lists: - [ ] Task - Slash commands: /assign @user Examples: 'LGTM! 👍' 'Found an issue in line 42: ```python # This could be None result = data["key"] ``` Should check if key exists first.'

Implementation Reference

  • The core handler function that implements the tool logic: validates required parameters (mr_iid, body), auto-detects project_id if not provided, and delegates to GitLabClient.add_merge_request_comment method.
    def handle_add_merge_request_comment(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]:
        """Handle adding a comment to a merge request"""
        project_id = require_project_id(client, arguments)
        mr_iid = require_argument(arguments, "mr_iid")
        body = require_argument(arguments, "body")
        
        return client.add_merge_request_comment(project_id, mr_iid, body)
  • MCP tool registration defining the tool name, description, and input schema (JSON Schema) for parameter validation including project_id (optional), mr_iid (int required), body (string required).
    types.Tool(
        name="gitlab_add_merge_request_comment",
        description=desc.DESC_ADD_MR_COMMENT,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "mr_iid": {"type": "integer", "description": desc.DESC_MR_IID},
                "body": {"type": "string", "description": desc.DESC_COMMENT_BODY}
            },
            "required": ["mr_iid", "body"]
        }
    ),
  • Internal TOOL_HANDLERS dictionary registration mapping the tool name constant to its handler function.
    TOOL_ADD_MR_COMMENT: handle_add_merge_request_comment,
  • Constant defining the official tool name string used throughout the codebase for consistency.
    TOOL_ADD_MR_COMMENT = "gitlab_add_merge_request_comment"
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It successfully adds valuable context beyond basic functionality: it specifies the return value ('Returns: Created comment object'), mentions supported features ('Supports: Markdown, mentions, slash commands'), and provides a concrete example. However, it doesn't mention permissions, rate limits, or error conditions that would be helpful for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with clear sections: purpose statement, return value, usage guidance, supported features, example, and related tools. Every sentence earns its place by providing distinct, valuable information without redundancy. The information is front-loaded with the core functionality first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 3 parameters, 100% schema coverage, but no annotations or output schema, the description does a good job of providing context. It covers purpose, usage, return value, and supported features. However, as a write operation, it could benefit from mentioning authentication requirements or potential side effects that aren't covered by the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning all parameters are well-documented in the schema itself. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions. This meets the baseline expectation when schema coverage is high, but doesn't provide additional semantic context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description starts with a clear verb+resource statement 'Add comment to merge request' that precisely states what the tool does. It distinguishes this tool from sibling tools like gitlab_get_merge_request_notes (read existing) and gitlab_get_merge_request_discussions (threaded view), making the purpose specific and differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides usage guidance with 'Use when: Code review feedback, discussions' and lists related tools with their specific purposes ('Read existing', 'Threaded view'). This gives clear context about when to use this tool versus alternatives, including both positive guidance (when to use) and implicit exclusions (when not to use).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Vijay-Duke/mcp-gitlab'

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