get_author_metrics
Retrieve per-author git metrics including commit statistics and activity timelines within a date range to analyze individual contributions.
Instructions
Get detailed metrics per author
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | Path to git repository | |
| since | Yes | Start date (YYYY-MM-DD) | |
| until | No | End date (YYYY-MM-DD), optional |
Implementation Reference
- src/handlers.ts:42-75 (handler)Main handler for get_author_metrics. Parses git log output with numstat and author info, aggregating commits, additions, deletions, and files changed per author.
export function handleGetAuthorMetrics(args: any) { const { repo_path, since, until } = args; validateRepoPath(repo_path); validateDate(since, "since"); if (until) validateDate(until, "until"); let cmd = `git log --since="${since}"`; if (until) cmd += ` --until="${until} 23:59:59"`; cmd += ` --pretty=format:"%an <%ae>" --numstat`; const output = runGitCommand(repo_path, cmd); const lines = output.trim().split("\n"); const authors: Record<string, any> = {}; let currentAuthor = ""; for (const line of lines) { if (line.includes("<") && line.includes(">")) { currentAuthor = line; if (!authors[currentAuthor]) { authors[currentAuthor] = { commits: 0, additions: 0, deletions: 0, files: 0 }; } authors[currentAuthor].commits++; } else if (line.match(/^\d+\s+\d+/) && currentAuthor) { const [add, del] = line.split(/\s+/); authors[currentAuthor].additions += parseInt(add) || 0; authors[currentAuthor].deletions += parseInt(del) || 0; authors[currentAuthor].files++; } } return authors; } - src/git-metrics.ts:109-121 (schema)Input schema for get_author_metrics tool registration in the ListToolsRequestSchema handler.
{ name: "get_author_metrics", description: "Get detailed metrics per author", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "Path to git repository" }, since: { type: "string", description: "Start date (YYYY-MM-DD)" }, until: { type: "string", description: "End date (YYYY-MM-DD), optional" }, }, required: ["repo_path", "since"], }, }, - src/git-metrics.ts:257-258 (registration)Dispatch/call-site where get_author_metrics is routed to the handler function.
} else if (request.params.name === "get_author_metrics") { result = handlers.handleGetAuthorMetrics(args);