Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

commit_workflow_step

Process a commit workflow step to generate, preview, approve, or execute conventional commit messages with state management.

Instructions

Multi-step commit workflow with state management.

Args: workflow_data: Workflow state data step: Current step ("generate" | "preview" | "approve" | "execute")

Returns: Dict with workflow state and next step information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflow_dataYes
stepNogenerate

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function implementing the multi-step commit workflow tool: generate commit message, preview changes, approve with validation, and execute git commit.
    @mcp.tool()
    @handle_errors(log_errors=True)
    def commit_workflow_step(
        workflow_data: Dict[str, Any], step: str = "generate"
    ) -> Dict[str, Any]:
        """
        Multi-step commit workflow with state management.
    
        Args:
            workflow_data: Workflow state data
            step: Current step ("generate" | "preview" | "approve" | "execute")
    
        Returns:
            Dict with workflow state and next step information
        """
        if step == "generate":
            # Generate commit message from parameters
            required_params = ["type", "subject"]
            for param in required_params:
                if param not in workflow_data:
                    raise ValidationError(
                        f"Missing required parameter: {param}",
                        validation_type="workflow_parameters",
                        invalid_value=str(workflow_data.keys()),
                    )
    
            # Import message generation function
            from .message_tools import generate_commit_message
    
            message_result = generate_commit_message(
                type=workflow_data["type"],
                subject=workflow_data["subject"],
                body=workflow_data.get("body"),
                scope=workflow_data.get("scope"),
                breaking=workflow_data.get("breaking", False),
                footer=workflow_data.get("footer"),
            )
    
            if "error" in message_result:
                return {
                    "error": f"Message generation failed: {message_result['error']}",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            # Update workflow data with generated message
            updated_workflow = workflow_data.copy()
            updated_workflow["generated_message"] = message_result["message"]
            updated_workflow["is_valid"] = message_result["is_valid"]
    
            return {
                "success": True,
                "step": step,
                "workflow_data": updated_workflow,
                "next_step": "preview",
                "result": message_result,
            }
    
        elif step == "preview":
            # Show commit preview with git status
            if "generated_message" not in workflow_data:
                return {
                    "error": "No generated message found in workflow data",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            # Import git preview function
            from .git_tools import preview_git_commit
    
            # Get repository path from workflow data or use current service
            repo_path = workflow_data.get("repo_path")
            if not repo_path and service.git_service:
                repo_path = str(service.git_service.repo_path)
    
            if not repo_path:
                return {
                    "error": "No repository path available for preview",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            preview_result = preview_git_commit(
                workflow_data["generated_message"], repo_path
            )
    
            # Update workflow data with preview
            updated_workflow = workflow_data.copy()
            updated_workflow["preview_result"] = preview_result
            updated_workflow["repo_path"] = repo_path  # Store for later steps
    
            return {
                "success": True,
                "step": step,
                "workflow_data": updated_workflow,
                "next_step": "approve",
                "result": preview_result,
            }
    
        elif step == "approve":
            # Validate approval and prepare execution
            if "generated_message" not in workflow_data:
                return {
                    "error": "No generated message found in workflow data",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            # Check if user has explicitly approved
            user_approved = workflow_data.get("user_approved", False)
            if not user_approved:
                return {
                    "error": "User approval required before execution",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": "execute",
                    "approval_required": True,
                    "message": "Set 'user_approved': true in workflow_data to proceed",
                }
    
            # Import readiness validation function
            from .git_tools import validate_commit_readiness
    
            # Validate readiness - get repo_path from workflow data
            repo_path = workflow_data.get("repo_path")
            if not repo_path and service.git_service:
                repo_path = str(service.git_service.repo_path)
    
            if not repo_path:
                return {
                    "error": "No repository path available for readiness validation",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            readiness = validate_commit_readiness(repo_path)
    
            updated_workflow = workflow_data.copy()
            updated_workflow["readiness_check"] = readiness
            updated_workflow["ready_for_execution"] = readiness.get(
                "ready_to_commit", False
            )
    
            return {
                "success": True,
                "step": step,
                "workflow_data": updated_workflow,
                "next_step": "execute" if readiness.get("ready_to_commit", False) else None,
                "result": readiness,
            }
    
        elif step == "execute":
            # Perform actual commit with all safety checks
            if "generated_message" not in workflow_data:
                return {
                    "error": "No generated message found in workflow data",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            if not workflow_data.get("user_approved", False):
                return {
                    "error": "User approval required for execution",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            # Import git execution function
            from .git_tools import execute_git_commit
    
            # Execute the commit
            repo_path = workflow_data.get("repo_path")
            if not repo_path and service.git_service:
                repo_path = str(service.git_service.repo_path)
    
            if not repo_path:
                return {
                    "error": "No repository path available for commit execution",
                    "step": step,
                    "workflow_data": workflow_data,
                    "next_step": None,
                }
    
            commit_result = execute_git_commit(
                message=workflow_data["generated_message"],
                repo_path=repo_path,
                sign_off=workflow_data.get("sign_off", True),  # Default to True for signoff
                force_execute=True,
            )
    
            updated_workflow = workflow_data.copy()
            updated_workflow["commit_result"] = commit_result
            updated_workflow["completed"] = commit_result.get("success", False)
    
            return {
                "success": commit_result.get("success", False),
                "step": step,
                "workflow_data": updated_workflow,
                "next_step": None,
                "result": commit_result,
                "workflow_completed": True,
            }
    
        else:
            raise ValidationError(
                f"Unknown workflow step: {step}",
                validation_type="workflow_step",
                invalid_value=step,
                expected_format="One of: generate, preview, approve, execute",
            )
  • Explicit import of commit_workflow_step from workflow_tools module, which registers the @mcp.tool()-decorated function for the MCP server.
    from .server.workflow_tools import (
        get_commit_questions,
        health_check,
        refresh_configuration,
        commit_workflow_step,
    )
  • Module-level import of workflow_tools, automatically registering all @mcp.tool() functions including commit_workflow_step.
    from .server import workflow_tools
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'state management' and returns 'workflow state and next step information', but doesn't disclose critical behavioral traits like whether this performs actual Git operations, requires authentication, has side effects, or handles errors. For a tool with 'commit' in its name and complex workflow logic, this is insufficient.

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

Conciseness4/5

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

The description is appropriately sized with a brief overview followed by Args and Returns sections. It's front-loaded with the core purpose, though some sentences could be more informative. No wasted text, but the content is under-specified rather than concise.

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

Completeness3/5

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

Given complexity (multi-step workflow with state management), no annotations, and an output schema (which handles return values), the description is incomplete. It outlines the tool's role but lacks details on behavior, error handling, or integration with sibling tools. The output schema reduces burden, but key contextual gaps remain for effective agent use.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It adds basic meaning by explaining 'workflow_data' as 'Workflow state data' and 'step' with enum values, but doesn't detail the structure of 'workflow_data' or how steps transition. With 2 parameters and nested objects, this provides minimal semantic value beyond the bare schema.

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

Purpose3/5

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

The description states it's a 'Multi-step commit workflow with state management' which gives a general purpose, but it's vague about what specific action it performs. It doesn't clearly distinguish from sibling tools like 'execute_git_commit' or 'stage_files_and_commit' that also handle commit operations. The verb 'commit' in the name isn't elaborated in the description beyond workflow management.

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?

No guidance on when to use this tool versus alternatives is provided. With many sibling tools related to commits (e.g., 'execute_git_commit', 'preview_git_commit'), the description doesn't explain this tool's specific role in the workflow or when to choose it over others. Usage is implied through parameter descriptions but not explicitly stated.

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