get_commit_types
Retrieve available commit types and their descriptions from the Commit Helper MCP server to structure conventional commit messages effectively.
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. Decorated with @mcp.tool() for automatic registration. Retrieves commit types via service facade and formats 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)
- Service facade method that delegates get_commit_types to the CommitzenCore service.def get_commit_types(self) -> List[Dict[str, str]]: """Extract available commit types from questions.""" return self.commitizen_core.get_commit_types()
- Core implementation that extracts commit types from the plugin's questions, handling various choice formats and returning list of dicts with name/value.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
- src/commit_helper_mcp/mcp_server.py:26-31 (registration)Imports the get_commit_types tool function from message_tools, ensuring it's available and registered when the server module is imported.from .server.message_tools import ( generate_commit_message, create_commit_message, validate_commit_message, get_commit_types, )