git_create_branch
Create a new Git branch from a specified base branch to organize development work and manage code changes in a repository.
Instructions
Creates a new branch from an optional base branch
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| branch_name | Yes | ||
| base_branch | No |
Implementation Reference
- The core handler function implementing the git_create_branch tool logic using GitPython to create a new branch.def git_create_branch(repo: git.Repo, branch_name: str, base_branch: str | None = None) -> str: 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}'"
- 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
- src/git/src/mcp_server_git/server.py:327-331 (registration)MCP tool registration in the server's list_tools method, associating the name, description, and schema.Tool( name=GitTools.CREATE_BRANCH, description="Creates a new branch from an optional base branch", inputSchema=GitCreateBranch.model_json_schema(), ),
- src/git/src/mcp_server_git/server.py:104-104 (registration)Enum value defining the tool name constant used in registration.CREATE_BRANCH = "git_create_branch"