Skip to main content
Glama

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
NameRequiredDescriptionDefault
repo_pathYes
filesYes

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"
  • 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(), ),
  • 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 )]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/modelcontextprotocol/git'

If you have feedback or need assistance with the MCP directory API, please join our Discord server