git_add
Adds file contents to the staging area in a Git repository to prepare changes for committing. Use this tool to stage specific files before creating a commit.
Instructions
Adds file contents to the staging area
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| files | Yes |
Implementation Reference
- Pydantic model defining the input schema for the git_add tool, including repo_path (str) and files (list[str]).class GitAdd(BaseModel): repo_path: str files: list[str]
- Core handler function for git_add tool. Stages specified files (or all with ".") using GitPython's repo.git.add or repo.index.add, returns success message.def git_add(repo: git.Repo, files: list[str]) -> str: if files == ["."]: repo.git.add(".") else: repo.index.add(files) return "Files staged successfully"
- src/git/src/mcp_server_git/server.py:313-316 (registration)Registers the git_add tool (name='git_add' via GitTools.ADD) in the MCP server's list_tools() with description and input schema from GitAdd model.name=GitTools.ADD, description="Adds file contents to the staging area", inputSchema=GitAdd.model_json_schema(), ),
- src/git/src/mcp_server_git/server.py:101-101 (registration)Enum value in GitTools defining the tool name 'git_add'.ADD = "git_add"
- Dispatcher in call_tool() that invokes git_add handler with repo and files from arguments, wraps result in TextContent for MCP response.case GitTools.ADD: result = git_add(repo, arguments["files"]) return [TextContent( type="text", text=result )]