Skip to main content
Glama

gitlab_batch_operations

Execute multiple GitLab operations atomically with automatic rollback on failure, enabling complex multi-step workflows where all steps succeed or none apply.

Instructions

Execute multiple operations atomically Returns: Results of all operations or rollback Use when: Complex multi-step workflows Feature: Reference previous operation results

Key benefits:

  • All-or-nothing execution

  • Operation chaining

  • Automatic rollback

  • Result references: {{op1.field}}

Example workflow:

  1. Create branch

  2. Add files

  3. Create MR All succeed or all rolled back

Related tools:

  • Individual operation tools

  • gitlab_safe_preview_commit: Test first

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
operationsYesBatch operations list Type: array of objects Required: Yes Structure: { "name": "string (operation identifier)", "tool": "string (GitLab tool name)", "arguments": "object (tool-specific arguments)" } Features: - Sequential execution - Result referencing: {{operation_name.field}} - Automatic rollback on failure Examples: [ { "name": "create_branch", "tool": "gitlab_create_branch", "arguments": { "branch": "feature/new-feature", "ref": "main" } }, { "name": "create_file", "tool": "gitlab_create_commit", "arguments": { "branch": "{{create_branch.name}}", "commit_message": "Add new feature", "actions": [{ "action": "create", "file_path": "feature.py", "content": "# New feature" }] } }, { "name": "create_mr", "tool": "gitlab_create_merge_request", "arguments": { "source_branch": "{{create_branch.name}}", "target_branch": "main", "title": "Add new feature" } } ] Use cases: - Complex workflows - Dependent operations - Atomic multi-step changes
stop_on_errorNoError handling strategy Type: boolean Default: true Options: - true: Stop and rollback on first error - false: Continue, collect all errors Use cases: - true: Critical operations requiring all-or-nothing - false: Best-effort batch processing

Implementation Reference

  • The primary handler function that implements the core logic of the gitlab_batch_operations tool. It parses input arguments, resolves the project ID (auto-detecting from git if not provided), and executes batch operations via the GitLabClient.
    def handle_batch_operations(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]:
        """Handle batch operations"""
        project_id = require_project_id(client, arguments)
        operations = require_argument(arguments, "operations")
        stop_on_error = get_argument(arguments, "stop_on_error", True)
        
        return client.batch_operations(project_id, operations, stop_on_error)
  • Defines the input schema and parameters for the gitlab_batch_operations tool, including the structure for the operations array (each with name, tool, arguments) and optional project_id and stop_on_error.
    types.Tool(
        name=TOOL_BATCH_OPERATIONS,
        description=desc.DESC_BATCH_OPERATIONS,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "operations": {
                    "type": "array",
                    "description": desc.DESC_OPERATIONS,
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": {"type": "string", "description": "Operation name for reference"},
                            "tool": {"type": "string", "description": "GitLab tool name to execute"},
                            "arguments": {"type": "object", "description": "Arguments for the tool"}
                        },
                        "required": ["name", "tool", "arguments"]
                    }
                },
                "stop_on_error": {"type": "boolean", "description": desc.DESC_STOP_ON_ERROR, "default": True}
            },
            "required": ["operations"]
        }
    ),
  • Registers the handler function for gitlab_batch_operations in the central TOOL_HANDLERS dictionary, which is used by server.py to dispatch tool calls.
    TOOL_BATCH_OPERATIONS: handle_batch_operations,
  • Registers the gitlab_batch_operations tool definition (name, description, schema) in the TOOLS list used for tool listing and validation.
        name=TOOL_BATCH_OPERATIONS,
        description=desc.DESC_BATCH_OPERATIONS,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "operations": {
                    "type": "array",
                    "description": desc.DESC_OPERATIONS,
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": {"type": "string", "description": "Operation name for reference"},
                            "tool": {"type": "string", "description": "GitLab tool name to execute"},
                            "arguments": {"type": "object", "description": "Arguments for the tool"}
                        },
                        "required": ["name", "tool", "arguments"]
                    }
                },
                "stop_on_error": {"type": "boolean", "description": desc.DESC_STOP_ON_ERROR, "default": True}
            },
            "required": ["operations"]
        }
    ),
  • Constant definition providing the canonical string name for the gitlab_batch_operations tool, used consistently across definitions, registrations, and tests.
    TOOL_BATCH_OPERATIONS = "gitlab_batch_operations"

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