Skip to main content
Glama

add

Stage files in a Git repository by specifying absolute paths. Integrates with the Git MCP Server to enhance AI-assisted Git operations for efficient version control.

Instructions

Stage files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFiles to stage
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)

Implementation Reference

  • The primary handler function for the 'add' tool. It validates the repository path, executes 'git add' for each specified file, invalidates relevant caches, and returns a success message.
    static async add({ path, files }: AddOptions, context: GitToolContext): Promise<GitToolResult> {
      const resolvedPath = this.getPath({ path });
      return await this.executeOperation(
        context.operation,
        resolvedPath,
        async () => {
          const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath);
          
          // Handle each file individually to avoid path issues
          for (const file of files) {
            await CommandExecutor.executeGitCommand(
              `add "${file}"`,
              context.operation,
              repoPath
            );
          }
    
          return {
            content: [{
              type: 'text',
              text: 'Files staged successfully'
            }]
          };
        },
        {
          command: 'add',
          invalidateCache: true, // Invalidate status cache
          stateType: RepoStateType.STATUS
        }
      );
    }
  • Registers the 'add' tool with MCP server, including its name, description, and input schema for tool listing.
    {
      name: 'add',
      description: 'Stage files',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: `Path to repository. ${PATH_DESCRIPTION}`,
          },
          files: {
            type: 'array',
            items: {
              type: 'string',
              description: FILE_PATH_DESCRIPTION,
            },
            description: 'Files to stage',
          },
        },
        required: ['files'],
      },
    },
  • TypeScript interface defining the input parameters for the 'add' tool.
    export interface AddOptions extends GitOptions, BasePathOptions {
      /**
       * Array of absolute paths to files to stage
       * Example: /Users/username/projects/my-repo/src/file.js
       */
      files: string[];
    }
  • Type guard function used to validate arguments for the 'add' tool before execution.
    export function isAddOptions(obj: any): obj is AddOptions {
      return obj && 
        validatePath(obj.path) && 
        Array.isArray(obj.files) &&
        obj.files.every((f: any) => typeof f === 'string' && isAbsolutePath(f));
    }
  • Dispatch handler in the tool executor that validates arguments and delegates to GitOperations.add.
    case 'add': {
      const validArgs = this.validateArguments(operation, args, isAddOptions);
      return await GitOperations.add(validArgs, context);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Stage files' implies a mutation operation (adding files to the staging area), but it doesn't describe what staging entails (e.g., preparing files for commit), whether it's reversible (e.g., via git reset), or any side effects (e.g., changes to the git index). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is extremely concise with just two words ('Stage files'), which is front-loaded and wastes no space. Every word earns its place by directly conveying the core action and target. This is optimal for a simple tool where the name and parameters provide additional context.

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 complexity of a git staging operation (a mutation with no annotations and no output schema), the description is incomplete. It doesn't explain what staging does in git terms, what the expected outcome is, or any error conditions (e.g., invalid paths). For a tool that modifies repository state, more context is needed to guide the agent effectively.

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

Parameters3/5

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

The schema description coverage is 100%, with clear descriptions for both parameters ('files' and 'path'), including format requirements (absolute paths). The description 'Stage files' implies the 'files' parameter but adds no additional semantic meaning beyond what the schema provides (e.g., it doesn't explain what types of files can be staged or how wildcards might work). Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose4/5

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

The description 'Stage files' clearly states the verb ('stage') and resource ('files'), making the purpose immediately understandable. It distinguishes from siblings like commit, push, or stash_save by focusing specifically on staging rather than committing, pushing, or stashing operations. However, it doesn't explicitly differentiate from all siblings (e.g., it could be more specific about what staging entails versus other git operations).

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a git repository), when staging is appropriate (e.g., before committing), or what alternatives exist (e.g., using commit directly for unstaged files). This lack of context leaves the agent to infer usage from the tool name alone.

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

Related 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/Sheshiyer/git-mcp-v2'

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