Skip to main content
Glama

gitlab_cherry_pick_commit

Apply a specific commit from one branch to another branch in GitLab. Use for backporting fixes or selectively moving changes between branches.

Instructions

Apply commit to another branch Returns: New commit on target branch Use when: Backporting fixes, selective changes Creates: New commit with same changes

Example: Backport bug fix to stable

  • commit: "abc123" (fix from main)

  • branch: "stable-1.0" (apply here)

Related tools:

  • gitlab_get_commit: Find commit to pick

  • gitlab_create_merge_request: MR for picked commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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
commit_shaYesGit commit SHA Type: string Format: Abbreviated (min 7 chars) or full 40-character SHA Required: Yes Examples: - 'a1b2c3d' (short form - minimum 7 characters) - 'a1b2c3d4e5f6' (medium form) - 'e83c5163316f89bfbde7d9ab23ca2e25604af290' (full SHA) How to find: git log, GitLab UI, or MR/commit pages
branchYesTarget branch for commits Type: string Required: Yes Format: Existing branch name Examples: - 'main' (commit to main) - 'feature/add-login' (feature branch) - 'hotfix/security-patch' (hotfix branch) Note: Branch must exist before committing

Implementation Reference

  • Main handler function that implements the gitlab_cherry_pick_commit tool logic. Extracts required parameters (project_id auto-detected if missing, commit_sha, branch) and delegates to GitLabClient.cherry_pick_commit method.
    def handle_cherry_pick_commit(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]:
        """Handle cherry-picking a commit"""
        project_id = require_project_id(client, arguments)
        commit_sha = require_argument(arguments, "commit_sha")
        branch = require_argument(arguments, "branch")
        
        return client.cherry_pick_commit(project_id, commit_sha, branch)
  • Pydantic/MCP schema definition for gitlab_cherry_pick_commit tool input validation, specifying parameters and requirements.
        name=TOOL_CHERRY_PICK_COMMIT,
        description=desc.DESC_CHERRY_PICK,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "commit_sha": {"type": "string", "description": desc.DESC_COMMIT_SHA},
                "branch": {"type": "string", "description": desc.DESC_BRANCH}
            },
            "required": ["commit_sha", "branch"]
        }
    ),
  • Registration of the handler function in TOOL_HANDLERS dictionary used by server.call_tool() to dispatch tool calls.
    TOOL_CHERRY_PICK_COMMIT: handle_cherry_pick_commit,
    TOOL_COMPARE_REFS: handle_compare_refs,
  • Constant definition for the tool name, used consistently across codebase.
    TOOL_CHERRY_PICK_COMMIT = "gitlab_cherry_pick_commit"
  • Tool schema and registration in server.list_tools() method, exposed to MCP clients.
    types.Tool(
        name="gitlab_cherry_pick_commit",
        description=desc.DESC_CHERRY_PICK,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "commit_sha": {"type": "string", "description": desc.DESC_COMMIT_SHA},
                "branch": {"type": "string", "description": desc.DESC_BRANCH}
            },
            "required": ["commit_sha", "branch"]
        }
    ),

Tool Definition Quality

Score is being calculated. Check back soon.

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

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