Skip to main content
Glama
modelcontextprotocol

git MCP server

Official

git_create_branch

Create a new branch in a Git repository, optionally specifying a base branch to branch from.

Instructions

Creates a new branch from an optional base branch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
branch_nameYes
base_branchNo

Implementation Reference

  • Pydantic schema for git_create_branch input: repo_path, branch_name, optional base_branch
    class GitCreateBranch(BaseModel):
        repo_path: str
        branch_name: str
        base_branch: str | None = None
  • Enum value mapping GitTools.CREATE_BRANCH to the string 'git_create_branch'
    CREATE_BRANCH = "git_create_branch"
    CHECKOUT = "git_checkout"
  • Tool registration in list_tools() with schema, description, and annotations
    Tool(
        name=GitTools.CREATE_BRANCH,
        description="Creates a new branch from an optional base branch",
        inputSchema=GitCreateBranch.model_json_schema(),
        annotations=ToolAnnotations(
            readOnlyHint=False,
            destructiveHint=False,
            idempotentHint=False,
            openWorldHint=False,
        ),
    ),
  • Core handler function that creates a branch. Validates names (rejects '-' prefix), resolves base branch or uses active branch, then calls repo.create_head()
    def git_create_branch(repo: git.Repo, branch_name: str, base_branch: str | None = None) -> str:
        # Defense in depth: reject names starting with '-' to prevent flag injection
        if branch_name.startswith("-"):
            raise BadName(f"Invalid branch name: '{branch_name}' - cannot start with '-'")
        if base_branch and base_branch.startswith("-"):
            raise BadName(f"Invalid base branch: '{base_branch}' - cannot start with '-'")
        if base_branch:
            base = repo.references[base_branch]
        else:
            base = repo.active_branch
    
        repo.create_head(branch_name, base)
        return f"Created branch '{branch_name}' from '{base.name}'"
  • Handler dispatch in call_tool() that routes GitTools.CREATE_BRANCH to the git_create_branch function
    case GitTools.CREATE_BRANCH:
        result = git_create_branch(
            repo,
            arguments["branch_name"],
            arguments.get("base_branch")
        )
        return [TextContent(
            type="text",
            text=result
        )]
Behavior2/5

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

Annotations already indicate not read-only and not destructive. The description adds no extra behavioral context, such as error behavior if branch already exists or default base branch behavior.

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 very concise with no wasted words. Could benefit from a slightly more structured format, but remains efficient.

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 simple tool, the description covers the basic purpose but lacks details on default behavior (e.g., what branch is created from if base_branch is null) and error handling. Without an output schema, more explanation of return values would help.

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

Parameters2/5

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

Schema coverage is 0%, but description only clarifies the optional base_branch parameter. repo_path and branch_name are not elaborated beyond their names. The description adds minimal value over the schema.

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 it creates a new branch from an optional base branch, which distinguishes it from siblings like git_branch (listing) and git_checkout (switching). However, it could be more specific about what 'from' means, e.g., 'based on current HEAD if base_branch is omitted'.

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 versus alternatives like git_branch or git_checkout. No when-not or prerequisites provided.

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/modelcontextprotocol/git'

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