Skip to main content
Glama

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); }

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