analyze_time_period
Analyze development activity patterns within a specific time period in git repositories to identify trends and changes.
Instructions
Analyze detailed development activity in a specific time period
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repoPath | Yes | Path to git repository | |
| branches | Yes | Branches to analyze | |
| timeRange | Yes | ||
| outputPath | Yes | Path to write analysis output |
Implementation Reference
- src/index.ts:267-292 (handler)The primary handler function for the 'analyze_time_period' tool. It processes the input arguments, retrieves commits within the specified time range for each branch using helper methods, generates activity summaries, compiles the results, writes them to the output file, and returns a success message.private async handleTimePeriodAnalysis(args: TimePeriodArgs) { const analysis = args.branches.map(branch => { const commits = this.getCommitsInRange(args.repoPath, branch, args.timeRange); return { branch, commits, activitySummary: this.summarizeActivity(commits), }; }); const result = { analysis, summary: this.generateTimePeriodSummary(analysis), }; writeFileSync(args.outputPath, JSON.stringify(result, null, 2)); return { content: [ { type: 'text', text: `Time period analysis written to ${args.outputPath}`, }, ], }; }
- src/index.ts:94-124 (registration)Registers the 'analyze_time_period' tool in the MCP server's listTools response, including name, description, and input schema.{ name: 'analyze_time_period', description: 'Analyze detailed development activity in a specific time period', inputSchema: { type: 'object', properties: { repoPath: { type: 'string', description: 'Path to git repository', }, branches: { type: 'array', items: { type: 'string' }, description: 'Branches to analyze', }, timeRange: { type: 'object', properties: { start: { type: 'string' }, end: { type: 'string' }, }, required: ['start', 'end'], }, outputPath: { type: 'string', description: 'Path to write analysis output', }, }, required: ['repoPath', 'branches', 'timeRange', 'outputPath'], }, },
- src/index.ts:189-195 (schema)Dispatcher case in the CallToolRequestSchema handler that validates input parameters using the TimePeriodArgs type and delegates to the main handleTimePeriodAnalysis function.case 'analyze_time_period': { const args = request.params.arguments as TimePeriodArgs; if (!args?.repoPath || !args?.branches || !args?.timeRange || !args?.outputPath) { throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters'); } return await this.handleTimePeriodAnalysis(args); }
- src/index.ts:20-28 (schema)TypeScript interface defining the input arguments structure for the 'analyze_time_period' tool, matching the inputSchema.interface TimePeriodArgs { repoPath: string; branches: string[]; timeRange: { start: string; end: string; }; outputPath: string; }
- src/index.ts:370-385 (helper)Helper function that executes git log to fetch commits within the specified time range for a given branch, parsing them into structured objects. Called by the main handler.private getCommitsInRange( repoPath: string, branch: string, timeRange: { start: string; end: string } ) { const output = execSync( `cd "${repoPath}" && git log --format="%H|%aI|%s" ` + `--after="${timeRange.start}" --before="${timeRange.end}" ${branch}`, { encoding: 'utf8' } ); return output.trim().split('\n').filter(Boolean).map(line => { const [hash, date, message] = line.split('|'); return { hash, date, message, branch }; }); }