git_add
Stage file changes in a Git repository to prepare them for committing. Specify the repository path and files to add to the staging area.
Instructions
Adds file contents to the staging area
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| files | Yes |
Implementation Reference
- src/mcp_server_git/server.py:93-95 (handler)The core handler function that stages the specified files using the Git repository's index.
def git_add(repo: git.Repo, files: list[str]) -> str: repo.index.add(files) return "Files staged successfully" - src/mcp_server_git/server.py:36-38 (schema)Pydantic model defining the input schema for the git_add tool, including repo_path and list of files.
class GitAdd(BaseModel): repo_path: str files: list[str] - src/mcp_server_git/server.py:196-200 (registration)Registration of the git_add tool in the list_tools handler, specifying name, description, and input schema.
Tool( name=GitTools.ADD, description="Adds file contents to the staging area", inputSchema=GitAdd.schema(), ), - src/mcp_server_git/server.py:313-318 (helper)Dispatcher logic in call_tool that invokes the git_add handler with parsed arguments and formats the response.
case GitTools.ADD: result = git_add(repo, arguments["files"]) return [TextContent( type="text", text=result )] - src/mcp_server_git/server.py:69-69 (helper)Enum constant defining the tool name 'git_add' in GitTools.
ADD = "git_add"