Skip to main content
Glama
davidorex

Git File Forensics MCP

by davidorex

analyze_file_semantics

Analyze semantic changes and patterns in file history to understand code evolution and detect meaningful modifications in Git repositories.

Instructions

Analyze semantic changes and patterns in file history

Input Schema

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

Implementation Reference

  • The primary handler function that performs semantic analysis on a file's git history by retrieving changes, analyzing patterns, generating a summary, writing JSON output to the specified path, and returning a success message.
    private async handleFileSemantics(args: FileSemanticArgs) {
      const changes = this.getSemanticChanges(args.repoPath, args.file);
      const patterns = this.analyzeChangePatterns(changes);
      
      const analysis = {
        changes,
        patterns,
        summary: this.generateSemanticSummary(changes, patterns),
      };
    
      writeFileSync(args.outputPath, JSON.stringify(analysis, null, 2));
    
      return {
        content: [
          {
            type: 'text',
            text: `File semantic analysis written to ${args.outputPath}`,
          },
        ],
      };
    }
  • src/index.ts:224-245 (registration)
    Tool registration in the listTools response, including name, description, and input schema definition.
    {
      name: 'analyze_file_semantics',
      description: 'Analyze semantic changes and patterns in file history',
      inputSchema: {
        type: 'object',
        properties: {
          repoPath: {
            type: 'string',
            description: 'Path to git repository',
          },
          file: {
            type: 'string',
            description: 'File to analyze',
          },
          outputPath: {
            type: 'string',
            description: 'Path to write analysis output',
          },
        },
        required: ['repoPath', 'file', 'outputPath'],
      },
    },
  • TypeScript interface defining the input parameters for the analyze_file_semantics tool.
    interface FileSemanticArgs {
      repoPath: string;
      file: string;
      outputPath: string;
    }
  • Type guard function used to validate incoming arguments conform to FileSemanticArgs before calling the handler.
    private isFileSemanticArgs(args: unknown): args is FileSemanticArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        'repoPath' in args &&
        'file' in args &&
        'outputPath' in args &&
        typeof (args as FileSemanticArgs).repoPath === 'string' &&
        typeof (args as FileSemanticArgs).file === 'string' &&
        typeof (args as FileSemanticArgs).outputPath === 'string'
      );
    }
  • Helper function that executes git log with patches to retrieve file history data for semantic change analysis.
    private getSemanticChanges(repoPath: string, file: string) {
      const output = execSync(
        `cd "${repoPath}" && git log --patch --format="%H|%aI|%s" -- "${file}"`,
        { encoding: 'utf8' }
      );
    
      // Implement semantic change analysis
      return [];
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool analyzes semantic changes and patterns, but doesn't describe what the analysis entails (e.g., output format, whether it writes to a file or returns data, error handling, or performance considerations). For a tool with 3 parameters and no output schema, this lack of detail is a significant gap, making it hard for an agent to predict behavior beyond basic functionality.

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 front-loaded and every part earns its place by conveying the core functionality. There's no redundancy or fluff, making it highly concise and well-structured for quick understanding.

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 (3 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what the analysis outputs, how to interpret results, or any behavioral traits like side effects (e.g., writing to 'outputPath'). For a tool that likely involves file operations and semantic analysis, more context is needed to guide effective use, leaving gaps in understanding.

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%, with clear descriptions for each parameter (repoPath, file, outputPath). The description doesn't add any meaning beyond the schema, such as explaining how 'file' relates to 'repoPath' or what 'outputPath' expects. Since the schema already documents parameters adequately, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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') and the target ('semantic changes and patterns in file history'), which is specific and meaningful. It distinguishes this tool from siblings like 'analyze_file_diff' (which likely focuses on textual differences) and 'track_file_versions' (which might track version metadata), though it doesn't explicitly differentiate them. The purpose is not vague or tautological, but it lacks explicit sibling differentiation for a perfect score.

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. It doesn't mention when to choose it over siblings like 'analyze_file_context' or 'analyze_file_diff', nor does it specify any prerequisites or exclusions. The context is implied (analyzing file history), but without explicit usage instructions, it leaves the agent to guess based on tool names alone.

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-file-forensics'

If you have feedback or need assistance with the MCP directory API, please join our Discord server