unapprove_merge_request
Revoke approval from a GitLab merge request to prevent merging when changes require further review. Specify project and merge request IDs.
Instructions
Unapprove a merge request.
Args:
project_id: The GitLab project ID or URL-encoded path
merge_request_iid: The merge request IID (project-specific ID)
Returns:
Dict containing the unapproval information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| merge_request_iid | Yes |
Implementation Reference
- server.py:502-522 (handler)The main handler function for the 'unapprove_merge_request' tool. It is registered via the @mcp.tool() decorator. The function fetches the project and merge request using the GitLab client, attempts to unapprove the MR with mr.unapprove(), logs any errors, and returns the MR details.@mcp.tool() def unapprove_merge_request(ctx: Context, project_id: str, merge_request_iid: str) -> Dict[str, Any]: """ Unapprove a merge request. Args: project_id: The GitLab project ID or URL-encoded path merge_request_iid: The merge request IID (project-specific ID) Returns: Dict containing the unapproval information """ gl = ctx.request_context.lifespan_context project = gl.projects.get(project_id) mr = project.mergerequests.get(merge_request_iid) try: mr.unapprove() except Exception as e: logger.error(f"Failed to unapprove merge request {merge_request_iid}: {e}") return mr.asdict()