Skip to main content
Glama

get_merge_recommendations

Analyze git repository branches to generate targeted merge strategy recommendations, aiding in efficient and informed repository management decisions.

Instructions

Get detailed merge strategy recommendations

Input Schema

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

Implementation Reference

  • Core handler function that executes the get_merge_recommendations tool logic: computes strategy, risks, steps using helpers, writes JSON output, and returns success message.
    private async handleMergeRecommendations(args: MergeRecommendationsArgs) { const recommendations = { strategy: this.determineMergeStrategy(args.repoPath, args.branches), conflictRisks: this.assessConflictRisks(args.repoPath, args.branches), steps: this.generateMergeSteps(args.repoPath, args.branches), }; writeFileSync(args.outputPath, JSON.stringify(recommendations, null, 2)); return { content: [ { type: 'text', text: `Merge recommendations written to ${args.outputPath}`, }, ], };
  • src/index.ts:153-175 (registration)
    Registration of the tool in ListToolsRequestSchema handler, including name, description, and JSON input schema.
    { name: 'get_merge_recommendations', description: 'Get detailed merge strategy recommendations', 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 parameters for the merge recommendations tool.
    interface MergeRecommendationsArgs { repoPath: string; branches: string[]; outputPath: string; }
  • Dispatch handler case within CallToolRequestSchema that validates arguments and invokes the main handler.
    case 'get_merge_recommendations': { const args = request.params.arguments as MergeRecommendationsArgs; if (!args?.repoPath || !args?.branches || !args?.outputPath) { throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters'); } return await this.handleMergeRecommendations(args); }
  • Helper function called by handler to determine the recommended merge strategy based on branch commit counts.
    private determineMergeStrategy(repoPath: string, branches: string[]) { const commitCounts = branches.map(branch => ({ branch, count: this.getCommitCount(repoPath, branch), })); const baseChoice = commitCounts.reduce((a, b) => a.count > b.count ? a : b ); return { recommendedBase: baseChoice.branch, approach: 'cherry-pick', reasoning: [ `${baseChoice.branch} has the most changes (${baseChoice.count} commits)`, 'Cherry-pick approach allows for selective integration', ], }; }

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