Skip to main content
Glama

merge_merge_request

Merge a GitLab merge request with options for custom commit messages and branch cleanup. Use this tool to finalize code changes by combining source and target branches in GitLab projects.

Instructions

合併 Merge Request

Args: project_id: 專案 ID 或路徑 mr_iid: MR 的 IID merge_commit_message: 自訂合併 commit 訊息 should_remove_source_branch: 合併後是否刪除來源分支

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
mr_iidYes
merge_commit_messageNo
should_remove_source_branchNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool registration and handler implementation for merge_merge_request.
    @mcp.tool()
    def merge_merge_request(project_id: int | str, mr_iid: int,
                            merge_commit_message: str = None,
                            should_remove_source_branch: bool = False) -> str:
        """合併 Merge Request
    
        Args:
            project_id: 專案 ID 或路徑
            mr_iid: MR 的 IID
            merge_commit_message: 自訂合併 commit 訊息
            should_remove_source_branch: 合併後是否刪除來源分支
        """
        try:
            client = get_client()
            mr = client.merge_merge_request(
                project_id, mr_iid,
                merge_commit_message=merge_commit_message,
                should_remove_source_branch=should_remove_source_branch
            )
            result = f"✓ MR !{mr['iid']} 已合併 — {mr['title']}"
            if should_remove_source_branch:
                result += f"\n來源分支 {mr.get('source_branch', '')} 已標記刪除"
            return result
        except GitLabAPIError as e:
            return f"合併 MR 失敗: {str(e)}"
  • GitLab client method to perform the API request to merge a merge request.
    def merge_merge_request(
        self,
        project_id: int | str,
        mr_iid: int,
        merge_commit_message: str = None,
        should_remove_source_branch: bool = False,
    ) -> dict:
        """PUT /projects/:id/merge_requests/:iid/merge"""
        pid = self._resolve_project_id(project_id)
        data = {}
        if merge_commit_message:
            data["merge_commit_message"] = merge_commit_message
        if should_remove_source_branch:
            data["should_remove_source_branch"] = True
        return self._put_json(
            f"/projects/{pid}/merge_requests/{mr_iid}/merge", data=data
        )
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the action ('合併 Merge Request') without explaining critical behaviors: whether this is a destructive write operation, what permissions are required, how conflicts are handled, or what happens on success/failure. For a mutation tool with zero annotation coverage, this leaves the agent guessing about important operational aspects.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the core purpose first. The Args section is organized efficiently with one line per parameter. There's no wasted text, though the structure could be slightly improved by integrating parameter explanations more naturally into the description rather than as a separate section.

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

Completeness3/5

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

Given this is a mutation tool with no annotations, 4 parameters (2 required), and an output schema exists, the description is moderately complete. It covers the basic action and parameters but lacks crucial context about behavioral traits, error conditions, and usage prerequisites. The existence of an output schema means return values are documented elsewhere, but the description should still address mutation consequences and operational constraints.

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?

Schema description coverage is 0%, so the description must compensate. It provides brief explanations for all 4 parameters in the Args section, adding meaning beyond the bare schema. However, the explanations are minimal ('專案 ID 或路徑' = 'project ID or path') and don't clarify format expectations, constraints, or practical usage examples. The description adds some value but doesn't fully bridge the schema coverage gap.

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

Purpose4/5

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

The description clearly states the verb ('合併' meaning 'merge') and resource ('Merge Request'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'create_merge_request' or 'update_merge_request' by specifying the merge action. However, it doesn't explicitly differentiate from other merge-related operations like 'approve_merge_request' beyond the core action.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., MR must be approved or pipeline must pass), conditions for successful merging, or what happens in conflict scenarios. Given siblings like 'approve_merge_request' and 'update_merge_request', the lack of differentiation is a significant gap.

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

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