Skip to main content
Glama

get_merge_request_details

Retrieve comprehensive information about a specific GitLab merge request, including its status, changes, and discussions, to facilitate review and management.

Instructions

Get detailed information about a specific merge request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
merge_request_iidYesInternal ID of the merge request

Implementation Reference

  • Primary tool handler: fetches MR details, pipeline, changes, reviews in parallel via API helpers, analyzes readiness, calculates stats, and generates comprehensive Markdown report with status icons, action items, and quick action links.
    async def get_merge_request_details(gitlab_url, project_id, access_token, args):
        logging.info(f"get_merge_request_details called with args: {args}")
        mr_iid = args["merge_request_iid"]
    
        tasks = [
            api_get_merge_request_details(gitlab_url, project_id, access_token, mr_iid),
            get_merge_request_pipeline(gitlab_url, project_id, access_token, mr_iid),
            get_merge_request_changes(gitlab_url, project_id, access_token, mr_iid),
            get_merge_request_reviews(gitlab_url, project_id, access_token, mr_iid),
        ]
    
        try:
            details_result, pipeline_result, changes_result, reviews_result = await asyncio.gather(*tasks)
        except Exception as e:
            logging.error(f"Error in parallel API calls: {e}")
            raise Exception(f"Error fetching merge request data: {e}")
    
        mr_status, mr_data, mr_error = details_result
        pipeline_status, pipeline_data, pipeline_error = pipeline_result
        changes_status, changes_data, changes_error = changes_result
    
        if mr_status != 200:
            logging.error(f"Error fetching merge request details: {mr_status} - {mr_error}")
            raise Exception(f"Error fetching merge request details: {mr_status} - {mr_error}")
    
        state_icon = "✅" if mr_data["state"] == "merged" else "🔄" if mr_data["state"] == "opened" else "❌"
        result = f"# {state_icon} Merge Request !{mr_data['iid']}: {mr_data['title']}\n\n"
    
        result += "## 📋 Overview\n"
        result += f"**👤 Author**: {mr_data['author']['name']} (@{mr_data['author']['username']})\n"
        result += f"**📊 Status**: {mr_data['state']} ({get_state_explanation(mr_data['state'])})\n"
        result += f"**🏷️ Priority**: {get_mr_priority(mr_data)}\n"
        result += f"**📅 Created**: {format_date(mr_data['created_at'])}\n"
        result += f"**🔄 Updated**: {format_date(mr_data['updated_at'])}\n"
        result += f"**🌿 Branches**: `{mr_data['source_branch']}` → `{mr_data['target_branch']}`\n"
    
        if pipeline_status == 200 and pipeline_data:
            pipeline_icon = get_pipeline_status_icon(pipeline_data.get("status"))
            result += f"**🔧 Pipeline**: {pipeline_icon} {pipeline_data.get('status', 'unknown')}\n"
            if pipeline_data.get("web_url"):
                result += f"  *[View Pipeline]({pipeline_data['web_url']})*\n"
        elif mr_data.get("pipeline"):
            pipeline_status = mr_data["pipeline"].get("status")
            pipeline_icon = get_pipeline_status_icon(pipeline_status)
            result += f"**🔧 Pipeline**: {pipeline_icon} {pipeline_status or 'unknown'}\n"
    
        if changes_status == 200:
            change_stats = calculate_change_stats(changes_data)
            result += f"**📈 Changes**: {change_stats}\n"
    
        readiness = analyze_mr_readiness(mr_data, pipeline_data)
        result += f"**🚦 Merge Status**: {readiness}\n"
    
        if mr_data.get("labels"):
            labels_str = ", ".join(f"`{label}`" for label in mr_data["labels"])
            result += f"**🏷️ Labels**: {labels_str}\n"
    
        if mr_data.get("draft") or mr_data.get("work_in_progress"):
            result += "**⚠️ Status**: 🚧 Draft/Work in Progress\n"
    
        if mr_data.get("has_conflicts"):
            result += "**⚠️ Warning**: 🔥 Has merge conflicts\n"
    
        result += f"**🔗 URL**: {mr_data['web_url']}\n\n"
    
        if mr_data.get("description"):
            result += "## 📝 Description\n"
            result += f"{mr_data['description']}\n\n"
    
        result += "## 🔧 Technical Details\n"
    
        if mr_data.get("merge_commit_sha"):
            result += f"**📦 Merge Commit**: `{mr_data['merge_commit_sha'][:8]}`\n"
    
        if mr_data.get("squash_commit_sha"):
            result += f"**🔄 Squash Commit**: `{mr_data['squash_commit_sha'][:8]}`\n"
    
        merge_options = []
        if mr_data.get("squash"):
            merge_options.append("🔄 Squash commits")
        if mr_data.get("remove_source_branch"):
            merge_options.append("🗑️ Remove source branch")
        if mr_data.get("force_remove_source_branch"):
            merge_options.append("🗑️ Force remove source branch")
    
        if merge_options:
            result += f"**⚙️ Merge Options**: {', '.join(merge_options)}\n"
    
        if mr_data.get("assignees"):
            assignees = ", ".join(f"@{user['username']}" for user in mr_data["assignees"])
            result += f"**👥 Assignees**: {assignees}\n"
    
        if mr_data.get("reviewers"):
            reviewers = ", ".join(f"@{user['username']}" for user in mr_data["reviewers"])
            result += f"**👀 Reviewers**: {reviewers}\n"
    
        if mr_data.get("milestone"):
            result += f"**🎯 Milestone**: {mr_data['milestone']['title']}\n"
    
        result += "\n"
    
        if reviews_result and "discussions" in reviews_result:
            discussions_status, discussions, _ = reviews_result["discussions"]
            approvals_status, approvals, _ = reviews_result["approvals"]
    
            result += "## 💬 Reviews Summary\n"
    
            if discussions_status == 200 and discussions:
                total_discussions = len(discussions)
                resolved_count = sum(1 for d in discussions if d.get("resolved"))
                unresolved_count = total_discussions - resolved_count
    
                result += (
                    f"**Discussions**: {total_discussions} total, "
                    f"{resolved_count} resolved, {unresolved_count} unresolved\n"
                )
    
                if unresolved_count > 0:
                    result += f"⚠️ **{unresolved_count} unresolved discussion{'s' if unresolved_count > 1 else ''}**\n"
    
            if approvals_status == 200 and approvals:
                approved_by = approvals.get("approved_by", [])
                approvals_left = approvals.get("approvals_left", 0)
    
                if approved_by:
                    result += f"**Approvals**: ✅ {len(approved_by)} approval{'s' if len(approved_by) > 1 else ''}\n"
    
                if approvals_left > 0:
                    result += f"**Needed**: ⏳ {approvals_left} more approval{'s' if approvals_left > 1 else ''}\n"
    
            result += "\n"
    
        result += "## 📊 Action Items\n"
        action_items = []
    
        if mr_data.get("draft") or mr_data.get("work_in_progress"):
            action_items.append("🚧 Remove draft/WIP status")
    
        if mr_data.get("has_conflicts"):
            action_items.append("⚠️ Resolve merge conflicts")
    
        if pipeline_status == 200 and pipeline_data and pipeline_data.get("status") == "failed":
            action_items.append("❌ Fix failing pipeline")
        elif pipeline_status == 200 and pipeline_data and pipeline_data.get("status") == "running":
            action_items.append("🔄 Wait for pipeline completion")
    
        if reviews_result and "discussions" in reviews_result:
            discussions_status, discussions, _ = reviews_result["discussions"]
            approvals_status, approvals, _ = reviews_result["approvals"]
    
            if discussions_status == 200 and discussions:
                unresolved_count = sum(1 for d in discussions if not d.get("resolved"))
                if unresolved_count > 0:
                    plural = "s" if unresolved_count > 1 else ""
                    action_items.append(f"💬 Resolve {unresolved_count} pending discussion{plural}")
    
            if approvals_status == 200 and approvals and approvals.get("approvals_left", 0) > 0:
                approvals_left = approvals["approvals_left"]
                plural = "s" if approvals_left > 1 else ""
                action_items.append(f"👥 Obtain {approvals_left} more approval{plural}")
    
        if mr_data["state"] == "opened" and not action_items:
            action_items.append("✅ Ready to merge!")
    
        if action_items:
            for item in action_items:
                result += f"• {item}\n"
        else:
            result += "✅ No action items identified\n"
    
        result += "\n## 🚀 Quick Actions\n"
        if mr_data["state"] == "opened":
            result += f"• [📝 Edit MR]({mr_data['web_url']}/edit)\n"
            result += f"• [💬 Add Comment]({mr_data['web_url']}#note_form)\n"
            result += f"• [🔄 View Changes]({mr_data['web_url']}/diffs)\n"
            if pipeline_data and pipeline_data.get("web_url"):
                result += f"• [🔧 View Pipeline]({pipeline_data['web_url']})\n"
    
        return [TextContent(type="text", text=result)]
  • Input schema definition for the tool: requires 'merge_request_iid' as a positive integer.
    Tool(
        name="get_merge_request_details",
        description=("Get detailed information about a specific " "merge request"),
        inputSchema={
            "type": "object",
            "properties": {
                "merge_request_iid": {
                    "type": "integer",
                    "minimum": 1,
                    "description": ("Internal ID of the merge request"),
                }
            },
            "required": ["merge_request_iid"],
            "additionalProperties": False,
        },
    ),
  • main.py:308-311 (registration)
    Tool dispatch/registration in MCP server's call_tool handler: routes 'get_merge_request_details' calls to the tool function with config params.
    elif name == "get_merge_request_details":
        return await get_merge_request_details(
            self.config["gitlab_url"], self.config["project_id"], self.config["access_token"], arguments
        )
  • Core API helper: performs HTTP GET to GitLab API endpoint for raw merge request details (imported as api_get_merge_request_details).
    async def get_merge_request_details(gitlab_url, project_id, access_token, mr_iid):
        url = f"{gitlab_url}/api/v4/projects/{project_id}/merge_requests/{mr_iid}"
        headers = _headers(access_token)
        async with aiohttp.ClientSession() as session:
            async with session.get(url, headers=headers) as response:
                return (response.status, await response.json(), await response.text())
  • Package-level import and export (__all__) of the tool handler for use in main.py.
    from .get_merge_request_details import get_merge_request_details
    from .get_merge_request_pipeline import get_merge_request_pipeline
    from .get_merge_request_reviews import get_merge_request_reviews
    from .get_merge_request_test_report import get_merge_request_test_report
    from .get_pipeline_test_summary import get_pipeline_test_summary
    from .list_merge_requests import list_merge_requests
    from .reply_to_review_comment import create_review_comment, reply_to_review_comment, resolve_review_discussion
    
    __all__ = [
        "list_merge_requests",
        "get_merge_request_reviews",
        "get_merge_request_details",
Behavior2/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 states it 'gets' information, implying a read-only operation, but doesn't clarify if it requires authentication, has rate limits, returns paginated data, or what format the output takes. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Get detailed information'), making it easy to parse. Every part of the sentence earns its place by conveying essential information.

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

Completeness2/5

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

Given the complexity (a read operation with no output schema) and lack of annotations, the description is incomplete. It doesn't explain what 'detailed information' entails, potential errors (e.g., invalid ID), or behavioral traits like authentication needs. For a tool with no structured output or annotations, more context is needed to guide the agent effectively.

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 input schema has 100% description coverage, with the parameter 'merge_request_iid' clearly documented as 'Internal ID of the merge request'. The description adds no additional meaning beyond this, as it doesn't explain the parameter's role or constraints. According to the rules, with high schema coverage, the baseline is 3 even without param info in the description.

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 ('Get') and resource ('detailed information about a specific merge request'), making the purpose unambiguous. It distinguishes from siblings like 'list_merge_requests' (which lists multiple) and 'get_merge_request_reviews' (which focuses on reviews). However, it doesn't specify what 'detailed information' includes, leaving some ambiguity compared to a perfect 5.

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., needing a merge request ID), exclusions, or comparisons to siblings like 'get_merge_request_reviews' or 'list_merge_requests'. This lack of context leaves the agent to infer usage based on the name alone.

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/amirsina-mandegari/gitlab-mcp-server'

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