git_create_branch
Create a new Git branch from a specified base branch to organize development work and isolate 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
- src/mcp_server_git/server.py:116-123 (handler)The core handler function implementing the git_create_branch tool logic using gitpython to create a new branch 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}'"
- src/mcp_server_git/server.py:47-50 (schema)Pydantic model defining the input schema for the git_create_branch tool, including repo_path, branch_name, and optional base_branch.class GitCreateBranch(BaseModel): repo_path: str branch_name: str base_branch: str | None = None
- src/mcp_server_git/server.py:211-215 (registration)Registration of the git_create_branch tool in the MCP server's list_tools method, specifying name, description, and input schema.Tool( name=GitTools.CREATE_BRANCH, description="Creates a new branch from an optional base branch", inputSchema=GitCreateBranch.schema(), ),
- src/mcp_server_git/server.py:72-72 (registration)Enum definition providing the string name 'git_create_branch' used for tool registration.CREATE_BRANCH = "git_create_branch"