Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

generate_commit_message

Generate conventional commit messages with validation using specified parameters like type, subject, scope, and breaking changes for version control workflows.

Instructions

Generate a commit message with validation using provided parameters.

Args: type: The commit type (e.g., 'feat', 'fix', 'docs') subject: The commit subject/description body: Optional commit body with detailed description scope: Optional scope of the change breaking: Whether this is a breaking change footer: Optional footer (e.g., issue references) include_git_preview: Whether to include git preview in response

Returns: Dict containing the generated message and validation status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYes
subjectYes
bodyNo
scopeNo
breakingNo
footerNo
include_git_previewNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'generate_commit_message' MCP tool. Decorated with @mcp.tool() for registration and implements the logic: builds answers dict, generates message via service, validates it, optionally adds git preview, and returns structured response.
    @mcp.tool()
    @handle_errors(log_errors=True)
    def generate_commit_message(
        type: str,
        subject: str,
        body: Optional[str] = None,
        scope: Optional[str] = None,
        breaking: Optional[bool] = False,
        footer: Optional[str] = None,
        include_git_preview: bool = False,
    ) -> Dict[str, Any]:
        """
        Generate a commit message with validation using provided parameters.
    
        Args:
            type: The commit type (e.g., 'feat', 'fix', 'docs')
            subject: The commit subject/description
            body: Optional commit body with detailed description
            scope: Optional scope of the change
            breaking: Whether this is a breaking change
            footer: Optional footer (e.g., issue references)
            include_git_preview: Whether to include git preview in response
    
        Returns:
            Dict containing the generated message and validation status
        """
        # Build answers dictionary with all fields (adapter will handle mapping)
        answers = {
            "type": type,
            "prefix": type,  # Some plugins expect 'prefix'
            "subject": subject,
            "body": body or "",
            "scope": scope or "",
            "breaking": breaking or False,
            "is_breaking_change": breaking or False,  # Some plugins expect this name
            "footer": footer or "",
        }
    
        # Generate the message
        message = service.generate_message(answers)
    
        # Validate the generated message
        is_valid = service.validate_message(message)
    
        if not is_valid:
            raise create_validation_error(
                "Invalid commit message format",
                validation_type="commit_message",
                invalid_value=f"{type}: {subject}",
            )
    
        result = {
            "message": message,
            "is_valid": is_valid,
            "parameters": {
                "type": type,
                "subject": subject,
                "body": body,
                "scope": scope,
                "breaking": breaking,
                "footer": footer,
            },
        }
    
        # Add git preview if requested and available
        if include_git_preview and service.git_enabled:
            try:
                # Import preview function from git_tools
                from .git_tools import preview_git_commit
    
                # Use the current service's repository path for preview
                repo_path = (
                    str(service.git_service.repo_path) if service.git_service else None
                )
                if repo_path:
                    git_preview = preview_git_commit(message, repo_path)
                    result["git_preview"] = git_preview
                else:
                    result["git_preview_error"] = (
                        "No repository path available for git preview"
                    )
            except Exception as e:
                logger.warning(f"Failed to include git preview: {e}")
                result["git_preview_error"] = str(e)
        elif include_git_preview and not service.git_enabled:
            result["git_preview_error"] = (
                "Git operations not available - not in a git repository"
            )
    
        return create_success_response(result)
  • Import statement in the main MCP server file that loads the generate_commit_message tool (along with other message tools), ensuring it is registered and available in the server.
    from .server.message_tools import (
        generate_commit_message,
        create_commit_message,
        validate_commit_message,
        get_commit_types,
    )
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions 'validation' and describes the return format, it doesn't explain what validation entails, what validation failures look like, whether the tool has side effects, or any rate limits or authentication requirements. The description provides some behavioral context but leaves significant gaps.

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 well-structured with clear sections (purpose statement, Args, Returns) and uses bullet-like formatting. Every sentence serves a purpose, though the parameter explanations could be slightly more concise. The structure is front-loaded with the core purpose first.

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 complexity (7 parameters, no annotations, but with output schema), the description provides good coverage. It explains the tool's purpose, documents all parameters with semantics, and describes the return format. With an output schema present, it doesn't need to detail return values further. The main gap is lack of usage guidance relative to sibling tools.

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?

With 0% schema description coverage for 7 parameters, the description compensates well by listing all parameters with brief explanations of their purpose. Each parameter gets a clear semantic description (e.g., 'type: The commit type (e.g., 'feat', 'fix', 'docs')'), which adds significant value beyond the bare schema. The only gap is that it doesn't explain parameter interactions or constraints.

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: 'Generate a commit message with validation using provided parameters.' This specifies the verb (generate with validation) and resource (commit message), though it doesn't explicitly differentiate from sibling tools like 'create_commit_message' or 'validate_commit_message' which appear to serve similar functions.

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 multiple sibling tools related to commit messages (create_commit_message, validate_commit_message, generate_and_commit, etc.), there's no indication of this tool's specific use case or how it differs from similar tools in the server.

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