Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
branch_nameYes
repo_pathYes

Implementation Reference

  • 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}'"
  • 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
  • Tool registration in the list_tools() function, specifying name, description, and input schema.
    Tool( name=GitTools.CHECKOUT, description="Switches branches", inputSchema=GitCheckout.schema(), ),
  • 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 )]
  • Enum value defining the tool name constant GitTools.CHECKOUT.
    CHECKOUT = "git_checkout"

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