Skip to main content
Glama
davidorex

Git File Forensics MCP

by davidorex

analyze_file_context

Analyze file changes within a specific commit to understand broader context and patterns in Git repositories.

Instructions

Analyze broader context of file changes in a specific commit

Input Schema

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

Implementation Reference

  • Main execution function for the 'analyze_file_context' tool. It retrieves related files and commit context using helper methods, generates a summary, writes the analysis as JSON to the specified output path, and returns a success message.
    private async handleFileContext(args: FileContextArgs) {
      const relatedFiles = this.getRelatedFiles(args.repoPath, args.file, args.commit);
      const commitInfo = this.getCommitContext(args.repoPath, args.commit);
      
      const analysis = {
        relatedFiles,
        commitInfo,
        summary: this.generateContextSummary(relatedFiles, commitInfo),
      };
    
      writeFileSync(args.outputPath, JSON.stringify(analysis, null, 2));
    
      return {
        content: [
          {
            type: 'text',
            text: `File context analysis written to ${args.outputPath}`,
          },
        ],
      };
  • src/index.ts:198-223 (registration)
    Tool registration in the ListToolsRequestSchema handler. Defines the tool name, description, and JSON input schema including required parameters: repoPath, file, commit, outputPath.
    {
      name: 'analyze_file_context',
      description: 'Analyze broader context of file changes in a specific commit',
      inputSchema: {
        type: 'object',
        properties: {
          repoPath: {
            type: 'string',
            description: 'Path to git repository',
          },
          file: {
            type: 'string',
            description: 'File to analyze',
          },
          commit: {
            type: 'string',
            description: 'Commit hash to analyze',
          },
          outputPath: {
            type: 'string',
            description: 'Path to write analysis output',
          },
        },
        required: ['repoPath', 'file', 'commit', 'outputPath'],
      },
    },
  • TypeScript type definition (interface) for the input arguments used by the analyze_file_context tool handler.
    interface FileContextArgs {
      repoPath: string;
      file: string;
      commit: string;
      outputPath: string;
    }
  • Runtime type guard/validator function that checks if provided arguments match the FileContextArgs interface before calling the handler.
    private isFileContextArgs(args: unknown): args is FileContextArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        'repoPath' in args &&
        'file' in args &&
        'commit' in args &&
        'outputPath' in args &&
        typeof (args as FileContextArgs).repoPath === 'string' &&
        typeof (args as FileContextArgs).file === 'string' &&
        typeof (args as FileContextArgs).commit === 'string' &&
        typeof (args as FileContextArgs).outputPath === 'string'
      );
    }
  • Dispatch logic in the CallToolRequestSchema handler that routes 'analyze_file_context' calls: validates arguments using isFileContextArgs and invokes the main handleFileContext method.
    case 'analyze_file_context': {
      const args = request.params.arguments as unknown;
      if (!this.isFileContextArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters');
      }
      return await this.handleFileContext(args);
    }
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 mentions analysis and output writing, but doesn't clarify what 'broader context' entails (e.g., historical changes, related files, impact analysis), whether it's read-only or modifies data, or any performance or permission considerations. This leaves significant gaps for a tool with 4 parameters and no output schema.

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 with the core action and target, making it easy to parse quickly, which is ideal for conciseness in tool descriptions.

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 in commits (which could involve historical data, cross-file dependencies, or output formats), the description is incomplete. With no annotations to cover behavioral traits and no output schema to explain return values, it lacks details on what 'broader context' means, how analysis is performed, or what the output contains, making it inadequate for informed tool selection.

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 all 4 parameters (repoPath, file, commit, outputPath). The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints, but the schema adequately documents the inputs, meeting the baseline for high coverage.

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 broader context') and target ('file changes in a specific commit'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from its siblings like 'analyze_file_diff' or 'analyze_file_semantics', which likely have overlapping domains but different analytical focuses.

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_file_diff' or 'analyze_file_semantics'. It mentions the context ('broader context of file changes in a specific commit') but doesn't specify use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name 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