Skip to main content
Glama

list_merge_requests

Retrieve merge requests from a GitLab project with filtering options for state, pagination, and project identification.

Instructions

列出專案的 Merge Requests

Args: project_id: 專案 ID 或路徑 state: 狀態篩選(opened, closed, merged, all) page: 頁碼 per_page: 每頁筆數

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
stateNo
pageNo
per_pageNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The underlying GitLab API client method that performs the network request to fetch merge requests.
    def list_merge_requests(
        self,
        project_id: int | str,
        state: str = None,
        page: int = 1,
        per_page: int = 20,
    ) -> list[dict]:
        """GET /projects/:id/merge_requests"""
        pid = self._resolve_project_id(project_id)
        params = {"page": page, "per_page": per_page}
        if state:
            params["state"] = state
        return self._get_json(f"/projects/{pid}/merge_requests", params=params)
  • The MCP tool handler function which validates input, calls the GitLab client, and formats the response.
    @mcp.tool()
    def list_merge_requests(project_id: int | str, state: str = None,
                            page: int = 1, per_page: int = 20) -> str:
        """列出專案的 Merge Requests
    
        Args:
            project_id: 專案 ID 或路徑
            state: 狀態篩選(opened, closed, merged, all)
            page: 頁碼
            per_page: 每頁筆數
        """
        try:
            if state:
                v = GitLabValidator.validate_mr_state(state)
                if not v.is_valid:
                    return "\n".join(v.errors)
    
            client = get_client()
            mrs = client.list_merge_requests(project_id, state=state, page=page, per_page=per_page)
            if not mrs:
                return "找不到符合條件的 Merge Request"
    
            status_emoji = {"opened": "🟢", "closed": "🔴", "merged": "🟣"}
            lines = [f"找到 {len(mrs)} 個 Merge Request:\n"]
            for mr in mrs:
                emoji = status_emoji.get(mr.get("state", ""), "⚪")
                lines.append(
                    f"{emoji} !{mr['iid']} [{mr.get('state', '')}] {mr['title']}"
                    f"\n  {mr.get('source_branch', '')} → {mr.get('target_branch', '')}"
                    f"\n  作者: {mr.get('author', {}).get('name', 'N/A')} | {mr.get('web_url', '')}\n"
                )
            return "\n".join(lines)
        except GitLabAPIError as e:
            return f"列出 MR 失敗: {str(e)}"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions pagination parameters ('page', 'per_page'), which hints at paginated results, but doesn't describe the return format, rate limits, authentication needs, or whether it's read-only. For a list tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 with a clear purpose statement followed by parameter explanations. It uses bullet points for parameters, making it easy to scan. There's minimal waste, though the structure could be slightly improved by integrating the purpose more fluidly with the args.

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

Completeness4/5

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

Given the tool's complexity (4 parameters, 1 required), no annotations, and an output schema present, the description does a decent job. It explains the purpose and parameters well, and since an output schema exists, it doesn't need to detail return values. However, it lacks behavioral context like pagination behavior or error handling, which would be helpful for full completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description includes an 'Args' section that explains each parameter's purpose, such as 'project_id: 專案 ID 或路徑' (project ID or path) and 'state: 狀態篩選' (state filter). With schema description coverage at 0%, this adds substantial value beyond the schema, clarifying semantics for all 4 parameters. However, it doesn't detail enum values for 'state' beyond listing them, slightly limiting completeness.

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 tool's purpose: '列出專案的 Merge Requests' (List project's Merge Requests). It specifies the verb ('列出' - list) and resource ('Merge Requests'), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'get_merge_request' (singular) or 'list_merge_request_notes', which would require a 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 sibling tools like 'get_merge_request' for single MRs or 'list_merge_request_notes' for notes, nor does it specify prerequisites or contexts for usage. The only implied usage is listing merge requests, but no explicit guidelines are given.

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