Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_merge_branch

Merge a source branch into the current or target Git branch to integrate changes from development work into another branch.

Instructions

Merge a source branch into the current or target branch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
source_branchYesBranch to merge from
target_branchNoBranch to merge into (optional, uses current branch if not provided)
no_fast_forwardNoWhether to create a merge commit even if fast-forward is possible

Implementation Reference

  • The handler function that executes the git merge operation using simpleGit, handling checkout if target branch specified, merge options, and error handling with conflict reporting.
    export async function handleGitMergeBranch({
      repo_path,
      source_branch,
      target_branch = null,
      no_fast_forward = false,
    }) {
      try {
        const git = simpleGit(repo_path);
    
        // If target branch is specified, checkout to it first
        if (target_branch) {
          await git.checkout(target_branch);
        }
    
        // Perform the merge
        let mergeOptions = [];
        if (no_fast_forward) {
          mergeOptions = ["--no-ff"];
        }
    
        const mergeResult = await git.merge([...mergeOptions, source_branch]);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: true,
                  result: mergeResult,
                  message: `Merged ${source_branch} into ${
                    target_branch || "current branch"
                  }`,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  error: `Failed to merge branches: ${error.message}`,
                  conflicts: error.git ? error.git.conflicts : null,
                },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Defines the input schema, parameters, and description for the git_merge_branch tool used in tool listing and validation.
    {
      name: "git_merge_branch",
      description: "Merge a source branch into the current or target branch.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          source_branch: {
            type: "string",
            description: "Branch to merge from",
          },
          target_branch: {
            type: "string",
            description:
              "Branch to merge into (optional, uses current branch if not provided)",
          },
          no_fast_forward: {
            type: "boolean",
            description:
              "Whether to create a merge commit even if fast-forward is possible",
            default: false,
          },
        },
        required: ["repo_path", "source_branch"],
      },
    },
  • src/server.js:911-911 (registration)
    Maps the tool name 'git_merge_branch' to its handler function handleGitMergeBranch in the central handlersMap for request dispatching.
    git_merge_branch: handleGitMergeBranch,
  • Re-exports the handleGitMergeBranch function from branch-operations.js for convenient import in server.js.
    handleGitMergeBranch,
  • src/server.js:22-22 (registration)
    Imports the handleGitMergeBranch handler from handlers/index.js.
    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 merging but doesn't cover critical aspects like whether it requires authentication, potential conflicts and how they're handled, whether it's destructive to existing commits, rate limits, or what happens on failure. For a mutation tool with zero annotation coverage, this is a significant gap.

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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with zero wasted information.

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 mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens during conflicts, whether it creates merge commits by default, what the return value or success/failure indicators are, or how it interacts with other Git operations. Given the complexity of merging, more context is needed.

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 already fully documents all 4 parameters. The description doesn't add any semantic meaning beyond what's in the schema (e.g., it doesn't explain merge strategies or conflict resolution related to parameters). Baseline 3 is appropriate when 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 action ('merge') and resources ('source branch into the current or target branch'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like git_rebase or git_pull, which also involve branch integration, leaving some ambiguity about when this specific merge operation is preferred.

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_rebase or git_pull, nor does it mention prerequisites (e.g., clean working directory) or exclusions. 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