Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_clean

Remove untracked files and directories from a Git repository to clean up workspace clutter. Specify repository path, directory removal, force options, or dry run to preview changes.

Instructions

Perform git clean operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
directoriesNoWhether to remove directories as well
forceNoWhether to force clean
dry_runNoWhether to perform a dry run

Implementation Reference

  • Implements the git clean tool logic using simpleGit. Supports dry-run previews, force removal, and directory cleaning with safety checks.
    export async function handleGitClean({
      repo_path,
      directories = false,
      force = false,
      dry_run = true,
    }) {
      try {
        const git = simpleGit(repo_path);
    
        // At least one of force or dry_run must be true for safety
        if (!force && !dry_run) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  { error: "For safety, either force or dry_run must be true" },
                  null,
                  2
                ),
              },
            ],
            isError: true,
          };
        }
    
        // Build the clean command
        const cleanOptions = [];
    
        if (directories) {
          cleanOptions.push("-d");
        }
    
        if (force) {
          cleanOptions.push("-f");
        }
    
        if (dry_run) {
          cleanOptions.push("-n");
        }
    
        // Get the files that would be removed
        const preview = await git.clean([
          "--dry-run",
          ...(directories ? ["-d"] : []),
        ]);
        const filesToRemove = preview
          .split("\n")
          .filter((line) => line.startsWith("Would remove"))
          .map((line) => line.replace("Would remove ", "").trim());
    
        if (!dry_run) {
          // Perform the actual clean
          await git.clean(cleanOptions);
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: true,
                  message: dry_run
                    ? `Would remove ${filesToRemove.length} files/directories`
                    : `Removed ${filesToRemove.length} files/directories`,
                  files: filesToRemove,
                  dry_run: dry_run,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to clean repository: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Defines the input schema and metadata for the 'git_clean' tool used in tool listing and validation.
      name: "git_clean",
      description: "Perform git clean operations.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          directories: {
            type: "boolean",
            description: "Whether to remove directories as well",
            default: false,
          },
          force: {
            type: "boolean",
            description: "Whether to force clean",
            default: false,
          },
          dry_run: {
            type: "boolean",
            description: "Whether to perform a dry run",
            default: true,
          },
        },
        required: ["repo_path"],
      },
    },
  • src/server.js:922-922 (registration)
    Maps the tool name 'git_clean' to its handler function in the central handlersMap for request dispatching.
    git_clean: handleGitClean,
  • Imports the handleGitClean function from other-operations.js for re-export.
    handleGitClean,
  • src/server.js:33-38 (registration)
    Imports handleGitClean from handlers/index.js into the server for use in handlersMap.
      handleGitClean,
      handleGitHooks,
      handleGitLFS,
      handleGitLFSFetch,
      handleGitRevert,
    } from "./handlers/index.js";
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Perform git clean operations' implies a destructive action (cleaning/removing files), but it doesn't specify what gets removed (e.g., untracked files), safety implications, or output behavior. It lacks critical details like whether this is irreversible or what happens during execution, which is essential for a tool with potential data loss.

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, efficient sentence with no wasted words. It's appropriately sized for a tool with a clear name, though it could be more informative. The structure is front-loaded but lacks elaboration that might be needed given the tool's complexity and potential risks.

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 complexity (a destructive Git operation with 4 parameters), no annotations, and no output schema, the description is incomplete. It doesn't explain what 'git clean' does, its effects, or return values, leaving significant gaps for safe and effective use. A more detailed description is needed to compensate for the lack of structured data.

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 fully documents all four parameters (repo_path, directories, force, dry_run). The description adds no parameter-specific information beyond what's in the schema, such as explaining interactions between parameters (e.g., how 'force' and 'dry_run' affect safety). This meets the baseline score of 3 when schema coverage is high.

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

Purpose3/5

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

The description 'Perform git clean operations' states the action but is vague about what 'git clean' specifically does. It doesn't distinguish this tool from sibling Git tools like git_reset or git_stash, which also perform repository maintenance operations. However, it does identify the correct verb ('perform') and resource ('git clean operations'), avoiding tautology.

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., a clean working directory), when it's appropriate (e.g., removing untracked files), or what sibling tools might be better for related tasks (e.g., git_reset for tracked files). This leaves the agent with minimal context for tool selection.

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/bsreeram08/git-commands-mcp'

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