Skip to main content
Glama

analyze_commits_impact

Analyze git commits with code changes to assess their impact on projects. Provides commit messages and diffs for understanding actual work done.

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
NameRequiredDescriptionDefault
repo_nameNoName of the repository (optional, uses default if not specified)
sinceNoTime range for commits1 month ago
limitNoMaximum number of commits to analyze (default: 10)

Implementation Reference

  • The main handler function that retrieves recent git commits by author from the specified repository, fetches summary details (message, author, date, stat) for up to 'limit' commits since the given time, and formats output for impact analysis.
    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}")]
  • Registration of the 'analyze_commits_impact' tool in the list_tools() function, including name, description, and input schema.
    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 } } } ),
  • Input schema definition for the 'analyze_commits_impact' tool, specifying parameters repo_name (optional str), since (str, default '1 month ago'), limit (int, default 10).
    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 } } }
  • Dispatch handler in the main call_tool function that routes requests for 'analyze_commits_impact' to the implementation function.
    elif name == "analyze_commits_impact": return await analyze_commits_impact( arguments.get("repo_name"), arguments.get("since", "1 month ago"), arguments.get("limit", 10) )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eyaab/cv-resume-builder-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server