Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_stash

Save uncommitted changes temporarily to switch branches or clean your working directory, then restore them later when needed.

Instructions

Create or apply a stash.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
actionNoStash action (save, pop, apply, list, drop)save
messageNoStash message (for save action)
indexNoStash index (for pop, apply, drop actions)

Implementation Reference

  • Core handler function implementing git stash operations (save, pop, apply, list, drop) using simpleGit.
    export async function handleGitStash({
      repo_path,
      action = "save",
      message = "",
      index = 0,
    }) {
      try {
        const git = simpleGit(repo_path);
    
        let result;
        switch (action) {
          case "save":
            result = await git.stash(["save", message]);
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    {
                      success: true,
                      message: "Changes stashed successfully",
                      stash_message: message,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
    
          case "pop":
            result = await git.stash(["pop", index.toString()]);
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    {
                      success: true,
                      message: `Applied and dropped stash@{${index}}`,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
    
          case "apply":
            result = await git.stash(["apply", index.toString()]);
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    {
                      success: true,
                      message: `Applied stash@{${index}}`,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
    
          case "list":
            result = await git.stash(["list"]);
            // Parse the stash list
            const stashList = result
              .trim()
              .split("\n")
              .filter((line) => line.trim() !== "")
              .map((line) => {
                const match = line.match(/stash@\{(\d+)\}: (.*)/);
                if (match) {
                  return {
                    index: parseInt(match[1]),
                    description: match[2],
                  };
                }
                return null;
              })
              .filter((item) => item !== null);
    
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    {
                      success: true,
                      stashes: stashList,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
    
          case "drop":
            result = await git.stash(["drop", index.toString()]);
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    {
                      success: true,
                      message: `Dropped stash@{${index}}`,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
    
          default:
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    { error: `Unknown stash action: ${action}` },
                    null,
                    2
                  ),
                },
              ],
              isError: true,
            };
        }
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to perform stash operation: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Tool schema definition including input parameters and validation for git_stash.
      name: "git_stash",
      description: "Create or apply a stash.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          action: {
            type: "string",
            description: "Stash action (save, pop, apply, list, drop)",
            default: "save",
            enum: ["save", "pop", "apply", "list", "drop"],
          },
          message: {
            type: "string",
            description: "Stash message (for save action)",
            default: "",
          },
          index: {
            type: "integer",
            description: "Stash index (for pop, apply, drop actions)",
            default: 0,
          },
        },
        required: ["repo_path"],
      },
    },
  • src/server.js:914-914 (registration)
    Registers the 'git_stash' tool name to the handleGitStash function in the central handlersMap.
    git_stash: handleGitStash,
  • Imports the handleGitStash handler from its implementation file for re-export.
    import { handleGitStash } from "./stash-operations.js";
  • Re-exports handleGitStash from handlers/index.js to make it available to server.js.
    handleGitStash,
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. 'Create or apply a stash' implies mutation (creating or modifying stashes), but it doesn't clarify critical behaviors: whether operations are destructive (e.g., 'pop' removes a stash), permission requirements, error conditions, or what happens on success/failure. For a tool with multiple actions including potentially destructive ones like 'drop', this is a significant gap.

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 at three words, front-loaded with the core purpose, and wastes no space. Every word earns its place by covering both creation and application of stashes, making it efficient for quick understanding.

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 stash tool with multiple actions (some potentially destructive like 'drop'), no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, usage context, return values, or error handling, leaving significant gaps for an agent to operate safely and 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?

Schema description coverage is 100%, so the schema fully documents all parameters (repo_path, action, message, index) with descriptions and defaults. The description adds no parameter-specific information beyond implying 'create' maps to 'save' and 'apply' to 'apply/pop', but this is minimal value. The baseline score of 3 reflects adequate coverage from the schema alone.

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 'Create or apply a stash' clearly states the verb ('create or apply') and resource ('stash'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from sibling Git tools like 'git_commit' or 'git_reset', which also handle repository state changes, leaving room for confusion about when to use this specific stash functionality.

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., uncommitted changes), compare to other state-management tools like 'git_commit' or 'git_reset', or specify scenarios where stashing is appropriate (e.g., temporarily saving work before switching branches). This lack of context makes it hard for an agent to decide when to invoke 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/bsreeram08/git-commands-mcp'

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