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:
git add -A(Stages all modified, deleted, and new files)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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| message | Yes |
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 - src/version_control_helper_mcp/tools.py:11-24 (registration)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)