git_commit
Record changes to a Git repository by creating a commit with a message for a given repository path.
Instructions
Records changes to the repository
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| message | Yes |
Implementation Reference
- The git_commit handler function that creates a commit using repo.index.commit(message) and returns the commit hash.
def git_commit(repo: git.Repo, message: str) -> str: commit = repo.index.commit(message) return f"Changes committed successfully with hash {commit.hexsha}" - GitCommit Pydantic model defining the input schema for the git_commit tool with fields: repo_path (str) and message (str).
class GitCommit(BaseModel): repo_path: str message: str - src/git/src/mcp_server_git/server.py:96-101 (registration)GitTools enum defining COMMIT = 'git_commit' as the tool name constant.
class GitTools(str, Enum): STATUS = "git_status" DIFF_UNSTAGED = "git_diff_unstaged" DIFF_STAGED = "git_diff_staged" DIFF = "git_diff" COMMIT = "git_commit" - src/git/src/mcp_server_git/server.py:353-363 (registration)Tool registration in the list_tools() function, binding the name 'git_commit' (GitTools.COMMIT) to GitCommit schema with description 'Records changes to the repository'.
Tool( name=GitTools.COMMIT, description="Records changes to the repository", inputSchema=GitCommit.model_json_schema(), annotations=ToolAnnotations( readOnlyHint=False, destructiveHint=False, idempotentHint=False, openWorldHint=False, ), ), - src/git/src/mcp_server_git/server.py:511-516 (registration)Dispatch in call_tool() that invokes the git_commit handler when the tool name matches GitTools.COMMIT, passing the 'message' argument.
case GitTools.COMMIT: result = git_commit(repo, arguments["message"]) return [TextContent( type="text", text=result )]