Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

batch_commit_analysis

Organize staged file changes into logical commit groups and generate appropriate commit messages for each group in a Git repository.

Instructions

Analyze multiple file groups for batch commit operations.

Helps organize staged changes into logical commit groups with appropriate commit messages for each group.

Args: repo_path: Path to git repository file_groups: List of file groups with metadata generate_messages: Whether to generate commit messages for each group

Returns: Dict containing batch commit analysis and suggestions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_groupsYes
generate_messagesNo
repo_pathYes

Implementation Reference

  • The primary MCP tool handler for 'batch_commit_analysis'. Decorated with @mcp.tool(), it initializes a CommitzenService, analyzes provided file groups, generates simple commit message suggestions if requested, and returns a structured analysis response.
    @mcp.tool() @handle_errors(log_errors=True) def batch_commit_analysis( repo_path: str, file_groups: List[Dict[str, Any]], generate_messages: bool = True ) -> Dict[str, Any]: """ Analyze multiple file groups for batch commit operations. Helps organize staged changes into logical commit groups with appropriate commit messages for each group. Args: repo_path: Path to git repository file_groups: List of file groups with metadata generate_messages: Whether to generate commit messages for each group Returns: Dict containing batch commit analysis and suggestions """ # Initialize service for the specified repository try: target_service = CommitzenService(repo_path=repo_path) except Exception as e: raise RepositoryError( f"Failed to initialize service for repository '{repo_path}'", repo_path=repo_path, cause=e ) try: batch_analysis = [] for i, group in enumerate(file_groups): group_files = group.get("files", []) group_description = group.get("description", f"Group {i+1}") if not group_files: continue # Analyze this group of files group_analysis = { "group_id": i, "description": group_description, "files": group_files, "file_count": len(group_files) } if generate_messages: # Generate smart suggestions for this group group_analysis["suggested_messages"] = [ { "type": "feat", "subject": f"implement {group_description}", "confidence": 0.7 } ] batch_analysis.append(group_analysis) return create_success_response({ "repository_path": repo_path, "implementation": target_service.git_implementation, "batch_analysis": batch_analysis, "total_groups": len(batch_analysis), "total_files": sum(group["file_count"] for group in batch_analysis) }) except Exception as e: logger.error(f"Failed to analyze batch commits: {e}") raise ServiceError( f"Failed to analyze batch commits: {e}", service_name="batch_commit_analysis", cause=e )
  • Explicit import of the batch_commit_analysis handler function in the main MCP server module, ensuring the tool is available and exported.
    from .server.enhanced_tools import ( analyze_repository_health, get_detailed_diff_analysis, get_branch_analysis, smart_commit_suggestion, batch_commit_analysis, )
  • A helper method in the CommitOrchestrator class that provides batch commit analysis using CommitizenCore for message generation and validation. May be used internally by services.
    def batch_commit_analysis( self, repo_path: Optional[str], file_groups: List[Dict[str, Any]], generate_messages: bool = True, **kwargs, ) -> Dict[str, Any]: """ Analyze multiple file groups for batch commit operations. Args: repo_path: Repository path file_groups: List of file groups with metadata generate_messages: Whether to generate commit messages Returns: Dict containing batch analysis and suggestions """ if not self.git_enabled: raise RepositoryError("Git operations not available", repo_path=repo_path) analyzed_groups = [] for group in file_groups: group_analysis = { "group_id": group.get("id", "unnamed"), "files": group.get("files", []), "description": group.get("description", ""), } # Generate commit message if requested if generate_messages and group.get("type") and group.get("subject"): try: message = self.commitizen.generate_message( { "type": group["type"], "subject": group["subject"], "scope": group.get("scope"), "body": group.get("body"), "breaking": group.get("breaking", False), "footer": group.get("footer"), } ) group_analysis["generated_message"] = message group_analysis["is_valid"] = self.commitizen.validate_message( message ) except Exception as e: logger.warning( f"Failed to generate message for group {group.get('id')}: {e}" ) group_analysis["message_error"] = str(e) analyzed_groups.append(group_analysis) return create_success_response( { "groups": analyzed_groups, "total_groups": len(file_groups), "valid_messages": len( [g for g in analyzed_groups if g.get("is_valid", False)] ), "git_enabled": True, } )

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/jolfr/commit-helper-mcp'

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