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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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,
    )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'comprehensive validation' and outlines return values, but lacks details on permissions, rate limits, error handling, or what 'validation' entails (e.g., checks for uncommitted changes, merge conflicts). This is a significant gap for a validation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the purpose, followed by structured Args and Returns sections. Every sentence earns its place with no wasted words, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (validation with one parameter), no annotations, and an output schema (implied by the Returns section), the description is mostly complete. It covers purpose, parameters, and return structure, but lacks behavioral context like error cases or performance characteristics, which holds it back from a 5.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, but the description compensates by documenting the single parameter 'repo_path' in the Args section, adding meaning beyond the bare schema. However, it doesn't specify format details (e.g., absolute vs. relative path, existence requirements), preventing a perfect score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Comprehensive validation of repository readiness for commit,' which is a specific verb (validate) + resource (repository readiness for commit). However, it doesn't explicitly distinguish this from sibling tools like 'validate_commit_message' or 'preview_git_commit,' which reduces the score from a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools related to commits (e.g., 'execute_git_commit,' 'validate_commit_message'), there's no indication of context, prerequisites, or exclusions, leaving the agent to guess based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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