Skip to main content
Glama

gitlab_create_branch

Create a new branch in a GitLab project by specifying the project path, branch name, and source reference for development or feature work.

Instructions

Creates a new branch in a GitLab project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.
branchNameYesThe name of the new branch.
refYesThe branch or SHA to create the branch from.

Implementation Reference

  • MCP server request handler for the 'gitlab_create_branch' tool. Extracts arguments, calls GitLabService.createBranch, and returns success response.
    case 'gitlab_create_branch': { if (!gitlabService) { throw new Error('GitLab service is not initialized.'); } const { projectPath, branchName, ref } = args as { projectPath: string; branchName: string; ref: string }; const result = await gitlabService.createBranch(projectPath, branchName, ref); return { content: [ { type: 'text', text: `Branch created successfully: ${JSON.stringify(result, null, 2)}`, }, ], }; }
  • src/index.ts:770-790 (registration)
    Tool registration in allTools array, including name, description, and input schema.
    name: 'gitlab_create_branch', description: 'Creates a new branch in a GitLab project.', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, branchName: { type: 'string', description: 'The name of the new branch.', }, ref: { type: 'string', description: 'The branch or SHA to create the branch from.', }, }, required: ['projectPath', 'branchName', 'ref'], }, },
  • GitLabService.createBranch method: core logic that makes the POST API call to GitLab to create the branch.
    async createBranch(projectPath: string, branchName: string, ref: string): Promise<any> { const encodedProjectPath = encodeURIComponent(projectPath); return this.callGitLabApi<any>( `projects/${encodedProjectPath}/repository/branches`, 'POST', { branch: branchName, ref: ref, }, ); }

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

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