Skip to content

Enhance git add to support batch operations and deletions #25

@MementoRC

Description

@MementoRC

Problem Description

The current mcp__git__git_add tool has significant limitations that make it difficult to handle common git workflows:

Current Issues:

  1. Cannot add deleted files - Returns "Files not found" error
  2. No batch operation support - No equivalent to git add -A or git add -u
  3. Requires explicit file paths - No wildcard or pattern support
  4. Cannot stage directory deletions - Manual workarounds required

Observed Error Example:

❌ Files not found: reports/health_score.txt, reports/maintenance_needed.txt, reports/project_health.json

Proposed Solution

Extend existing tool with new parameters:

mcp__git__git_add({
  repo_path: string,
  files?: string[],              // existing
  add_all?: boolean,             // equivalent to git add -A
  update_only?: boolean,         // equivalent to git add -u
  include_deletions?: boolean,   // handle deleted files
  patterns?: string[]            // glob patterns like "*.py"
})

Use Cases

1. CI Fix Workflows

// Stage all changes including deletions (common in CI cleanup)
mcp__git__git_add({repo_path: ".", add_all: true})

// Stage only tracked file updates and deletions
mcp__git__git_add({repo_path: ".", update_only: true})

2. Cleanup Operations

// Stage deletion of temporary files
mcp__git__git_add({
  repo_path: ".", 
  files: ["reports/temp.txt", "cache/old.json"], 
  include_deletions: true
})

Impact

This was the primary blocker during a recent CI fix session, forcing workarounds like:

  • Manual file deletion instead of proper git staging
  • Using bash commands, defeating MCP integration benefits
  • Complex multi-step operations for simple batch adds

Implementation Notes

  • Maintain backward compatibility with existing files parameter
  • Add validation for conflicting parameters (e.g., add_all + files)
  • Provide clear error messages for invalid combinations

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions