get_commit_types
Retrieve a dictionary of available commit types and their descriptions for generating conventional commit messages in the current plugin.
Instructions
Get list of available commit types from the current plugin.
Returns: Dict containing available commit types and their descriptions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool handler for get_commit_types: retrieves commit types from service, formats response with count and plugin info, returns success response.@mcp.tool() @handle_errors(log_errors=True) def get_commit_types() -> Dict[str, Any]: """ Get list of available commit types from the current plugin. Returns: Dict containing available commit types and their descriptions """ commit_types = service.get_commit_types() result = { "commit_types": commit_types, "count": len(commit_types), "plugin": service.get_info().get("plugin_name"), } return create_success_response(result)
- Core helper function in CommitzenCore service that parses commitizen questions to extract available commit types with name/value pairs, handling various choice formats.def get_commit_types(self) -> List[Dict[str, str]]: """Extract available commit types from questions.""" try: questions = self.get_questions() commit_types = [] for question in questions: if question.get("name") == "prefix" and "choices" in question: # Handle different choice formats choices = question["choices"] for choice in choices: if isinstance(choice, dict): # Choice is a dict with 'name' and 'value' commit_types.append( { "name": choice.get( "name", choice.get("value", str(choice)) ), "value": choice.get( "value", choice.get("name", str(choice)) ), } ) elif isinstance(choice, str): # Choice is a simple string commit_types.append({"name": choice, "value": choice}) else: # Fallback for other formats commit_types.append( {"name": str(choice), "value": str(choice)} ) break logger.debug(f"Extracted {len(commit_types)} commit types") return commit_types except CommitizenException as e: logger.error(f"Failed to get commit types: {e}") raise PluginError( f"Failed to extract commit types: {e}", plugin_name=self.committer.__class__.__name__, cause=e, ) except Exception as e: if not isinstance(e, (PluginError, ValidationError)): logger.error(f"Failed to get commit types: {e}") raise PluginError( f"Failed to extract commit types: {e}", plugin_name=self.committer.__class__.__name__, cause=e, ) raise
- Facade service method that delegates get_commit_types call to the underlying commitizen_core service.def get_commit_types(self) -> List[Dict[str, str]]: """Extract available commit types from questions.""" return self.commitizen_core.get_commit_types()
- src/commit_helper_mcp/mcp_server.py:26-31 (registration)Import statement in mcp_server.py that triggers registration of the get_commit_types tool via its @mcp.tool() decorator by importing message_tools.from .server.message_tools import ( generate_commit_message, create_commit_message, validate_commit_message, get_commit_types, )