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
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | The path of the GitLab project. | |
| branchName | Yes | The name of the new branch. | |
| ref | Yes | The branch or SHA to create the branch from. |
Implementation Reference
- src/index.ts:1905-1919 (handler)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'], }, },
- src/gitlab.service.ts:613-623 (helper)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, }, ); }