Skip to main content
Glama
archish9

GitHub MCP Server

by archish9

commit_all_changes

Stage all changes and create a commit with a descriptive message to save project progress. Automatically initializes the repository if needed and returns the commit SHA.

Instructions

Stage ALL changes (including untracked files) and create a commit.

This tool acts as a "save point" for the project. It performs the equivalent of:

  1. git add -A (Stages all modified, deleted, and new files)

  2. git commit -m "message"

It will automatically initialize the repository if it hasn't been initialized yet.

Args: repo_path: The absolute path to the repository. message: A descriptive commit message. Common prefixes: 'feat:', 'fix:', 'docs:', 'refactor:', 'test:'.

Returns: The SHA (full hash) of the new commit, or a message indicating "No changes to commit" if the working directory was clean.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
messageYes

Implementation Reference

  • The commit_all_changes MCP tool handler. This async function stages all changes (including untracked files) and creates a commit. It uses the @mcp.tool() decorator for registration and calls GitManager.commit_all() to perform the actual git operations.
    async def commit_all_changes(
        repo_path: str,
        message: str,
    ) -> str:
        """Stage ALL changes (including untracked files) and create a commit.
        
        This tool acts as a "save point" for the project. It performs the equivalent of:
        1. `git add -A` (Stages all modified, deleted, and new files)
        2. `git commit -m "message"`
        
        It will automatically initialize the repository if it hasn't been initialized yet.
        
        Args:
            repo_path: The absolute path to the repository.
            message: A descriptive commit message. 
                     Common prefixes: 'feat:', 'fix:', 'docs:', 'refactor:', 'test:'.
            
        Returns:
            The SHA (full hash) of the new commit, or a message indicating "No changes to commit" 
            if the working directory was clean.
        """
        manager = GitManager(repo_path)
        
        # Lazy initialization for mutating operations
        if not manager.is_initialized():
            manager.initialize(initial_commit=False)
        
        return manager.commit_all(message)
  • The GitManager.commit_all() method that implements the actual git operations. It stages all changes using 'git add -A', checks if there are changes to commit, and creates a commit with the provided message, returning the commit SHA.
    def commit_all(self, message: str) -> str:
        """Stage all changes and commit.
        
        Args:
            message: Commit message
            
        Returns:
            Commit SHA
        """
        repo = self.repo
    
        # Stage all changes
        repo.git.add(A=True)
    
        # Check if there are changes to commit
        if not repo.index.diff("HEAD") and not repo.untracked_files:
            return "No changes to commit"
    
        # Commit
        commit = repo.index.commit(message)
        return commit.hexsha
  • The register_tools function that sets up the MCP server and registers all tools including commit_all_changes. This function is called from server.py to initialize all available MCP tools.
    def register_tools(mcp: FastMCP, default_repo_path: str | None = None):
        """Register all MCP tools on the server.
        
        Args:
            mcp: MCP server instance
            default_repo_path: Default repository path (can be overridden per-call)
        """
        
        def get_manager(repo_path: str | None = None) -> GitManager:
            """Get GitManager for the specified or default repo path."""
            path = repo_path or default_repo_path
            if not path:
                raise ValueError("repo_path is required (no default configured)")
            return GitManager(path)

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/archish9/github-mcp-small'

If you have feedback or need assistance with the MCP directory API, please join our Discord server