git_add
Add files to the staging area in a Git repository using the MCP Git Server. Specify the repository path and files to prepare them for commit, streamlining version control workflows.
Instructions
Adds file contents to the staging area
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | ||
| repo_path | Yes |
Implementation Reference
- src/mcp_server_git/server.py:93-95 (handler)The git_add handler function stages the specified files in the Git repository 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-39 (schema)Pydantic BaseModel 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() method, 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 (registration)Tool dispatch logic in call_tool() that invokes the git_add handler with arguments from the tool call.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"