Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_branch_diff

Compare two Git branches to identify files changed between them. Use this tool to analyze differences in code, track modifications, and review changes before merging branches in a repository.

Instructions

Compare two branches and show files changed between them.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_urlYesThe URL of the Git repository
source_branchYesThe source branch name
target_branchYesThe target branch name
show_patchNoWhether to include the actual diff patches

Implementation Reference

  • The main handler function that executes the git_branch_diff tool. It clones the repository, ensures branches are available, computes the diff between source and target branches (with optional patch), gets commit count, and returns a JSON-formatted result or error.
    export async function handleGitBranchDiff({
      repo_url,
      source_branch,
      target_branch,
      show_patch = false,
    }) {
      try {
        const repoPath = await cloneRepo(repo_url);
        const git = simpleGit(repoPath);
    
        // Make sure both branches exist locally
        const branches = await git.branch();
        if (!branches.all.includes(source_branch)) {
          await git.fetch("origin", source_branch);
          await git.checkout(source_branch);
        }
    
        if (!branches.all.includes(target_branch)) {
          await git.fetch("origin", target_branch);
        }
    
        // Get the diff between branches
        const diffOptions = ["--name-status"];
        if (show_patch) {
          diffOptions.push("--patch");
        }
    
        const diff = await git.diff([
          ...diffOptions,
          `${target_branch}...${source_branch}`,
        ]);
    
        // Get commit range information
        const logSummary = await git.log({
          from: target_branch,
          to: source_branch,
        });
    
        const result = {
          commits_count: logSummary.total,
          diff_summary: diff,
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to get branch diff: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
  • The MCP tool schema definition for 'git_branch_diff', including description and input schema with properties repo_url, source_branch, target_branch, and optional show_patch.
    name: "git_branch_diff",
    description:
      "Compare two branches and show files changed between them.",
    inputSchema: {
      type: "object",
      properties: {
        repo_url: {
          type: "string",
          description: "The URL of the Git repository",
        },
        source_branch: {
          type: "string",
          description: "The source branch name",
        },
        target_branch: {
          type: "string",
          description: "The target branch name",
        },
        show_patch: {
          type: "boolean",
          description: "Whether to include the actual diff patches",
          default: false,
        },
      },
      required: ["repo_url", "source_branch", "target_branch"],
    },
  • src/server.js:902-902 (registration)
    Registers the tool name 'git_branch_diff' mapped to the handleGitBranchDiff handler function in the server's handlersMap.
    git_branch_diff: handleGitBranchDiff,
  • Imports the handleGitBranchDiff handler from branch-operations.js into the handlers index module, facilitating its use in the server.
    import {
      handleGitBranchDiff,
      handleGitCheckoutBranch,
      handleGitDeleteBranch,
      handleGitMergeBranch,
    } from "./branch-operations.js";
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions comparing branches and showing changed files, but doesn't cover critical aspects like whether this is a read-only operation, potential side effects, authentication needs, rate limits, or output format. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 function without unnecessary words. It's front-loaded with the core purpose and avoids redundancy, making it easy to parse quickly.

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 the complexity of Git operations and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., list of files, diff details), error conditions, or how it interacts with other tools. For a tool with 4 parameters and no structured behavioral hints, more context is needed to ensure proper usage.

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 input schema fully documents all parameters (repo_url, source_branch, target_branch, show_patch). The description adds no additional parameter semantics beyond implying a comparison between two branches, which is already clear from the schema. 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 tool's purpose: 'Compare two branches and show files changed between them.' It specifies the verb 'compare' and resource 'branches' with the outcome 'show files changed.' However, it doesn't explicitly differentiate from sibling tools like git_merge_branch or git_rebase, which might also involve branch comparisons, keeping it from 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. With many sibling tools available (e.g., git_merge_branch, git_rebase, git_commit_history), there's no indication of specific use cases, prerequisites, or exclusions. This lack of context makes it harder for an AI agent to select this tool appropriately.

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