gitlab_close_merge_request
Close a GitLab merge request without merging it, useful for abandoning changes or deferring work. Automatically updates the MR to a closed state, allowing it to be reopened later. Requires the merge request number (IID).
Instructions
Close merge request without merging Returns: Updated MR with closed state Use when: Abandoning changes, deferring work Note: Can be reopened later
Related tools:
gitlab_update_merge_request: Reopen or other updates
gitlab_merge_merge_request: Merge instead
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mr_iid | Yes | Merge request number (IID - Internal ID) Type: integer Format: Project-specific MR number (without !) Required: Yes Examples: - 456 (for MR !456) - 7890 (for MR !7890) How to find: Look at MR URL or title - URL: https://gitlab.com/group/project/-/merge_requests/456 → use 456 - Title: "Add new feature (!456)" → use 456 Note: This is NOT the global MR ID | |
| project_id | No | Project identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted |
Implementation Reference
- src/mcp_gitlab/tool_handlers.py:304-310 (handler)The core handler function that executes the gitlab_close_merge_request tool. It resolves the project_id (auto-detecting from git if not provided), requires the mr_iid argument, and delegates to the GitLabClient's close_merge_request method.def handle_close_merge_request(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle closing a merge request""" project_id = require_project_id(client, arguments) mr_iid = require_argument(arguments, "mr_iid") return client.close_merge_request(project_id, mr_iid)
- src/mcp_gitlab/tool_handlers.py:1044-1044 (registration)The tool handler is registered in the TOOL_HANDLERS dictionary mapping using the TOOL_CLOSE_MR constant as the key.TOOL_CLOSE_MR: handle_close_merge_request,
- Input schema definition for the tool in the TOOLS list, specifying the expected parameters: optional project_id (string) and required mr_iid (integer).types.Tool( name=TOOL_CLOSE_MR, description=desc.DESC_CLOSE_MR, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "mr_iid": {"type": "integer", "description": desc.DESC_MR_IID} }, "required": ["mr_iid"] } ),
- src/mcp_gitlab/constants.py:231-231 (helper)Constant defining the exact tool name string used for registration and references.TOOL_CLOSE_MR = "gitlab_close_merge_request"