Skip to main content
Glama

analyze_file_changes

Track and compare file changes across branches in a Git repository. Input repository path, branches, and files to analyze, and generate detailed output for review and insights.

Instructions

Analyze changes to specific files across branches

Input Schema

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

Implementation Reference

  • The primary handler function that implements the core logic for the 'analyze_file_changes' tool. It maps over files and branches to gather change history using getFileHistory, analyzes conflicts, generates a summary, writes results to outputPath, and returns a success message.
    private async handleFileChangesAnalysis(args: FileChangesArgs) { const analysis = args.files.map(file => { const changes = args.branches.map(branch => ({ branch, history: this.getFileHistory(args.repoPath, branch, file), })); return { file, changes, conflicts: this.analyzeConflicts(changes), }; }); const result = { analysis, summary: this.generateFileChangesSummary(analysis), }; writeFileSync(args.outputPath, JSON.stringify(result, null, 2)); return { content: [ { type: 'text', text: `File changes analysis written to ${args.outputPath}`, }, ], }; }
  • src/index.ts:125-152 (registration)
    Tool registration in the ListTools response, including name, description, and input schema definition.
    { name: 'analyze_file_changes', description: 'Analyze changes to specific files across branches', inputSchema: { type: 'object', properties: { repoPath: { type: 'string', description: 'Path to git repository', }, branches: { type: 'array', items: { type: 'string' }, description: 'Branches to analyze', }, files: { type: 'array', items: { type: 'string' }, description: 'Files to analyze', }, outputPath: { type: 'string', description: 'Path to write analysis output', }, }, required: ['repoPath', 'branches', 'files', 'outputPath'], }, },
  • TypeScript interface defining the input arguments for the analyze_file_changes tool, matching the inputSchema.
    interface FileChangesArgs { repoPath: string; branches: string[]; files: string[]; outputPath: string; }
  • Handler dispatcher in the CallToolRequest switch statement that validates arguments and delegates to the main handleFileChangesAnalysis function.
    case 'analyze_file_changes': { const args = request.params.arguments as FileChangesArgs; if (!args?.repoPath || !args?.branches || !args?.files || !args?.outputPath) { throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters'); } return await this.handleFileChangesAnalysis(args); }
  • Helper function used by the handler to analyze potential conflicts in file changes across branches.
    private analyzeConflicts(branchChanges: Array<{ branch: string; history: Array<{ hash: string; date: string; message: string }> }>) { const overlaps = this.findOverlappingChanges(branchChanges); return { riskLevel: this.assessRiskLevel(overlaps), reasons: this.generateConflictReasons(overlaps), }; }

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