Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

validate_commit_readiness

Validate repository readiness before committing by checking multiple criteria and providing actionable recommendations to ensure proper commit preparation.

Instructions

Comprehensive validation of repository readiness for commit.

Args: repo_path: Path to git repository

Returns: Dict containing: - ready_to_commit: Boolean overall readiness - checks: Dict of individual validation checks - recommendations: List of actions to take before commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes

Implementation Reference

  • MCP tool handler implementing 'validate_commit_readiness'. Validates git repository status, checks for staged files, determines readiness, and provides recommendations.
    @mcp.tool() @handle_errors(log_errors=True) def validate_commit_readiness(repo_path: str) -> Dict[str, Any]: """ Comprehensive validation of repository readiness for commit. Args: repo_path: Path to git repository Returns: Dict containing: - ready_to_commit: Boolean overall readiness - checks: Dict of individual validation checks - recommendations: List of actions to take before commit """ # 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, ) if not target_service.git_enabled: raise RepositoryError( "Git operations not available - not in a git repository", repo_path=repo_path, ) # Get repository status status = target_service.get_repository_status() if "error" in status: raise GitOperationError(status["error"], repo_path=repo_path) # Perform readiness checks checks = { "is_git_repository": status.get("is_git_repository", False), "has_staged_files": not status.get("staging_clean", True), "staged_files_count": status.get("staged_files_count", 0), } # Determine overall readiness ready_to_commit = ( checks["is_git_repository"] and checks["has_staged_files"] and checks["staged_files_count"] > 0 ) # Generate recommendations recommendations = [] if not checks["is_git_repository"]: recommendations.append("Initialize git repository") if not checks["has_staged_files"]: recommendations.append("Stage files for commit using 'git add'") if checks["staged_files_count"] == 0: recommendations.append("Add files to staging area before committing") if ready_to_commit: recommendations.append("Repository is ready for commit") return create_success_response( { "ready_to_commit": ready_to_commit, "git_enabled": True, "checks": checks, "recommendations": recommendations, "repository_status": status, "repository_path": repo_path, } )
  • Supporting service method in CommitOrchestrator that performs detailed commit readiness validation, likely used internally by the MCP tool handler via CommitzenService.
    def validate_commit_readiness( self, repo_path: Optional[str] = None ) -> Dict[str, Any]: """ Comprehensive validation combining git status and message requirements. Args: repo_path: Optional repository path (uses current if not provided) Returns: Dict containing readiness status and recommendations """ if not self.git_enabled: return create_success_response( { "ready_to_commit": False, "checks": { "git_repository": False, "has_staged_files": False, "has_commitizen_config": True, }, "recommendations": ["Not in a git repository"], "git_enabled": False, } ) # Get repository status try: status = self.git.get_repository_status() except Exception as e: raise RepositoryError( f"Failed to get repository status: {str(e)}", repo_path=repo_path, cause=e, ) # Get Commitizen info try: commitizen_info = self.commitizen.get_info() except Exception as e: raise ServiceError( f"Failed to get Commitizen information: {str(e)}", service_name="commitizen_core", cause=e, ) # Perform checks checks = { "git_repository": status.get("is_git_repository", False), "has_staged_files": len(status.get("staged_files", [])) > 0, "has_commitizen_config": commitizen_info.get("config", {}).get("name") != "unknown", "has_unstaged_files": len(status.get("unstaged_files", [])) > 0, "has_untracked_files": len(status.get("untracked_files", [])) > 0, } # Build recommendations recommendations = [] if not checks["has_staged_files"]: recommendations.append("Stage files before committing (git add <files>)") if checks["has_unstaged_files"]: recommendations.append( f"You have {len(status['unstaged_files'])} unstaged files" ) if checks["has_untracked_files"]: recommendations.append( f"You have {len(status['untracked_files'])} untracked files" ) ready_to_commit = ( checks["git_repository"] and checks["has_staged_files"] and checks["has_commitizen_config"] ) return create_success_response( { "ready_to_commit": ready_to_commit, "checks": checks, "recommendations": recommendations, "repository_status": status, "commitizen_info": commitizen_info, "git_enabled": True, } )
  • Re-export of the validate_commit_readiness tool function from git_tools.py for backward compatibility and testing purposes.
    from .server.git_tools import ( get_git_implementation_info, get_enhanced_git_status, get_git_status, preview_git_commit, execute_git_commit, generate_and_commit, validate_commit_readiness, stage_files_and_commit, )

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