Branch
gitlab_branchManage Git branches: create, delete, list, protect, unprotect. View aggregated branch rules via GraphQL including push/merge access, force push, code owner approval. Supports pagination.
Instructions
Example: {"action":"create","params":{...}} For the params schema of any action, read the MCP resource gitlab://schema/meta/gitlab_branch/.
Manage Git branches and branch protections in a project, plus aggregated branch rules (GraphQL). Delete and unprotect are destructive and irreversible. When to use: create/list/delete branches, protect or update protection on branches, audit aggregated branch rules (push/merge access, approval rules, status checks). NOT for: file contents on a branch (use gitlab_repository file_get/file_create/...), commit operations (use gitlab_repository commit_*), tags (use gitlab_tag), opening MRs against a branch (use gitlab_merge_request).
Returns:
list / list_protected: array of {name, default, protected, merged, commit, ...} with pagination.
get / get_protected / create / protect / update_protected: branch or protection object.
delete / delete_merged / unprotect: {success: bool, message: string}.
rule_list: GraphQL aggregated view {nodes: [{name, branch_protection, approval_rules, external_status_checks}], page_info}. Errors: 404 not found, 403 forbidden (hint: requires Maintainer+ to protect/unprotect), 400 invalid params (hint: cannot delete default or protected branches — unprotect first).
Param conventions: * = required. All actions need project_id* (numeric or url-encoded path) except rule_list which uses project_path*. Access levels: 0 = no one, 30 = Developer, 40 = Maintainer.
create: project_id*, branch_name*, ref* (branch/tag/SHA)
get / delete: project_id*, branch_name*
list: project_id*, search, page, per_page
delete_merged: project_id* — deletes all merged branches except default/protected
protect: project_id*, branch_name*, push_access_level (0/30/40), merge_access_level (0/30/40), allow_force_push (bool)
unprotect: project_id*, branch_name*
list_protected: project_id*
get_protected: project_id*, branch_name*
update_protected: project_id*, branch_name*, allow_force_push (bool), code_owner_approval_required (bool)
rule_list: project_path* (e.g. my-group/my-project), first (max 100), after (cursor)
See also: gitlab_repository (file/commit operations on a branch), gitlab_merge_request (open MRs against a branch), gitlab_tag (tag CRUD/protection).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform. Pick exactly one of the values in `enum`. Each action expects its own `params` object — see the tool description for the per-action parameter list. | |
| params | No | Action-specific parameters as a JSON object. Required and optional fields differ per action; consult this tool's description for the chosen action. Send only the fields documented for that action — unknown keys are rejected with a validation error (only reserved meta keys like `confirm` are stripped before validation). For the JSON Schema of a specific action's `params`, read the MCP resource `gitlab://schema/meta/{tool}/{action}` (replace placeholders with the tool name and the chosen action). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next_steps | No | Optional. Suggested follow-up actions or tool calls for the LLM, contextual to the result. | |
| pagination | No | Present on list actions. Use `has_more` and `next_page` to paginate through results. |