Skip to main content
Glama

protect_branch

Destructive

Set branch protection rules to control who can push, merge, or unprotect, and enable force-push or code-owner approvals. Define clear permissions to safeguard critical branches.

Instructions

Protect a repository branch (set push/merge/unprotect access levels). Use this to create or update protection rules for a branch or wildcard; use get_protected_branch to inspect existing rules first. The operation changes who may push, merge, or unprotect, may enable force-push or code-owner settings, requires maintainer-level permission, and returns the protection rule or a validation/permission error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoDeprecated alias for branch_name; prefer branch_name for consistency
project_idNoProject ID or complete URL-encoded path to project
branch_nameYesBranch name or wildcard pattern to protect
allow_force_pushNoAllow force push to the protected branch. Default: false
push_access_levelNoAccess level for pushing (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted.
merge_access_levelNoAccess level for merging (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted.
unprotect_access_levelNoAccess level for unprotecting (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted.
code_owner_approval_requiredNoRequire code owner approval before merging (PREMIUM). Default: false

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Addedv2.1.21

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already disclose destructiveHint=true and openWorldHint=true, so the bar is lowered. The description adds value beyond annotations by disclosing that the operation 'changes who may push, merge, or unprotect', 'may enable force-push or code-owner settings', requires 'maintainer-level permission', and returns 'the protection rule or a validation/permission error'. This is meaningful operational context on top of the structured annotations. No contradiction found.

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?

Two efficiently structured sentences with zero filler. Purpose is front-loaded, succeeded by usage direction, then behavioral notes. Every clause earns its place; permission requirement and return/error behavior are packed into the final sentence without bloat.

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?

For a complex 8-parameter mutation tool with no output schema, the description covers the essentials: the operation's scope, the permission prerequisite, force-push/code-owner side effects, and the return type or error. The 'inspect first' guidance rounds out the workflow. Minor gap: it does not enumerate all side-effect flags or clarify the deprecation relationship between `name` and `branch_name`, but the schema covers parameters.

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%, so the schema already documents all 8 parameters in detail (including access-level integer meanings and defaults). The description adds only a high-level mention of 'push/merge/unprotect access levels' and 'force-push or code-owner settings', which restates rather than extends the schema. Baseline 3 is appropriate when the schema carries the burden.

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?

States a specific verb and resource ('Protect a repository branch') with a concrete description of the effect ('set push/merge/unprotect access levels'). Explicitly names the sibling `get_protected_branch` to distinguish inspection from mutation, and the existence of `unprotect_branch` in the sibling list provides further contrast. An agent can clearly tell this tool from related ones without opening schemas.

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

Usage Guidelines4/5

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

Gives explicit when-to-use guidance ('Use this to create or update protection rules for a branch or wildcard') and instructs the agent to inspect first ('use `get_protected_branch` to inspect existing rules first'). Also states the prerequisite permission ('requires maintainer-level permission'). It does not explicitly contrast with `unprotect_branch`, but the directional guidance to the sibling is strong and actionable.

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

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