Skip to main content
Glama

create_branch

Create a new branch in a GitHub repository by specifying owner, repo, and branch name, with optional source branch selection.

Instructions

Create a new branch in a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
repoYesRepository name
branchYesName for the new branch
from_branchNoOptional: source branch to create from (defaults to the repository's default branch)

Implementation Reference

  • Core handler function that implements the branch creation logic by resolving the source SHA and calling the low-level createBranch API.
    export async function createBranchFromRef(
      github_pat: string,
      owner: string,
      repo: string,
      newBranch: string,
      fromBranch?: string
    ): Promise<z.infer<typeof GitHubReferenceSchema>> {
      let sha: string;
      if (fromBranch) {
        sha = await getBranchSHA(github_pat, owner, repo, fromBranch);
      } else {
        sha = await getDefaultBranchSHA(github_pat, owner, repo);
      }
    
      return createBranch(github_pat, owner, repo, {
        ref: newBranch,
        sha,
      });
    }
  • src/index.ts:118-122 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema.
    {
      name: "create_branch",
      description: "Create a new branch in a GitHub repository",
      inputSchema: zodToJsonSchema(branches.CreateBranchSchema),
    },
  • Tool dispatch handler in the CallToolRequest switch statement that validates input and invokes the core createBranchFromRef function.
    case "create_branch": {
      const args = branches._CreateBranchSchema.parse(params.arguments);
      const branch = await branches.createBranchFromRef(
        args.github_pat,
        args.owner,
        args.repo,
        args.branch,
        args.from_branch
      );
      return {
        content: [{ type: "text", text: JSON.stringify(branch, null, 2) }],
      };
    }
  • Primary input schema definition for the create_branch tool, referenced in registration.
    export const CreateBranchSchema = z.object({
      owner: z.string().describe("Repository owner (username or organization)"),
      repo: z.string().describe("Repository name"),
      branch: z.string().describe("Name for the new branch"),
      from_branch: z.string().optional().describe("Optional: source branch to create from (defaults to the repository's default branch)"),
    });
  • Low-level helper function that performs the actual GitHub API call to create a branch ref.
    export async function createBranch(
      github_pat: string,
      owner: string,
      repo: string,
      options: CreateBranchOptions
    ): Promise<z.infer<typeof GitHubReferenceSchema>> {
      const fullRef = `refs/heads/${options.ref}`;
    
      const response = await githubRequest(
        github_pat,
        `https://api.github.com/repos/${owner}/${repo}/git/refs`,
        {
          method: "POST",
          body: {
            ref: fullRef,
            sha: options.sha,
          },
        }
      );
    
      return GitHubReferenceSchema.parse(response);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('Create') but lacks critical details: whether this requires specific permissions, if it's idempotent, what happens on duplicate branch names, error conditions, or rate limits. The description is minimal and misses key behavioral traits.

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, clear sentence with zero waste. It's front-loaded and efficiently conveys the core purpose without unnecessary elaboration. Every word earns its place.

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 annotations, no output schema, and a mutation tool with 4 parameters, the description is incomplete. It lacks behavioral context (permissions, idempotency), output expectations, and error handling. For a creation tool in GitHub's API, this leaves significant gaps for an agent.

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%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema. Baseline 3 is appropriate when the schema does the heavy lifting, though no extra value is added.

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') and resource ('new branch in a GitHub repository'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'create_repository' or 'create_tag', but the specificity of 'branch' provides reasonable distinction. No tautology is present.

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., authentication needs, repository access), nor does it contrast with related tools like 'fork_repository' or 'create_tag'. Usage context is implied but not 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/MissionSquad/mcp-github'

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