Skip to content

feat: Branches management entity (browse_branches, manage_branch) #79

@polaz

Description

@polaz

Summary

Add branches management as new CQRS entity with browse_branches and manage_branch tools.

Motivation

  • Security critical for enterprise users
  • Branch protection is essential for code quality workflows
  • Competitors (rifqi96, GitHub MCP) have this

Proposed Tools

browse_branches (Query)

Action Description
list List all branches
get Get specific branch details
list_protected List protected branches
get_protected Get protection rules for branch

manage_branch (Command)

Action Description
create Create new branch from ref
delete Delete branch
protect Add branch protection
unprotect Remove branch protection
update_protection Update protection rules

GitLab API

  • GET /projects/:id/repository/branches - List branches
  • GET /projects/:id/repository/branches/:branch - Get branch
  • POST /projects/:id/repository/branches - Create branch
  • DELETE /projects/:id/repository/branches/:branch - Delete branch
  • GET /projects/:id/protected_branches - List protected
  • POST /projects/:id/protected_branches - Protect branch
  • DELETE /projects/:id/protected_branches/:name - Unprotect
  • PATCH /projects/:id/protected_branches/:name - Update protection

Docs: https://docs.gitlab.com/ee/api/branches.html
Docs: https://docs.gitlab.com/ee/api/protected_branches.html

Example Usage

// Create branch
{
  action: "create",
  project_id: "my-org/app",
  branch: "feature/new-feature",
  ref: "main"
}

// Protect branch
{
  action: "protect",
  project_id: "my-org/app",
  branch: "main",
  push_access_level: 40,      // Maintainers
  merge_access_level: 30,     // Developers
  allow_force_push: false
}

Tasks

  • Create src/entities/branches/ directory
  • Create schema-readonly.ts with BrowseBranchesSchema
  • Create schema.ts with ManageBranchSchema
  • Create registry.ts with handlers
  • Add to tool registry
  • Add tier metadata (protected branches: Premium for some features)
  • Add unit tests

Tier Requirements

  • Basic branches: GitLab Free
  • Protected branches: GitLab Free (basic), Premium (code owners, approval rules)

Complexity

HIGH - New entity, protection rules are complex, ~250 LOC

Priority

HIGH - Security critical

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature, new MCP tool, new capability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions