Skip to main content
Glama
davidorex

Git Forensics MCP

by davidorex

analyze_file_changes

Analyze specific file changes across git branches to track modifications and generate detailed reports for repository forensic analysis.

Instructions

Analyze changes to specific files across branches

Input Schema

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

Implementation Reference

  • The primary handler function for the 'analyze_file_changes' tool. Processes input arguments to analyze changes in specified files across branches: retrieves git history, analyzes conflicts, generates summary, writes JSON output, and returns 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)
    Registration of the 'analyze_file_changes' tool in the ListToolsRequestHandler response, including name, description, and complete input schema.
    {
      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 structure for the 'analyze_file_changes' tool handler.
    interface FileChangesArgs {
      repoPath: string;
      branches: string[];
      files: string[];
      outputPath: string;
    }
  • Dispatcher case in CallToolRequestHandler for 'analyze_file_changes': validates parameters and delegates to the main handler method.
    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);
    }
  • Key helper function used by the handler to fetch git commit history for a specific file on a given branch.
    private getFileHistory(repoPath: string, branch: string, file: string) {
      const output = execSync(
        `cd "${repoPath}" && git log --format="%H|%aI|%s" ${branch} -- ${file}`,
        { encoding: 'utf8' }
      );
    
      return output.trim().split('\n').filter(Boolean).map(line => {
        const [hash, date, message] = line.split('|');
        return { hash, date, message, branch };
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure but only states what the tool does at a high level. It doesn't explain what 'analyze' entails (e.g., type of analysis, output format, whether it writes to disk, performance implications, or error handling), leaving significant gaps in understanding its 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 appropriately sized and front-loaded, making it easy to parse 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 analyzing file changes across branches (a non-trivial operation), no annotations, and no output schema, the description is insufficient. It lacks details on what the analysis produces, how results are formatted, or any behavioral traits, making it incomplete for effective agent use.

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 4 parameters thoroughly. The description doesn't add any additional meaning or context about the parameters beyond what's in the schema, resulting in a baseline score of 3.

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 action ('analyze changes') and target ('specific files across branches'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'analyze_time_period' or 'get_branch_overview', which might also involve analysis operations.

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?

The description provides no guidance on when to use this tool versus alternatives like 'analyze_time_period' or 'get_branch_overview'. There's no mention of prerequisites, exclusions, or comparative contexts, leaving the agent without usage direction.

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