Skip to main content
Glama

create_branch

Create a new branch in a GitLab project by specifying the project ID, branch name, and source reference for version control workflows.

Instructions

Create a new branch in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or URL-encoded path
branchYesName for the new branch
refNoSource branch/commit for new branch

Implementation Reference

  • The actual implementation of the branch creation logic, utilizing the gitlab-client to perform the API call.
    export async function createBranch(projectId: string, options: CreateBranchOptions): Promise<GitLabReference> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (!options.name?.trim()) {
        throw new Error("Branch name is required");
      }
      if (!options.ref?.trim()) {
        throw new Error("Source reference is required");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/repository/branches`;
    
      const branch = await gitlabPost<GitLabReference>(endpoint, {
        branch: options.name,
        ref: options.ref
      });
    
      return GitLabReferenceSchema.parse(branch);
    }
  • src/server.ts:227-235 (registration)
    The tool request handler switch-case block where the `create_branch` request is handled.
    case "create_branch": {
      const args = CreateBranchSchema.parse(request.params.arguments);
      const ref = args.ref || "HEAD";
      const branch = await api.createBranch(args.project_id, {
        name: args.branch,
        ref
      });
      return { content: [{ type: "text", text: JSON.stringify(branch, null, 2) }] };
    }
  • src/server.ts:104-108 (registration)
    The definition of the `create_branch` tool including its name, description, and input schema.
    {
      name: "create_branch",
      description: "Create a new branch in a GitLab project",
      inputSchema: zodToJsonSchema(CreateBranchSchema)
    },
  • The Zod schema definition for input validation of the `create_branch` tool.
    export const CreateBranchSchema = ProjectParamsSchema.extend({
      branch: z.string().describe("Name for the new branch"),
      ref: z.string().optional().describe("Source branch/commit for new branch")
    });

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.5.2

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and description omits behavioral details like error handling on duplicate branch, permission requirements, or whether ref is optional.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence is concise and front-loaded with key info, but lacks structure for complex details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, description is too brief. Does not mention important context like branch naming rules or default behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers 100% of parameters with descriptions. Description adds no extra meaning beyond what schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states action (Create), resource (branch), and context (GitLab project). It effectively distinguishes from sibling tools as no other tool creates branches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives, no prerequisites or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.