Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_add

Stage files for commit in Git repositories. Use this tool to prepare file changes for version control by adding them to the staging area before committing.

Instructions

Stage files for commit. Use "." to stage all changes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile(s) to stage. Use "." for all files
cwdNoRepository directory

Implementation Reference

  • The core handler function that processes input arguments, formats the git add command, and executes it via the shared executeGitCommand helper.
    export async function gitAdd(args: z.infer<typeof gitAddSchema>): Promise<ToolResponse> {
      const files = Array.isArray(args.files) ? args.files.join(' ') : args.files;
      return executeGitCommand(`git add ${files}`, args.cwd);
    }
  • Zod schema used for input validation in the git_add handler and dispatch.
    export const gitAddSchema = z.object({
      files: z.union([z.string(), z.array(z.string())]).describe('File(s) to stage. Use "." for all files'),
      cwd: z.string().optional().describe('Repository directory')
    });
  • src/index.ts:361-364 (registration)
    Dispatch logic in the main MCP server that routes 'git_add' tool calls to the handler after schema validation.
    if (name === 'git_add') {
      const validated = gitAddSchema.parse(args);
      return await gitAdd(validated);
    }
  • MCP tool registration object defining name, description, and JSON input schema for tool listing.
    {
      name: 'git_add',
      description: 'Stage files for commit. Use "." to stage all changes',
      inputSchema: {
        type: 'object',
        properties: {
          files: {
            oneOf: [
              { type: 'string' },
              { type: 'array', items: { type: 'string' } }
            ],
            description: 'File(s) to stage. Use "." for all files'
          },
          cwd: { type: 'string', description: 'Repository directory' }
        },
        required: ['files']
      }
    },
  • Shared helper function that executes git commands asynchronously and formats success/error responses.
    async function executeGitCommand(command: string, cwd?: string): Promise<ToolResponse> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: cwd || process.cwd(),
          shell: '/bin/bash',
          maxBuffer: 10 * 1024 * 1024 // 10MB buffer
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: true,
                command: command,
                stdout: stdout.trim(),
                stderr: stderr.trim(),
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: false,
                command: command,
                stdout: error.stdout?.trim() || '',
                stderr: error.stderr?.trim() || error.message,
                exitCode: error.code || 1,
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
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. It mentions staging files but does not disclose behavioral traits such as whether this is a read-only or mutating operation (it mutates the staging area), what happens on errors, or if it requires a Git repository to be initialized. The description is minimal and lacks critical behavioral context for a mutation tool.

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 two sentences with zero waste—front-loaded with the core purpose and followed by a practical usage tip. Every sentence earns its place by adding value without redundancy.

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

Completeness3/5

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

Given no annotations and no output schema, the description is incomplete for a mutation tool. It covers the basic purpose and a parameter tip, but lacks details on behavioral aspects (e.g., effects, error handling) and return values. It is minimally adequate but has clear gaps in context.

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?

Schema description coverage is 100%, so the schema already documents both parameters (files and cwd) with descriptions. The description adds marginal value by reiterating the '.' usage for files, but does not provide additional meaning beyond what the schema specifies. Baseline 3 is appropriate as the schema does the heavy lifting.

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 clearly states the specific action ('Stage files for commit') and resource ('files'), distinguishing it from sibling Git tools like git_commit (which commits staged changes) or git_status (which shows status). The mention of '.' for all changes adds specificity about scope.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (to prepare files for a commit) and includes a practical tip (use '.' for all changes). However, it does not explicitly state when not to use it or name alternatives (e.g., git_reset to unstage), though the sibling list implies a workflow context.

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/ConnorBoetig-dev/mcp2'

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