Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_branch

Manage Git branches by listing existing ones, creating new branches, deleting unwanted branches, or renaming branches to organize your repository workflow.

Instructions

List, create, delete, or rename branches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoRepository directory
actionNoBranch actionlist
nameNoBranch name (required for create/delete/rename)
newNameNoNew branch name (required for rename)
forceNoForce delete or creation
remoteNoList remote branches

Implementation Reference

  • The main handler function that implements the git_branch tool logic. It handles list, create, delete, and rename actions for git branches using the executeGitCommand helper.
    export async function gitBranch(args: z.infer<typeof gitBranchSchema>): Promise<ToolResponse> {
      switch (args.action) {
        case 'list':
          const remoteFlag = args.remote ? '-r' : '-a';
          return executeGitCommand(`git branch ${remoteFlag}`, args.cwd);
        case 'create':
          if (!args.name) {
            return {
              content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Branch name required for create action' }, null, 2) }],
              isError: true
            };
          }
          return executeGitCommand(`git branch ${args.name}`, args.cwd);
        case 'delete':
          if (!args.name) {
            return {
              content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Branch name required for delete action' }, null, 2) }],
              isError: true
            };
          }
          const deleteFlag = args.force ? '-D' : '-d';
          return executeGitCommand(`git branch ${deleteFlag} ${args.name}`, args.cwd);
        case 'rename':
          if (!args.name || !args.newName) {
            return {
              content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Both name and newName required for rename action' }, null, 2) }],
              isError: true
            };
          }
          return executeGitCommand(`git branch -m ${args.name} ${args.newName}`, args.cwd);
        default:
          return {
            content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Invalid branch action' }, null, 2) }],
            isError: true
          };
      }
    }
  • Zod schema used for input validation of the git_branch tool parameters.
    export const gitBranchSchema = z.object({
      cwd: z.string().optional().describe('Repository directory'),
      action: z.enum(['list', 'create', 'delete', 'rename']).optional().default('list').describe('Branch action'),
      name: z.string().optional().describe('Branch name (required for create/delete/rename)'),
      newName: z.string().optional().describe('New branch name (required for rename)'),
      force: z.boolean().optional().default(false).describe('Force delete or creation'),
      remote: z.boolean().optional().default(false).describe('List remote branches')
    });
  • MCP tool registration definition in the gitTools array, including the tool name, description, and input schema advertised to clients.
    {
      name: 'git_branch',
      description: 'List, create, delete, or rename branches',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: { type: 'string', description: 'Repository directory' },
          action: { type: 'string', enum: ['list', 'create', 'delete', 'rename'], default: 'list', description: 'Branch action' },
          name: { type: 'string', description: 'Branch name (required for create/delete/rename)' },
          newName: { type: 'string', description: 'New branch name (required for rename)' },
          force: { type: 'boolean', default: false, description: 'Force delete or creation' },
          remote: { type: 'boolean', default: false, description: 'List remote branches' }
        }
      }
    },
  • src/index.ts:377-379 (registration)
    Dispatch/registration logic in the main MCP server handler that routes calls to the git_branch tool by name, validates input, and invokes the handler.
    if (name === 'git_branch') {
      const validated = gitBranchSchema.parse(args);
      return await gitBranch(validated);
  • Shared helper function used by gitBranch (and all git tools) to execute git commands and format responses.
    async function executeGitCommand(command: string, cwd?: string): Promise<ToolResponse> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: cwd || process.cwd(),
          shell: '/bin/bash',
          maxBuffer: 10 * 1024 * 1024 // 10MB buffer
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: true,
                command: command,
                stdout: stdout.trim(),
                stderr: stderr.trim(),
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: false,
                command: command,
                stdout: error.stdout?.trim() || '',
                stderr: error.stderr?.trim() || error.message,
                exitCode: error.code || 1,
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
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 only lists actions without behavioral details. It doesn't disclose permission requirements, side effects (e.g., deletion permanence), error conditions, or output format. For a multi-action tool with potential destructive operations, this is a significant gap in transparency.

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 extremely concise and front-loaded with a single, clear phrase listing all actions. Every word earns its place with zero wasted text, making it easy to scan and understand at a glance.

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 complex tool with 6 parameters, multiple actions (including destructive ones), no annotations, and no output schema, the description is inadequate. It doesn't explain return values, error handling, or behavioral nuances needed for safe and effective use, leaving significant gaps in context.

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%, providing good parameter documentation. The description adds no additional parameter semantics beyond implying the tool handles branch operations, which the schema already covers through the action enum and parameter descriptions. Baseline 3 is appropriate as the schema does the heavy lifting.

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 tool's purpose with specific verbs (list, create, delete, rename) and resource (branches), making it immediately understandable. However, it doesn't differentiate from sibling git tools like git_checkout or git_merge, which also work with branches, so it misses full sibling differentiation.

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?

No guidance is provided on when to use this tool versus alternatives. The description lists actions but doesn't indicate prerequisites, when to choose create vs. checkout, or how it relates to sibling tools like git_checkout for switching branches or git_merge for branch integration.

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/ConnorBoetig-dev/mcp2'

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