Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

execute_git_commit

Execute Git commits with safety checks and user approval, requiring explicit confirmation to perform actual commits while supporting conventional commit messages.

Instructions

Execute actual git commit with safety checks and user approval.

SAFETY: Requires force_execute=True to perform actual commit.

Args: message: Commit message to use repo_path: Path to git repository stage_all: Whether to stage all changes before commit (not implemented yet) sign_off: Whether to add sign-off to commit (default: True) force_execute: Must be True to execute actual commit (safety flag)

Returns: Dict containing: - success: Whether commit was successful - message: The commit message used - executed: Whether commit was actually executed - error: Error message (if failed) - dry_run: False if actually executed, True if preview only

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes
repo_pathYes
stage_allNo
sign_offNo
force_executeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'execute_git_commit' MCP tool. Decorated with @mcp.tool(), it implements the git commit logic using CommitzenService, with safety requiring 'force_execute=True' to actually commit. Handles repository initialization, git checks, and error responses.
    @mcp.tool()
    def execute_git_commit(
        message: str,
        repo_path: str,
        stage_all: bool = False,
        sign_off: bool = True,
        force_execute: bool = False,
    ) -> Dict[str, Any]:
        """
        Execute actual git commit with safety checks and user approval.
    
        SAFETY: Requires force_execute=True to perform actual commit.
    
        Args:
            message: Commit message to use
            repo_path: Path to git repository
            stage_all: Whether to stage all changes before commit (not implemented yet)
            sign_off: Whether to add sign-off to commit (default: True)
            force_execute: Must be True to execute actual commit (safety flag)
    
        Returns:
            Dict containing:
            - success: Whether commit was successful
            - message: The commit message used
            - executed: Whether commit was actually executed
            - error: Error message (if failed)
            - dry_run: False if actually executed, True if preview only
        """
        try:
            # Initialize service for the specified repository
            try:
                target_service = CommitzenService(repo_path=repo_path)
            except Exception as e:
                return {
                    "git_enabled": False,
                    "error": f"Failed to initialize service for repository '{repo_path}': {e}",
                    "success": False,
                    "executed": False,
                    "message": message,
                    "repository_path": repo_path,
                }
    
            if not target_service.git_enabled:
                return {
                    "git_enabled": False,
                    "error": "Git operations not available - not in a git repository",
                    "success": False,
                    "executed": False,
                    "message": message,
                    "repository_path": repo_path,
                }
    
            # Execute commit with safety checks
            result = target_service.execute_commit_operation(
                message=message, force_execute=force_execute, sign_off=sign_off
            )
    
            # Add dry_run flag based on execution
            result["dry_run"] = not result.get("executed", False)
            result["git_enabled"] = True
            result["repository_path"] = repo_path
    
            return result
    
        except Exception as e:
            logger.error(f"Failed to execute git commit: {e}")
            return {
                "git_enabled": False,
                "error": str(e),
                "success": False,
                "executed": False,
                "message": message,
                "dry_run": True,
                "repository_path": repo_path,
            }
  • Registration via re-export/import of the execute_git_commit function from git_tools.py in the main mcp_server.py, ensuring it's available in the server's namespace after module imports trigger @mcp.tool() decorators.
    from .server.git_tools import (
        get_git_implementation_info,
        get_enhanced_git_status,
        get_git_status,
        preview_git_commit,
        execute_git_commit,
        generate_and_commit,
        validate_commit_readiness,
        stage_files_and_commit,
    )
  • Internal usage of execute_git_commit within the generate_and_commit tool, demonstrating how it's integrated into higher-level workflows.
    commit_result = execute_git_commit(
        message=generated_message,
        repo_path=repo_path,
        sign_off=sign_off,
        force_execute=True,  # Since user explicitly set preview_only=False
    )
  • Usage of execute_git_commit in the multi-step commit_workflow_step tool during the 'execute' phase.
    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,
    )
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so effectively. It discloses safety mechanisms (requires force_execute=True), user approval needs, and behavioral traits like dry-run vs. actual execution. It also notes that 'stage_all' is 'not implemented yet', adding useful context about limitations.

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 sections for safety, args, and returns, making it easy to parse. It is appropriately sized with no redundant sentences, though the 'Args' and 'Returns' sections could be slightly more integrated into the flow. Every sentence adds value, earning its place.

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

Completeness5/5

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

Given the complexity of a git commit tool with safety mechanisms and no annotations, the description is complete. It explains the tool's behavior, parameters, and return values in detail. With an output schema present, it doesn't need to elaborate on return types, but it still provides a clear summary, making it fully adequate for the context.

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

Parameters5/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 fully. It adds significant meaning beyond the schema by explaining each parameter's purpose, defaults, and constraints (e.g., 'stage_all' not implemented, 'force_execute' as safety flag). This provides clear semantics for all 5 parameters, compensating for the lack of schema descriptions.

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

Purpose5/5

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

The description clearly states the specific action ('Execute actual git commit') with safety mechanisms and distinguishes it from siblings like 'preview_git_commit' and 'stage_files_and_commit'. It explicitly mentions the safety requirement for actual execution, making the purpose distinct and well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: it requires 'force_execute=True' to perform an actual commit, implying it should be used for final execution after safety checks. It distinguishes from alternatives like 'preview_git_commit' (for dry runs) and other analysis tools, offering clear context for usage.

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