git_checkout
Switch between branches in a Git repository to access different code versions or development lines.
Instructions
Switches branches
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"repo_path": "<repo_path>",
"branch_name": "<branch_name>"
},
"name": "git_checkout"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| branch_name | Yes |
Implementation Reference
- src/mcp_server_git/server.py:125-127 (handler)The main handler function that performs the git checkout operation on the given repository and branch.
def git_checkout(repo: git.Repo, branch_name: str) -> str: repo.git.checkout(branch_name) return f"Switched to branch '{branch_name}'" - src/mcp_server_git/server.py:52-54 (schema)Pydantic model defining the input schema for the git_checkout tool, including repo_path and branch_name.
class GitCheckout(BaseModel): repo_path: str branch_name: str - src/mcp_server_git/server.py:216-220 (registration)Registration of the git_checkout tool in the list_tools handler, using the name from GitTools.CHECKOUT and GitCheckout schema.
Tool( name=GitTools.CHECKOUT, description="Switches branches", inputSchema=GitCheckout.schema(), ), - src/mcp_server_git/server.py:73-73 (registration)Enum value in GitTools defining the tool name 'git_checkout'.
CHECKOUT = "git_checkout"