analyze_time_period
Examine development activity within a specific time frame in a git repository. Analyzes branches, tracks changes, and generates detailed insights for targeted periods to inform project progress and decision-making.
Instructions
Analyze detailed development activity in a specific time period
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branches | Yes | Branches to analyze | |
| outputPath | Yes | Path to write analysis output | |
| repoPath | Yes | Path to git repository | |
| timeRange | Yes |
Implementation Reference
- src/index.ts:267-292 (handler)The main handler function that executes the tool logic. It fetches commits in the specified time range for each branch using git log, summarizes the activity per branch, generates an overall summary, writes the analysis as JSON to the output path, 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)Tool registration in the 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:20-28 (schema)TypeScript interface defining the input arguments structure for the tool.interface TimePeriodArgs { repoPath: string; branches: string[]; timeRange: { start: string; end: string; }; outputPath: string; }
- src/index.ts:189-195 (registration)Dispatch case in the CallToolRequest handler that validates arguments and calls the main handler 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:370-385 (helper)Key helper function that executes git log to retrieve commits within the specified time range for a branch.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 }; }); }