approve_merge_request
Approve GitLab merge requests to facilitate code integration by providing approval status and managing required approval thresholds for project collaboration.
Instructions
Approve a merge request.
Args:
project_id: The GitLab project ID or URL-encoded path
merge_request_iid: The merge request IID (project-specific ID)
approvals_required: Optional number of required approvals to set
Returns:
Dict containing the approval information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| merge_request_iid | Yes | ||
| approvals_required | No |
Input Schema (JSON Schema)
{
"properties": {
"approvals_required": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Approvals Required"
},
"merge_request_iid": {
"title": "Merge Request Iid",
"type": "string"
},
"project_id": {
"title": "Project Id",
"type": "string"
}
},
"required": [
"project_id",
"merge_request_iid"
],
"type": "object"
}
Implementation Reference
- server.py:331-352 (handler)The handler function for the 'approve_merge_request' tool, decorated with @mcp.tool() for registration. It approves the specified GitLab merge request and optionally sets the number of required approvals using the GitLab Python client.@mcp.tool() def approve_merge_request(ctx: Context, project_id: str, merge_request_iid: str, approvals_required: Optional[int] = None) -> Dict[str, Any]: """ Approve a merge request. Args: project_id: The GitLab project ID or URL-encoded path merge_request_iid: The merge request IID (project-specific ID) approvals_required: Optional number of required approvals to set Returns: Dict containing the approval information """ gl = ctx.request_context.lifespan_context project = gl.projects.get(project_id) mr = project.mergerequests.get(merge_request_iid) mr.approve() if approvals_required is not None: mr.approvals.post({'approvals_required': approvals_required}) return mr.asdict()
- server.py:331-331 (registration)The @mcp.tool() decorator registers the approve_merge_request function as an MCP tool.@mcp.tool()