git_checkout
Switch Git repository branches with specified repo path and branch name using the MCP Git Server, enabling efficient branch management for LLMs.
Instructions
Switches branches
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch_name | Yes | ||
| repo_path | Yes |
Input Schema (JSON Schema)
{
"properties": {
"branch_name": {
"title": "Branch Name",
"type": "string"
},
"repo_path": {
"title": "Repo Path",
"type": "string"
}
},
"required": [
"repo_path",
"branch_name"
],
"title": "GitCheckout",
"type": "object"
}
Implementation Reference
- src/mcp_server_git/server.py:125-127 (handler)The core handler function that performs the git checkout operation using the git library and returns a success message.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 parameters (repo_path and branch_name) for the git_checkout tool.class GitCheckout(BaseModel): repo_path: str branch_name: str
- src/mcp_server_git/server.py:216-220 (registration)Tool registration in the list_tools() function, specifying name, description, and input schema.Tool( name=GitTools.CHECKOUT, description="Switches branches", inputSchema=GitCheckout.schema(), ),
- src/mcp_server_git/server.py:345-350 (helper)The match case in the call_tool dispatcher that extracts arguments and calls the git_checkout handler.case GitTools.CHECKOUT: result = git_checkout(repo, arguments["branch_name"]) return [TextContent( type="text", text=result )]
- src/mcp_server_git/server.py:73-73 (registration)Enum value defining the tool name constant GitTools.CHECKOUT.CHECKOUT = "git_checkout"