Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_delete_branch

Remove a branch from a Git repository to clean up your project's branch structure. Specify the repository path and branch name to delete it.

Instructions

Delete a branch from the repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
branch_nameYesThe name of the branch to delete
forceNoWhether to force deletion

Implementation Reference

  • Core handler function that implements the git_delete_branch tool. Validates input, checks if branch is current, deletes using simpleGit, and returns structured MCP response.
    export async function handleGitDeleteBranch({
      repo_path,
      branch_name,
      force = false,
    }) {
      try {
        const git = simpleGit(repo_path);
    
        // Get current branch to prevent deleting the active branch
        const currentBranch = await git.branch();
        if (currentBranch.current === branch_name) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  { error: "Cannot delete the currently checked out branch" },
                  null,
                  2
                ),
              },
            ],
            isError: true,
          };
        }
    
        // Delete the branch
        if (force) {
          await git.deleteLocalBranch(branch_name, true);
        } else {
          await git.deleteLocalBranch(branch_name);
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: true,
                  message: `Deleted branch: ${branch_name}`,
                  branch: branch_name,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to delete branch: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition and description for the git_delete_branch tool, included in the toolsList for MCP tool discovery.
      name: "git_delete_branch",
      description: "Delete a branch from the repository.",
      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 delete",
          },
          force: {
            type: "boolean",
            description: "Whether to force deletion",
            default: false,
          },
        },
        required: ["repo_path", "branch_name"],
      },
    },
  • src/server.js:910-910 (registration)
    Registers the git_delete_branch tool name to its handler function in the server's handlersMap object for fast request dispatching.
    git_delete_branch: handleGitDeleteBranch,
  • Imports the handleGitDeleteBranch handler from branch-operations.js into the handlers index module.
    import {
      handleGitBranchDiff,
      handleGitCheckoutBranch,
      handleGitDeleteBranch,
      handleGitMergeBranch,
    } from "./branch-operations.js";
  • Re-exports handleGitDeleteBranch from the handlers index module for convenient import in server.js.
    handleGitBranchDiff,
    handleGitCheckoutBranch,
    handleGitDeleteBranch,
    handleGitMergeBranch,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions deletion but fails to explain critical behaviors: whether deletion is permanent, if it affects remote repositories, what happens to unmerged changes, or error conditions like trying to delete a protected branch. This leaves significant gaps for a destructive operation.

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, direct sentence with zero wasted words. It front-loads the core action and resource efficiently, making it easy to parse quickly without unnecessary elaboration.

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?

For a destructive tool with no annotations and no output schema, the description is insufficient. It doesn't cover behavioral risks, return values, or error handling, leaving the agent under-informed about the implications of using this tool in a Git workflow.

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 the schema fully documents all three parameters (repo_path, branch_name, force). The description adds no additional meaning beyond the schema, such as explaining when to use 'force' or format examples for branch names. This meets the baseline for high schema coverage.

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 clearly states the action ('Delete') and resource ('a branch from the repository'), making the purpose immediately understandable. It doesn't differentiate from sibling tools like git_branch_diff or git_merge_branch, which prevents a perfect score.

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 like git_reset or git_revert, nor does it mention prerequisites such as ensuring the branch isn't currently checked out. It simply states what the tool does without contextual usage information.

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