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
| Name | Required | Description | Default |
|---|---|---|---|
| branches | Yes | Branches to analyze | |
| outputPath | Yes | Path to write analysis output | |
| repoPath | Yes | Path to git repository |
Implementation Reference
- src/index.ts:325-341 (handler)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'], }, },
- src/index.ts:37-41 (schema)TypeScript interface defining the input parameters for the merge recommendations tool.interface MergeRecommendationsArgs { repoPath: string; branches: string[]; outputPath: string; }
- src/index.ts:203-209 (handler)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); }
- src/index.ts:472-490 (helper)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', ], }; }