Skip to main content
Glama
davidorex

Git Forensics MCP

by davidorex

get_branch_overview

Analyze git branch states and relationships to understand repository structure and track development progress across specified branches.

Instructions

Get high-level overview of branch states and relationships

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoPathYesPath to git repository
branchesYesBranches to analyze
outputPathYesPath to write analysis output

Implementation Reference

  • The main handler function that executes the get_branch_overview tool logic. It computes last commit info, commit counts, merge bases between branches, generates an overview summary, writes JSON analysis to the output path, and returns a success message.
    private async handleBranchOverview(args: BranchOverviewArgs) {
      const overview = args.branches.map(branch => {
        const lastCommit = this.getLastCommit(args.repoPath, branch);
        const commitCount = this.getCommitCount(args.repoPath, branch);
        const mergeBase = args.branches.map(otherBranch => {
          if (otherBranch === branch) return null;
          return {
            branch: otherBranch,
            base: this.getMergeBase(args.repoPath, branch, otherBranch),
          };
        }).filter((base): base is NonNullable<typeof base> => base !== null);
    
        return {
          branch,
          lastCommit,
          commitCount,
          mergeBase,
        };
      });
    
      const analysis = {
        overview,
        summary: this.generateOverviewSummary(overview),
      };
    
      writeFileSync(args.outputPath, JSON.stringify(analysis, null, 2));
    
      return {
        content: [
          {
            type: 'text',
            text: `Branch analysis written to ${args.outputPath}`,
          },
        ],
      };
    }
  • src/index.ts:71-93 (registration)
    Registration of the get_branch_overview tool in the ListTools response, including name, description, and input schema.
    {
      name: 'get_branch_overview',
      description: 'Get high-level overview of branch states and relationships',
      inputSchema: {
        type: 'object',
        properties: {
          repoPath: {
            type: 'string',
            description: 'Path to git repository',
          },
          branches: {
            type: 'array',
            items: { type: 'string' },
            description: 'Branches to analyze',
          },
          outputPath: {
            type: 'string',
            description: 'Path to write analysis output',
          },
        },
        required: ['repoPath', 'branches', 'outputPath'],
      },
    },
  • TypeScript interface defining the input arguments for the get_branch_overview tool, used for type validation.
    interface BranchOverviewArgs {
      repoPath: string;
      branches: string[];
      outputPath: string;
    }
  • src/index.ts:182-188 (registration)
    Dispatch case in CallToolRequestSchema handler that validates input and calls the get_branch_overview handler function.
    case 'get_branch_overview': {
      const args = request.params.arguments as BranchOverviewArgs;
      if (!args?.repoPath || !args?.branches || !args?.outputPath) {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters');
      }
      return await this.handleBranchOverview(args);
    }
  • Helper function called by the handler to generate a summary of branch activity statistics.
    private generateOverviewSummary(overview: Array<{ branch: string; commitCount: number }>) {
      const totalCommits = overview.reduce((sum, { commitCount }) => sum + commitCount, 0);
      const avgCommits = totalCommits / overview.length;
    
      return {
        totalBranches: overview.length,
        totalCommits,
        averageCommitsPerBranch: Math.round(avgCommits),
        mostActiveBranch: overview.reduce((a, b) => 
          a.commitCount > b.commitCount ? a : b
        ).branch,
      };
    }
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 'Get' and 'write analysis output' (via outputPath), implying read and write operations, but doesn't specify if this is safe, requires permissions, or has side effects like file creation. Critical details like error handling or output format are missing, leaving gaps in understanding the tool's 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 purpose without unnecessary words. It's front-loaded and appropriately sized, making it easy to grasp 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 a git analysis tool with three parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'high-level overview' entails, how output is formatted, or any behavioral traits like file writing implications. This leaves significant gaps for an AI agent to use the tool effectively.

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 documents all three parameters (repoPath, branches, outputPath) with clear descriptions. The description adds no additional meaning beyond the schema, such as explaining relationships between parameters or usage nuances. 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 verb ('Get') and resource ('high-level overview of branch states and relationships'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'analyze_file_changes' or 'get_merge_recommendations', which also seem to analyze git repositories but focus on different aspects.

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 lacks context about prerequisites, such as needing a valid git repository, or exclusions, like not handling specific branch states. It doesn't reference sibling tools or suggest scenarios where this tool is preferred.

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/davidorex/git-forensics-mcp'

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