Skip to main content
Glama

get_branch_overview

Analyze and visualize branch states and relationships in a Git repository to understand development workflows and dependencies.

Instructions

Get high-level overview of branch states and relationships

Input Schema

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

Implementation Reference

  • The primary handler function for the 'get_branch_overview' tool. It computes last commit, commit count, and merge bases for each branch, generates a summary, writes the analysis as JSON 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)
    Registers the 'get_branch_overview' tool in the MCP server's listTools response, providing 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 handler.
    interface BranchOverviewArgs { repoPath: string; branches: string[]; outputPath: string; }
  • Dispatch handler in the CallToolRequestSchema that validates arguments and calls the main handleBranchOverview 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 that generates a summary of branch activity statistics used in the branch overview analysis.
    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, }; }

Other Tools

Related 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