Skip to main content
Glama
PhialsBasement

GitHub MCP Server Plus

create_branch

Create a new branch in a GitHub repository by specifying owner, repository name, and branch name, optionally from a source branch.

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

  • Dispatcher handler for the "create_branch" tool: parses input arguments using the schema and calls the branches.createBranchFromRef function to execute the tool logic.
    case "create_branch": {
      const args = branches.CreateBranchSchema.parse(request.params.arguments);
      const branch = await branches.createBranchFromRef(
        args.owner,
        args.repo,
        args.branch,
        args.from_branch
      );
      return {
        content: [{ type: "text", text: JSON.stringify(branch, null, 2) }],
      };
    }
  • Primary handler function implementing the create_branch tool logic: determines the SHA of the source branch (or default), then calls createBranch to perform the GitHub API call.
    export async function createBranchFromRef(
      owner: string,
      repo: string,
      newBranch: string,
      fromBranch?: string
    ): Promise<z.infer<typeof GitHubReferenceSchema>> {
      let sha: string;
      if (fromBranch) {
        sha = await getBranchSHA(owner, repo, fromBranch);
      } else {
        sha = await getDefaultBranchSHA(owner, repo);
      }
    
      return createBranch(owner, repo, {
        ref: newBranch,
        sha,
      });
    }
  • Core helper function that executes the GitHub API POST request to create a new git reference (branch).
    export async function createBranch(
      owner: string,
      repo: string,
      options: CreateBranchOptions
    ): Promise<z.infer<typeof GitHubReferenceSchema>> {
      const fullRef = `refs/heads/${options.ref}`;
    
      const response = await githubRequest(
        `https://api.github.com/repos/${owner}/${repo}/git/refs`,
        {
          method: "POST",
          body: {
            ref: fullRef,
            sha: options.sha,
          },
        }
      );
    
      return GitHubReferenceSchema.parse(response);
    }
  • Zod schema defining the input parameters for the create_branch tool, used for validation in the handler and tool 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)"),
    });

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Create') which implies a write operation, but doesn't mention permission requirements, rate limits, whether the branch becomes active immediately, or what happens on failure. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 gets straight to the point with no wasted words. It's appropriately sized for a straightforward tool and front-loads the essential information.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't address authentication requirements, error conditions, what the tool returns, or how it differs from related operations. The 100% schema coverage helps with parameters, but overall context for safe and effective use is lacking.

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 schema description coverage is 100%, so all parameters are documented in the schema. The description doesn't add any parameter-specific information beyond what's in the schema. This meets the baseline expectation when the schema does the heavy lifting, but doesn't provide additional context about parameter relationships 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') and resource ('new branch in a GitHub repository'), making the purpose immediately understandable. It doesn't specifically differentiate from sibling tools like 'fork_repository' or 'create_pull_request' which also involve branch-like operations, but it's sufficiently specific for basic understanding.

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 (like authentication needs), when not to use it, or how it relates to sibling tools like 'create_pull_request' or 'fork_repository' which might be alternatives for certain scenarios.

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