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
| Name | Required | Description | Default |
|---|---|---|---|
| repoPath | Yes | Path to git repository | |
| file | Yes | File to analyze | |
| commit | Yes | Commit hash to analyze | |
| outputPath | Yes | Path to write analysis output |
Implementation Reference
- src/index.ts:345-364 (handler)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'], }, },
- src/index.ts:30-35 (schema)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; }
- src/index.ts:93-106 (schema)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' ); }
- src/index.ts:267-273 (handler)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); }