Skip to main content
Glama

get_merge_request

Retrieve detailed information about a specific merge request from a GitLab project using project ID and merge request IID.

Instructions

取得 Merge Request 詳細資訊

Args: project_id: 專案 ID 或路徑 mr_iid: MR 的 IID(專案內編號)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
mr_iidYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler for the "get_merge_request" MCP tool, which orchestrates the call to the GitLab client and formats the result.
    @mcp.tool()
    def get_merge_request(project_id: int | str, mr_iid: int) -> str:
        """取得 Merge Request 詳細資訊
    
        Args:
            project_id: 專案 ID 或路徑
            mr_iid: MR 的 IID(專案內編號)
        """
        try:
            client = get_client()
            mr = client.get_merge_request(project_id, mr_iid)
    
            status_emoji = {"opened": "🟢", "closed": "🔴", "merged": "🟣"}
            emoji = status_emoji.get(mr.get("state", ""), "⚪")
    
            assignee = mr.get("assignee")
            assignee_str = f"{assignee['name']} (@{assignee['username']})" if assignee else "未指派"
    
            reviewers = mr.get("reviewers", [])
            reviewer_str = ", ".join(f"{r['name']}" for r in reviewers) if reviewers else "無"
    
            pipeline = mr.get("pipeline")
            pipeline_str = f"#{pipeline['id']} ({pipeline['status']})" if pipeline else "無"
    
            result = f"""{emoji} Merge Request !{mr['iid']}
    標題: {mr['title']}
    狀態: {mr.get('state', 'N/A')}
    來源分支: {mr.get('source_branch', 'N/A')} → 目標分支: {mr.get('target_branch', 'N/A')}
    作者: {mr.get('author', {}).get('name', 'N/A')}
    指派: {assignee_str}
    審核者: {reviewer_str}
    Pipeline: {pipeline_str}
    建立時間: {mr.get('created_at', 'N/A')}
    更新時間: {mr.get('updated_at', 'N/A')}
    網址: {mr.get('web_url', '')}"""
    
            if mr.get('merged_at'):
                result += f"\n合併時間: {mr['merged_at']}"
                merged_by = mr.get('merged_by')
                if merged_by:
                    result += f"\n合併者: {merged_by.get('name', 'N/A')}"
    
            if mr.get('description'):
                result += f"\n\n--- 描述 ---\n{mr['description']}"
    
            return result
        except GitLabAPIError as e:
  • The low-level client method that performs the API request to fetch merge request details from GitLab.
    def get_merge_request(self, project_id: int | str, mr_iid: int) -> dict:
        """GET /projects/:id/merge_requests/:iid"""
        pid = self._resolve_project_id(project_id)
        return self._get_json(f"/projects/{pid}/merge_requests/{mr_iid}")
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it retrieves detailed information but doesn't disclose behavioral traits like whether it's read-only (implied but not stated), authentication requirements, rate limits, error conditions, or what 'detailed information' includes. The description is minimal and lacks necessary context for safe invocation.

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

Conciseness3/5

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

The description is brief but not optimally structured. It starts with the purpose statement, then has an 'Args:' section that somewhat duplicates the schema. The two-sentence format is concise, but the 'Args' section adds minimal value beyond the schema and could be integrated more naturally. It's front-loaded with the main purpose.

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 the tool has an output schema (which handles return values), no annotations, and simple parameters, the description is moderately complete. It states the purpose and parameter meanings but lacks behavioral context, usage guidelines, and error handling. For a read operation with output schema, this is minimally adequate but leaves gaps in operational understanding.

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 schema provides no parameter descriptions. The description adds basic semantics: project_id is '專案 ID 或路徑' (project ID or path) and mr_iid is 'MR 的 IID(專案內編號)' (MR's IID, project-internal number). This clarifies what the parameters represent but doesn't provide format examples, validation rules, or usage context. Baseline is 3 since it adds some value but doesn't fully compensate for the 0% schema coverage.

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 action ('取得' meaning 'get' or 'retrieve') and the resource ('Merge Request 詳細資訊' meaning 'Merge Request detailed information'). It distinguishes from siblings like list_merge_requests (which lists multiple) and get_merge_request_changes/commits (which get specific aspects). However, it doesn't explicitly differentiate from all siblings in the description text.

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 when to use get_merge_request versus list_merge_requests (for single vs multiple), or versus get_merge_request_changes/commits (for full details vs specific aspects). No prerequisites or contextual usage hints are provided.

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