GitLab CI/CD · Capability

GitLab API — branches

GitLab API — branches. 8 operations. Lead operation: branches. Self-contained Naftiko capability covering one Gitlab Ci business surface.

Run with Naftiko Gitlab Cibranches

What You Can Do

GET
Getapiv4projectsidrepositorybranches — Get a project repository branches
/v1/api/v4/projects/{id}/repository/branches
POST
Postapiv4projectsidrepositorybranches — Create branch
/v1/api/v4/projects/{id}/repository/branches
HEAD
Headapiv4projectsidrepositorybranchesbranch — Check if a branch exists
/v1/api/v4/projects/{id}/repository/branches/{branch}
GET
Getapiv4projectsidrepositorybranchesbranch — Get a single repository branch
/v1/api/v4/projects/{id}/repository/branches/{branch}
DELETE
Deleteapiv4projectsidrepositorybranchesbranch — Delete a branch
/v1/api/v4/projects/{id}/repository/branches/{branch}
PUT
Putapiv4projectsidrepositorybranchesbranchprotect — Protect a single branch
/v1/api/v4/projects/{id}/repository/branches/{branch}/protect
PUT
Putapiv4projectsidrepositorybranchesbranchunprotect — Unprotect a single branch
/v1/api/v4/projects/{id}/repository/branches/{branch}/unprotect
DELETE
Deleteapiv4projectsidrepositorymergedbranches — Delete all merged branches
/v1/api/v4/projects/{id}/repository/merged-branches

MCP Tools

get-project-repository-branches

Get a project repository branches

read-only idempotent
create-branch

Create branch

check-if-branch-exists

Check if a branch exists

get-single-repository-branch

Get a single repository branch

read-only idempotent
delete-branch

Delete a branch

idempotent
protect-single-branch

Protect a single branch

idempotent
unprotect-single-branch

Unprotect a single branch

idempotent
delete-all-merged-branches

Delete all merged branches

idempotent

Capability Spec

gitlab-ci-branches.yaml Raw ↑
naftiko: 1.0.0-alpha2
info:
  label: GitLab API — branches
  description: 'GitLab API — branches. 8 operations. Lead operation: branches. Self-contained Naftiko capability covering
    one Gitlab Ci business surface.'
  tags:
  - Gitlab Ci
  - branches
  created: '2026-05-19'
  modified: '2026-05-19'
binds:
- namespace: env
  keys:
    GITLAB_CI_API_KEY: GITLAB_CI_API_KEY
