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"]
        }
    ),
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: 'Returns: New commit on target branch' and 'Creates: New commit with same changes', clarifying it's a write operation that produces a new commit. However, it doesn't mention potential side effects like merge conflicts, permissions required, or error conditions, leaving some behavioral aspects uncovered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with key information: purpose, returns, usage, and creation. Each section (e.g., 'Use when:', 'Example:', 'Related tools:') is concise and adds value without redundancy. The example is brief yet illustrative, making efficient use of space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a write operation with 3 parameters) and no annotations or output schema, the description does a good job covering purpose, usage, and behavior. However, it lacks details on error handling, authentication requirements, or what happens in edge cases (e.g., if the target branch doesn't exist), which would enhance completeness for a mutation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing detailed documentation for all three parameters (project_id, commit_sha, branch). The description adds minimal parameter semantics beyond the schema, only implying through the example that 'commit' maps to commit_sha and 'branch' maps to the target branch. It doesn't provide additional context or usage nuances for the parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Apply commit to another branch') and resource ('commit'), distinguishing it from siblings like gitlab_create_commit (which creates new commits) and gitlab_get_commit (which retrieves commit info). The first sentence provides a precise verb+resource combination.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'Use when: Backporting fixes, selective changes' and provides a concrete example ('Example: Backport bug fix to stable'). It also lists related tools (gitlab_get_commit, gitlab_create_merge_request) to guide users toward alternatives or complementary actions, offering clear context for when to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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