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

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
        )

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