analyze_commits_impact
Analyze git commits and code changes to assess their impact on projects, helping AI understand actual work performed for resume building.
Instructions
Get commits with their code changes for impact analysis. Returns commit messages + diffs to help AI understand the actual work done.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_name | No | Name of the repository (optional, uses default if not specified) | |
| since | No | Time range for commits | 1 month ago |
| limit | No | Maximum number of commits to analyze (default: 10) |
Implementation Reference
- The handler function that retrieves recent git commits by author, fetches their stats and summaries using 'git show --stat', formats them for impact analysis, and returns as TextContent. Limits to specified number of commits.async def analyze_commits_impact(repo_name: Optional[str], since: str, limit: int) -> list[TextContent]: """Get commits with their code changes for impact analysis.""" # Resolve repo if not repo_name: repo_name = list(REPO_DICT.keys())[0] if REPO_DICT else "default" if repo_name not in REPO_DICT: available = ", ".join(REPO_DICT.keys()) return [TextContent( type="text", text=f"Repository '{repo_name}' not found.\n\nAvailable repositories: {available}" )] repo_path = REPO_DICT[repo_name] try: # Get commit hashes cmd_log = [ "git", "log", f"--author={AUTHOR_NAME}", "--no-merges", f"--since={since}", f"-{limit}", "--pretty=format:%H" ] result = subprocess.run( cmd_log, cwd=repo_path, capture_output=True, text=True, check=True ) commit_hashes = result.stdout.strip().split('\n') if not commit_hashes or commit_hashes == ['']: return [TextContent( type="text", text=f"No commits found in '{repo_name}' for {since}" )] # Get details for each commit all_output = f"Commit Impact Analysis for '{repo_name}' ({since}):\n" all_output += f"Analyzing {len(commit_hashes)} commits\n\n" all_output += "="*60 + "\n\n" for i, commit_hash in enumerate(commit_hashes, 1): try: # Get commit with stats (no full diff, just summary) cmd_show = [ "git", "show", "--stat", "--format=## Commit %h - %s%n%nAuthor: %an%nDate: %ar%n", commit_hash ] result = subprocess.run( cmd_show, cwd=repo_path, capture_output=True, text=True, check=True ) all_output += result.stdout + "\n" all_output += "-"*60 + "\n\n" except subprocess.CalledProcessError: all_output += f"## Commit {commit_hash[:7]}\nError retrieving details\n\n" all_output += f"\n\nTotal commits analyzed: {len(commit_hashes)}\n" all_output += f"\nUse 'get_commit_details' with a specific commit hash to see full code changes." return [TextContent(type="text", text=all_output)] except subprocess.CalledProcessError as e: return [TextContent(type="text", text=f"Git error: {e.stderr}")]
- The input schema definition for the tool, specifying parameters repo_name (optional string), since (string, default '1 month ago'), limit (number, default 10). Part of the list_tools() response.Tool( name="analyze_commits_impact", description="Get commits with their code changes for impact analysis. Returns commit messages + diffs to help AI understand the actual work done.", inputSchema={ "type": "object", "properties": { "repo_name": { "type": "string", "description": "Name of the repository (optional, uses default if not specified)" }, "since": { "type": "string", "description": "Time range for commits", "default": "1 month ago" }, "limit": { "type": "number", "description": "Maximum number of commits to analyze (default: 10)", "default": 10 } } } ),
- src/cv_resume_builder_mcp/server.py:331-336 (registration)The dispatch logic in the main @app.call_tool() handler that routes calls to this tool name to the analyze_commits_impact function with parsed arguments.elif name == "analyze_commits_impact": return await analyze_commits_impact( arguments.get("repo_name"), arguments.get("since", "1 month ago"), arguments.get("limit", 10) )