Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_checkout_branch

Switch to or create a Git branch in a local repository to manage code changes and isolate development work.

Instructions

Create and/or checkout a branch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
branch_nameYesThe name of the branch to checkout
start_pointNoStarting point for the branch (optional)
createNoWhether to create a new branch

Implementation Reference

  • The core handler function that executes the git checkout branch logic using simpleGit. Handles both creating new branches and switching to existing ones.
    export async function handleGitCheckoutBranch({
      repo_path,
      branch_name,
      start_point = null,
      create = false,
    }) {
      try {
        const git = simpleGit(repo_path);
    
        if (create) {
          // Create and checkout a new branch
          if (start_point) {
            await git.checkoutBranch(branch_name, start_point);
          } else {
            await git.checkoutLocalBranch(branch_name);
          }
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    success: true,
                    message: `Created and checked out new branch: ${branch_name}`,
                    branch: branch_name,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } else {
          // Just checkout an existing branch
          await git.checkout(branch_name);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    success: true,
                    message: `Checked out branch: ${branch_name}`,
                    branch: branch_name,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to checkout branch: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema definition for the git_checkout_branch tool, including parameters, descriptions, and validation rules.
      name: "git_checkout_branch",
      description: "Create and/or checkout a branch.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          branch_name: {
            type: "string",
            description: "The name of the branch to checkout",
          },
          start_point: {
            type: "string",
            description: "Starting point for the branch (optional)",
          },
          create: {
            type: "boolean",
            description: "Whether to create a new branch",
            default: false,
          },
        },
        required: ["repo_path", "branch_name"],
      },
    },
  • src/server.js:909-909 (registration)
    Registration of the handler function in the main handlersMap object used by the MCP server to dispatch tool calls.
    git_checkout_branch: handleGitCheckoutBranch,
  • Re-export of the handler from branch-operations.js in the handlers index module, making it available for import in server.js.
    handleGitCheckoutBranch,
  • Alias registration allowing 'git_checkout' as an alternative name for the git_checkout_branch tool.
    git_checkout: "git_checkout_branch",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral context. It mentions creation and checkout but doesn't disclose critical traits: whether it's destructive (e.g., discarding uncommitted changes), authentication needs, error conditions (e.g., branch already exists), or side effects. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action ('Create and/or checkout'), making it easy to parse. Every word earns its place, and there's no redundant or verbose phrasing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a mutation tool with 4 parameters, the description is incomplete. It lacks behavioral details (e.g., what happens on failure), output expectations, or error handling. For a Git operation that can alter repository state, this leaves significant gaps for an AI agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no meaning beyond the schema—it doesn't explain interactions (e.g., how 'create' and 'start_point' relate) or provide examples. Baseline 3 is appropriate since the schema does the heavy lifting, but the description doesn't compensate with additional insights.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Create and/or checkout a branch' clearly states the tool's purpose with specific verbs (create, checkout) and resource (branch). It distinguishes from siblings like git_merge_branch or git_delete_branch by focusing on branch switching/creation, but doesn't explicitly differentiate from git_branch_diff or git_reset which might involve branches indirectly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a clean working directory), when to prefer git_switch or git_checkout for specific Git versions, or how it relates to siblings like git_merge_branch for branch operations. Usage is implied but not articulated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/bsreeram08/git-commands-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server