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")
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Create a new branch,' implying a write/mutation operation, but doesn't disclose any behavioral traits such as permissions required, whether it's idempotent, error handling for duplicate branches, or rate limits. This leaves significant gaps for an agent to understand how to use it effectively.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It's appropriately sized for a straightforward tool, making it easy for an agent to parse quickly.

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 the complexity (a mutation tool with no annotations and no output schema), the description is incomplete. It lacks information on behavioral aspects like permissions, error cases, or what the tool returns. While the schema covers parameters well, the overall context for safe and effective use is insufficient, especially for a creation operation.

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?

The description adds no parameter semantics beyond what the input schema provides. With 100% schema description coverage, the schema already documents all three parameters (project_id, branch, ref) clearly. The baseline score of 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with additional context like examples or constraints.

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

Purpose4/5

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

The description clearly states the action ('Create a new branch') and resource ('in a GitLab project'), making the purpose immediately understandable. It distinguishes this from sibling tools like create_issue or create_merge_request by specifying it's about branches. However, it doesn't explicitly mention what distinguishes it from fork_repository or push_files, which also involve branch-like operations.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing project), when not to use it (e.g., if a branch already exists), or direct alternatives among siblings like fork_repository for creating branches in a different context. Usage is implied but not explicitly stated.

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

Install Server

Other Tools

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/TheRealChrisThomas/gitlab-mcp-server'

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