Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

validate_commit_message

Check if a commit message follows conventional commit rules to maintain consistent project history and enable automated changelogs.

Instructions

Validate an existing commit message against the current plugin's rules.

Args: message: The commit message to validate

Returns: Dict containing validation result and details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes

Implementation Reference

  • MCP handler function decorated with @mcp.tool() that implements the validate_commit_message tool. It validates the input message using the service facade and returns structured results with validity status, pattern, and plugin information.
    @mcp.tool() @handle_errors(log_errors=True) def validate_commit_message(message: str) -> Dict[str, Any]: """ Validate an existing commit message against the current plugin's rules. Args: message: The commit message to validate Returns: Dict containing validation result and details """ is_valid = service.validate_message(message) # Get additional info for context info = service.get_info() pattern = info.get("pattern") result = { "is_valid": is_valid, "message": message, "pattern": pattern, "plugin": info.get("plugin_name"), } if not is_valid: # Return error response but don't raise exception # This allows validation to fail gracefully return { "success": False, "is_valid": False, "message": message, "error": "Commit message does not match required pattern", "pattern": pattern, "plugin": info.get("plugin_name"), } return create_success_response(result)
  • Core validation logic used by the tool's service.validate_message call. Performs regex matching against the Commitizen committer's pattern or falls back to plugin adapter validation.
    def validate_message(self, message: str) -> bool: """Validate commit message format.""" try: # First try plugin validation if available if hasattr(self.committer, "pattern"): import re pattern = self.committer.pattern is_valid = bool(re.match(pattern, message)) logger.debug(f"Plugin validation result: {is_valid}") return is_valid else: # Fall back to adapter validation is_valid = self.adapter.validate_message(message) logger.debug(f"Adapter validation result: {is_valid}") return is_valid except CommitizenException as e: logger.error(f"Failed to validate message: {e}") raise ValidationError( f"Message validation failed: {e}", validation_type="commit_message", invalid_value=message, cause=e, ) except Exception as e: if not isinstance(e, ValidationError): logger.error(f"Failed to validate message: {e}") raise ValidationError( f"Message validation failed: {e}", validation_type="commit_message", invalid_value=message, cause=e, ) raise
  • Facade method in CommitzenService that delegates validate_message to the underlying CommitzenCore service.
    def validate_message(self, message: str) -> bool: """Validate commit message format.""" return self.commitizen_core.validate_message(message)

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