Skip to main content
Glama

gitlab_rebase_merge_request

Rebase a GitLab merge request onto the target branch to resolve out-of-date status. Requires fast-forward merge, no conflicts, and developer access. Works with project ID and MR number.

Instructions

Rebase MR onto target branch Returns: Rebase status Use when: MR is behind target branch Fixes: Out-of-date MR status

Requirements:

  • Fast-forward merge method

  • No conflicts

  • Developer access

Related tools:

  • gitlab_get_merge_request: Check if rebase needed

  • gitlab_merge_merge_request: Merge after rebase

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mr_iidYesMerge 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_idNoProject 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

  • The core handler function for the gitlab_rebase_merge_request tool. Extracts project_id (auto-detects from git if missing) and required mr_iid parameter, then calls the underlying GitLabClient.rebase_merge_request method to perform the rebase operation.
    def handle_rebase_merge_request(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle rebasing a merge request""" project_id = require_project_id(client, arguments) mr_iid = require_argument(arguments, "mr_iid") return client.rebase_merge_request(project_id, mr_iid)
  • MCP tool schema definition specifying input parameters: optional project_id (string) and required mr_iid (integer). Used for input validation and tool documentation.
    types.Tool( name=TOOL_REBASE_MR, description=desc.DESC_REBASE_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"] } ),
  • Registration of the tool handler in the TOOL_HANDLERS dictionary mapping, which is used by server.py to dispatch tool calls to the correct handler function.
    TOOL_CREATE_SNIPPET: handle_create_snippet, TOOL_UPDATE_SNIPPET: handle_update_snippet, TOOL_UPDATE_MR: handle_update_merge_request, TOOL_CLOSE_MR: handle_close_merge_request, TOOL_MERGE_MR: handle_merge_merge_request, TOOL_REBASE_MR: handle_rebase_merge_request, TOOL_APPROVE_MR: handle_approve_merge_request, TOOL_ADD_ISSUE_COMMENT: handle_add_issue_comment, TOOL_ADD_MR_COMMENT: handle_add_merge_request_comment, TOOL_RESOLVE_DISCUSSION: handle_resolve_discussion, TOOL_CREATE_COMMIT: handle_create_commit, TOOL_CHERRY_PICK_COMMIT: handle_cherry_pick_commit, TOOL_COMPARE_REFS: handle_compare_refs,
  • Helper functions used by the handler: get_project_id_or_detect auto-detects project from git remote if not provided; require_project_id ensures project_id is available or raises error.
    def get_project_id_or_detect(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Optional[str]: """Get project_id from arguments or detect from git repository""" if arguments and arguments.get("project_id"): return arguments["project_id"] detected = client.get_project_from_git(".") if detected: return detected["id"] return None def require_project_id(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> str: """Get project_id or raise error if not found""" project_id = get_project_id_or_detect(client, arguments) if not project_id: raise ValueError(ERROR_NO_PROJECT) return project_id
  • Constant defining the exact tool name string used throughout for consistency in registrations and references.
    TOOL_REBASE_MR = "gitlab_rebase_merge_request"

Other Tools

Related 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/Vijay-Duke/mcp-gitlab'

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