Skip to main content
Glama
jolfr

Commit Helper MCP

by jolfr

get_git_status

Check Git repository status and view staged files to prepare for committing changes in the Commit Helper MCP server.

Instructions

Get current git repository status and staged files.

Args: repo_path: Path to git repository

Returns: Dict containing: - git_enabled: Whether git operations are available - staged_files: List of staged file paths - staged_count: Number of staged files - repository_path: Path to git repository - repository_status: Additional status information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes

Implementation Reference

  • The main handler function for the 'get_git_status' MCP tool. It initializes a CommitzenService for the given repo_path, retrieves the repository status, and returns a formatted dictionary with git status information including staged files. Includes comprehensive error handling and backward compatibility fields.
    @mcp.tool()
    @handle_errors(log_errors=True)
    def get_git_status(repo_path: str) -> Dict[str, Any]:
        """
        Get current git repository status and staged files.
    
        Args:
            repo_path: Path to git repository
    
        Returns:
            Dict containing:
            - git_enabled: Whether git operations are available
            - staged_files: List of staged file paths
            - staged_count: Number of staged files
            - repository_path: Path to git repository
            - repository_status: Additional status information
        """
        # For backward compatibility with tests expecting git_enabled field
        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}",
                    "staged_files": [],
                    "staged_count": 0,
                    "repository_path": repo_path,
                }
    
            if not target_service.git_enabled:
                return {
                    "git_enabled": False,
                    "error": "Git operations not available - not in a git repository",
                    "staged_files": [],
                    "staged_count": 0,
                    "repository_path": repo_path,
                }
    
            status = target_service.get_repository_status()
    
            return {
                "git_enabled": True,
                "staged_files": status.get("staged_files", []),
                "staged_count": status.get("staged_files_count", 0),
                "repository_path": status.get("repository_path"),
                "staging_clean": status.get("staging_clean", True),
                "repository_status": status,
                "success": True,
            }
    
        except Exception as e:
            logger.error(f"Failed to get git status: {e}")
            return {
                "git_enabled": False,
                "error": str(e),
                "staged_files": [],
                "staged_count": 0,
                "repository_path": repo_path,
                "success": False,
            }
  • Module imports that trigger registration of all MCP tools via @mcp.tool() decorators, including git_tools.py which contains get_git_status.
    from .server import message_tools
    from .server import git_tools
    from .server import workflow_tools
    from .server import enhanced_tools
    from .server import resources
  • Explicit re-export of git tools including get_git_status for backward compatibility and module API.
    # Git tools
    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,
    )
  • Docstring providing input/output schema description for the tool.
    """
    Get current git repository status and staged files.
    
    Args:
        repo_path: Path to git repository
    
    Returns:
        Dict containing:
        - git_enabled: Whether git operations are available
        - staged_files: List of staged file paths
        - staged_count: Number of staged files
        - repository_path: Path to git repository
        - repository_status: Additional status information
    """

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