Skip to main content
Glama

get_merge_request_commits

Retrieve all commits included in a GitLab merge request to review code changes and track development history for specific projects and MRs.

Instructions

取得 Merge Request 包含的 commits

Args: project_id: 專案 ID 或路徑 mr_iid: MR 的 IID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
mr_iidYes

Implementation Reference

  • The MCP tool handler for 'get_merge_request_commits', which calls the GitLab client's method.
    @mcp.tool()
    def get_merge_request_commits(project_id: int | str, mr_iid: int) -> str:
        """取得 Merge Request 包含的 commits
    
        Args:
            project_id: 專案 ID 或路徑
            mr_iid: MR 的 IID
        """
        try:
            client = get_client()
            commits = client.get_merge_request_commits(project_id, mr_iid)
    
            if not commits:
                return "此 MR 沒有 commits"
    
            lines = [f"MR !{mr_iid} 包含 {len(commits)} 個 commits:\n"]
            for c in commits:
                lines.append(
                    f"- {c.get('short_id', 'N/A')} {c.get('title', 'N/A')}"
                    f"\n  作者: {c.get('author_name', 'N/A')} | {c.get('authored_date', 'N/A')}"
                )
            return "\n".join(lines)
        except GitLabAPIError as e:
            return f"取得 MR commits 失敗: {str(e)}"
  • The actual implementation of get_merge_request_commits which communicates with the GitLab API.
    def get_merge_request_commits(
        self, project_id: int | str, mr_iid: int
    ) -> list[dict]:
        """GET /projects/:id/merge_requests/:iid/commits"""
        pid = self._resolve_project_id(project_id)
        return self._get_json(f"/projects/{pid}/merge_requests/{mr_iid}/commits")

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