Skip to main content
Glama

git_create_branch

Create a new Git branch from a specified or default base branch. Use this tool to manage repository branching directly through the MCP Git Server, ensuring efficient workflow organization.

Instructions

Creates a new branch from an optional base branch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_branchNo
branch_nameYes
repo_pathYes

Implementation Reference

  • The handler function that implements the core logic of creating a new Git branch, either from a specified base branch or the current active branch.
    def git_create_branch(repo: git.Repo, branch_name: str, base_branch: str | None = None) -> str: if base_branch: base = repo.refs[base_branch] else: base = repo.active_branch repo.create_head(branch_name, base) return f"Created branch '{branch_name}' from '{base.name}'"
  • Pydantic BaseModel defining the input schema (parameters) for the git_create_branch tool.
    class GitCreateBranch(BaseModel): repo_path: str branch_name: str base_branch: str | None = None
  • Registration of the git_create_branch tool within the list_tools() function, specifying name, description, and input schema.
    Tool( name=GitTools.CREATE_BRANCH, description="Creates a new branch from an optional base branch", inputSchema=GitCreateBranch.schema(), ),
  • Enum value defining the tool name constant 'git_create_branch' in GitTools.
    CREATE_BRANCH = "git_create_branch"

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/martinsky999/mcp-git-py'

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