Skip to main content
Glama
modelcontextprotocol

git MCP server

Official

git_add

Idempotent

Stage files in a Git repository. Prepares specified files for commit by adding their current contents to the staging area.

Instructions

Adds file contents to the staging area

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
filesYes

Implementation Reference

  • The git_add function: executes the 'git add' logic. If files is ['.'], runs 'git add .' to stage all changes. Otherwise uses 'git add -- <files>' to safely stage specific files (the '--' prevents file names starting with '-' from being interpreted as options). Returns 'Files staged successfully'.
    def git_add(repo: git.Repo, files: list[str]) -> str:
        if files == ["."]:
            repo.git.add(".")
        else:
            # Use '--' to prevent files starting with '-' from being interpreted as options
            repo.git.add("--", *files)
        return "Files staged successfully"
  • GitAdd Pydantic model: defines the input schema for the git_add tool with two fields: 'repo_path' (str) and 'files' (list[str]).
    class GitAdd(BaseModel):
        repo_path: str
        files: list[str]
  • Enum registration: GitTools.ADD = 'git_add' registers the tool name used throughout the codebase.
    class GitTools(str, Enum):
        STATUS = "git_status"
        DIFF_UNSTAGED = "git_diff_unstaged"
        DIFF_STAGED = "git_diff_staged"
        DIFF = "git_diff"
        COMMIT = "git_commit"
        ADD = "git_add"
  • Tool registration in list_tools(): registers the 'git_add' tool with description 'Adds file contents to the staging area' and inputSchema from GitAdd.model_json_schema(). Annotations indicate it is not readOnly, not destructive, and idempotent.
    Tool(
        name=GitTools.ADD,
        description="Adds file contents to the staging area",
        inputSchema=GitAdd.model_json_schema(),
        annotations=ToolAnnotations(
            readOnlyHint=False,
            destructiveHint=False,
            idempotentHint=True,
            openWorldHint=False,
        ),
    ),
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare idempotentHint=true and destructiveHint=false, covering safety. The description adds no extra behavioral context beyond what annotations provide, such as behavior with non-existent files or overwriting staging.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, making it very concise. However, it lacks structure; integrating parameter explanations or usage context would improve it without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity, the description is incomplete: no info on output, error handling, or parameter details. Context signals show no output schema, so the description shoulders more responsibility, which it fails to meet.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description does not explain the two required parameters (repo_path, files). The agent has no context on file path formats, glob patterns, or required directory specifications.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Adds file contents to the staging area' uses a specific verb and resource, clearly distinguishing it from sibling tools like git_commit (which commits staged changes) or git_branch (branch management).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives, such as using it before git_commit or how to add specific files. The description does not mention prerequisites, typical workflow, or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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