Skip to main content
Glama

branch_create

Create a new branch in a specified Git repository using the Git MCP Server. Input branch name and repository path; optionally force creation, set tracking, or configure upstream for push/pull operations.

Instructions

Create a new branch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forceNoForce create branch even if it exists
nameYesBranch name
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)
setUpstreamNoSet upstream for push/pull
trackNoSet up tracking mode

Implementation Reference

  • The primary handler function for 'branch_create' tool. Validates repository and branch name, executes 'git checkout -b' command with flags for force, track, and setUpstream, handles caching invalidation for branch state, and returns formatted success message.
    static async branchCreate({ path, name, force, track, setUpstream }: BranchOptions, context: GitToolContext): Promise<GitToolResult> {
      const resolvedPath = this.getPath({ path });
      return await this.executeOperation(
        context.operation,
        resolvedPath,
        async () => {
          const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath);
          PathValidator.validateBranchName(name);
          
          const result = await CommandExecutor.executeGitCommand(
            `checkout -b ${name}${force ? ' --force' : ''}${track ? ' --track' : ' --no-track'}${setUpstream ? ' --set-upstream' : ''}`,
            context.operation,
            repoPath
          );
    
          return {
            content: [{
              type: 'text',
              text: `Branch '${name}' created successfully\n${CommandExecutor.formatOutput(result)}`
            }]
          };
        },
        {
          command: 'branch_create',
          invalidateCache: true, // Invalidate branch cache
          stateType: RepoStateType.BRANCH
        }
      );
    }
  • MCP tool registration for 'branch_create', defining the tool name, description, input schema with properties for path, name, force, track, setUpstream, and required fields.
    {
      name: 'branch_create',
      description: 'Create a new branch',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: `Path to repository. ${PATH_DESCRIPTION}`,
          },
          name: {
            type: 'string',
            description: 'Branch name',
          },
          force: {
            type: 'boolean',
            description: 'Force create branch even if it exists',
            default: false
          },
          track: {
            type: 'boolean',
            description: 'Set up tracking mode',
            default: true
          },
          setUpstream: {
            type: 'boolean',
            description: 'Set upstream for push/pull',
            default: false
          }
        },
        required: ['name'],
      },
  • Tool dispatch handler in switch statement that validates arguments using isBranchOptions type guard and calls GitOperations.branchCreate.
    case 'branch_create': {
      const validArgs = this.validateArguments(operation, args, isBranchOptions);
      return await GitOperations.branchCreate(validArgs, context);
    }
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. 'Create a new branch' implies a write operation, but it doesn't disclose critical traits like whether it requires specific permissions, what happens on conflicts (e.g., if the branch exists), side effects (e.g., modifying repository state), or error conditions. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero waste—'Create a new branch' directly conveys the core action without fluff. It's appropriately sized for a simple tool and front-loaded with the essential information, making it easy to parse quickly. Every word earns its place by specifying the verb and resource.

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 of a branch creation tool (a mutation operation with 5 parameters) and no annotations or output schema, the description is incomplete. It lacks information on behavioral traits (e.g., error handling, side effects), usage context (e.g., repository requirements), and output details (e.g., success confirmation or branch details). For a tool that modifies system state, this minimal description is inadequate to ensure safe and correct use.

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 description coverage is 100%, with all 5 parameters well-documented in the input schema (e.g., 'force' allows overriding existing branches, 'path' specifies repository location). The description adds no parameter information beyond what the schema provides, not even hinting at required parameters like 'name'. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but no extra credit is earned.

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 'Create a new branch' clearly states the verb ('Create') and resource ('branch'), making the purpose immediately understandable. It distinguishes this tool from siblings like branch_delete, branch_list, tag_create, etc., which perform different operations on branches or other resources. However, it doesn't specify what type of branch (e.g., Git branch) or provide additional context like the repository scope, which prevents a perfect score.

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 repository), compare it to similar tools like checkout (which might create branches in some contexts), or indicate scenarios where it's appropriate (e.g., starting new features). Without such context, users must infer usage from the tool name alone.

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

Related 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/Sheshiyer/git-mcp-v2'

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