capability:
  consumes:
  - type: http
    namespace: gitlab-ci-branches
    baseUri: https://gitlab.com
    description: GitLab API — branches business capability. Self-contained, no shared references.
    resources:
    - name: api-v4-projects-id-repository-branches
      path: /api/v4/projects/{id}/repository/branches
      operations:
      - name: getapiv4projectsidrepositorybranches
        method: GET
        description: Get a project repository branches
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: page
          in: query
          type: integer
          description: Current page number
        - name: per_page
          in: query
          type: integer
          description: Number of items per page
        - name: search
          in: query
          type: string
          description: Return list of branches matching the search criteria
        - name: regex
          in: query
          type: string
          description: Return list of branches matching the regex
        - name: sort
          in: query
          type: string
          description: Return list of branches sorted by the given field
        - name: page_token
          in: query
          type: string
          description: Name of branch to start the pagination from
      - name: postapiv4projectsidrepositorybranches
        method: POST
        description: Create branch
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: postApiV4ProjectsIdRepositoryBranches
          in: body
          type: string
          required: true
    - name: api-v4-projects-id-repository-branches-branch
      path: /api/v4/projects/{id}/repository/branches/{branch}
      operations:
      - name: headapiv4projectsidrepositorybranchesbranch
        method: HEAD
        description: Check if a branch exists
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: branch
          in: path
          type: string
          description: The name of the branch
          required: true
      - name: getapiv4projectsidrepositorybranchesbranch
        method: GET
        description: Get a single repository branch
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: branch
          in: path
          type: integer
          required: true
      - name: deleteapiv4projectsidrepositorybranchesbranch
        method: DELETE
        description: Delete a branch
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: branch
          in: path
          type: string
          description: The name of the branch
          required: true
    - name: api-v4-projects-id-repository-branches-branch-protect
      path: /api/v4/projects/{id}/repository/branches/{branch}/protect
      operations:
      - name: putapiv4projectsidrepositorybranchesbranchprotect
        method: PUT
        description: Protect a single branch
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: branch
          in: path
          type: string
          description: The name of the branch
          required: true
        - name: putApiV4ProjectsIdRepositoryBranchesBranchProtect
          in: body
          type: string
          required: true
    - name: api-v4-projects-id-repository-branches-branch-unprotect
      path: /api/v4/projects/{id}/repository/branches/{branch}/unprotect
      operations:
      - name: putapiv4projectsidrepositorybranchesbranchunprotect
        method: PUT
        description: Unprotect a single branch
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
        - name: branch
          in: path
          type: string
          description: The name of the branch
          required: true
    - name: api-v4-projects-id-repository-merged_branches
      path: /api/v4/projects/{id}/repository/merged_branches
      operations:
      - name: deleteapiv4projectsidrepositorymergedbranches
        method: DELETE
        description: Delete all merged branches
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
        inputParameters:
        - name: id
          in: path
          type: string
          description: The ID or URL-encoded path of the project
          required: true
  exposes:
  - type: rest
    namespace: gitlab-ci-branches-rest
    port: 8080
    description: REST adapter for GitLab API — branches. One Spectral-compliant resource per consumed operation, prefixed
      with /v1.
    resources:
    - path: /v1/api/v4/projects/{id}/repository/branches
      name: api-v4-projects-id-repository-branches
      description: REST surface for api-v4-projects-id-repository-branches.
      operations:
      - method: GET
        name: getapiv4projectsidrepositorybranches
        description: Get a project repository branches
        call: gitlab-ci-branches.getapiv4projectsidrepositorybranches
        with:
          id: rest.id
          page: rest.page
          per_page: rest.per_page
          search: rest.search
          regex: rest.regex
          sort: rest.sort
          page_token: rest.page_token
        outputParameters:
        - type: object
          mapping: $.
      - method: POST
        name: postapiv4projectsidrepositorybranches
        description: Create branch
        call: gitlab-ci-branches.postapiv4projectsidrepositorybranches
        with:
          id: rest.id
          postApiV4ProjectsIdRepositoryBranches: rest.postApiV4ProjectsIdRepositoryBranches
        outputParameters:
        - type: object
          mapping: $.
    - path: /v1/api/v4/projects/{id}/repository/branches/{branch}
      name: api-v4-projects-id-repository-branches-branch
      description: REST surface for api-v4-projects-id-repository-branches-branch.
      operations:
      - method: HEAD
        name: headapiv4projectsidrepositorybranchesbranch
        description: Check if a branch exists
        call: gitlab-ci-branches.headapiv4projectsidrepositorybranchesbranch
        with:
          id: rest.id
          branch: rest.branch
        outputParameters:
        - type: object
          mapping: $.
      - method: GET
        name: getapiv4projectsidrepositorybranchesbranch
        description: Get a single repository branch
        call: gitlab-ci-branches.getapiv4projectsidrepositorybranchesbranch
        with:
          id: rest.id
          branch: rest.branch
        outputParameters:
        - type: object
          mapping: $.
      - method: DELETE
        name: deleteapiv4projectsidrepositorybranchesbranch
        description: Delete a branch
        call: gitlab-ci-branches.deleteapiv4projectsidrepositorybranchesbranch
        with:
          id: rest.id
          branch: rest.branch
        outputParameters:
        - type: object
          mapping: $.
    - path: /v1/api/v4/projects/{id}/repository/branches/{branch}/protect
      name: api-v4-projects-id-repository-branches-branch-protect
      description: REST surface for api-v4-projects-id-repository-branches-branch-protect.
      operations:
      - method: PUT
        name: putapiv4projectsidrepositorybranchesbranchprotect
        description: Protect a single branch
        call: gitlab-ci-branches.putapiv4projectsidrepositorybranchesbranchprotect
        with:
          id: rest.id
          branch: rest.branch
          putApiV4ProjectsIdRepositoryBranchesBranchProtect: rest.putApiV4ProjectsIdRepositoryBranchesBranchProtect
        outputParameters:
        - type: object
          mapping: $.
    - path: /v1/api/v4/projects/{id}/repository/branches/{branch}/unprotect
      name: api-v4-projects-id-repository-branches-branch-unprotect
      description: REST surface for api-v4-projects-id-repository-branches-branch-unprotect.
      operations:
      - method: PUT
        name: putapiv4projectsidrepositorybranchesbranchunprotect
        description: Unprotect a single branch
        call: gitlab-ci-branches.putapiv4projectsidrepositorybranchesbranchunprotect
        with:
          id: rest.id
          branch: rest.branch
        outputParameters:
        - type: object
          mapping: $.
    - path: /v1/api/v4/projects/{id}/repository/merged-branches
      name: api-v4-projects-id-repository-merged-branches
      description: REST surface for api-v4-projects-id-repository-merged_branches.
      operations:
      - method: DELETE
        name: deleteapiv4projectsidrepositorymergedbranches
        description: Delete all merged branches
        call: gitlab-ci-branches.deleteapiv4projectsidrepositorymergedbranches
        with:
          id: rest.id
        outputParameters:
        - type: object
          mapping: $.
  - type: mcp
    namespace: gitlab-ci-branches-mcp
    port: 9090
    transport: http
    description: MCP adapter for GitLab API — branches. One tool per consumed operation, routed inline through this capability's
      consumes block.
    tools:
    - name: get-project-repository-branches
      description: Get a project repository branches
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: gitlab-ci-branches.getapiv4projectsidrepositorybranches
      with:
        id: tools.id
        page: tools.page
        per_page: tools.per_page
        search: tools.search
        regex: tools.regex
        sort: tools.sort
        page_token: tools.page_token
      outputParameters:
      - type: object
        mapping: $.
    - name: create-branch
      description: Create branch
      hints:
        readOnly: false
        destructive: false
        idempotent: false
      call: gitlab-ci-branches.postapiv4projectsidrepositorybranches
      with:
        id: tools.id
        postApiV4ProjectsIdRepositoryBranches: tools.postApiV4ProjectsIdRepositoryBranches
      outputParameters:
      - type: object
        mapping: $.
    - name: check-if-branch-exists
      description: Check if a branch exists
      hints:
        readOnly: false
        destructive: false
        idempotent: false
      call: gitlab-ci-branches.headapiv4projectsidrepositorybranchesbranch
      with:
        id: tools.id
        branch: tools.branch
      outputParameters:
      - type: object
        mapping: $.
    - name: get-single-repository-branch
      description: Get a single repository branch
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: gitlab-ci-branches.getapiv4projectsidrepositorybranchesbranch
      with:
        id: tools.id
        branch: tools.branch
      outputParameters:
      - type: object
        mapping: $.
    - name: delete-branch
      description: Delete a branch
      hints:
        readOnly: false
        destructive: true
        idempotent: true
      call: gitlab-ci-branches.deleteapiv4projectsidrepositorybranchesbranch
      with:
        id: tools.id
        branch: tools.branch
      outputParameters:
      - type: object
        mapping: $.
    - name: protect-single-branch
      description: Protect a single branch
      hints:
        readOnly: false
        destructive: false
        idempotent: true
      call: gitlab-ci-branches.putapiv4projectsidrepositorybranchesbranchprotect
      with:
        id: tools.id
        branch: tools.branch
        putApiV4ProjectsIdRepositoryBranchesBranchProtect: tools.putApiV4ProjectsIdRepositoryBranchesBranchProtect
      outputParameters:
      - type: object
        mapping: $.
    - name: unprotect-single-branch
      description: Unprotect a single branch
      hints:
        readOnly: false
        destructive: false
        idempotent: true
      call: gitlab-ci-branches.putapiv4projectsidrepositorybranchesbranchunprotect
      with:
        id: tools.id
        branch: tools.branch
      outputParameters:
      - type: object
        mapping: $.
    - name: delete-all-merged-branches
      description: Delete all merged branches
      hints:
        readOnly: false
        destructive: true
        idempotent: true
      call: gitlab-ci-branches.deleteapiv4projectsidrepositorymergedbranches
      with:
        id: tools.id
      outputParameters:
      - type: object
        mapping: $.