Skip to main content
Glama

stash_pop

Apply and remove a Git stash from a specified repository path using the stash index. Part of the Git MCP Server, enabling enhanced Git operations for efficient repository management.

Instructions

Apply and remove a stash

Input Schema

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

Implementation Reference

  • The primary handler function that executes the 'git stash pop' command, validates the repository, handles caching invalidation, and formats the response.
    static async stashPop({ path, index = 0 }: StashOptions, context: GitToolContext): Promise<GitToolResult> {
      const resolvedPath = this.getPath({ path });
      return await this.executeOperation(
        context.operation,
        resolvedPath,
        async () => {
          const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath);
          const result = await CommandExecutor.executeGitCommand(
            `stash pop stash@{${index}}`,
            context.operation,
            repoPath
          );
    
          return {
            content: [{
              type: 'text',
              text: `Stash applied successfully\n${CommandExecutor.formatOutput(result)}`
            }]
          };
        },
        {
          command: 'stash_pop',
          invalidateCache: true, // Invalidate stash and status caches
          stateType: RepoStateType.STASH
        }
      );
    }
  • The input schema definition for the stash_pop tool, registered in the ListTools handler, defining parameters path and index.
    {
      name: 'stash_pop',
      description: 'Apply and remove a stash',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: `Path to repository. ${PATH_DESCRIPTION}`,
          },
          index: {
            type: 'number',
            description: 'Stash index',
            default: 0,
          },
        },
        required: [],
      },
    },
  • The switch case in the CallToolRequest handler that validates arguments using isStashOptions and dispatches to GitOperations.stashPop.
    case 'stash_pop': {
      const validArgs = this.validateArguments(operation, args, isStashOptions);
      return await GitOperations.stashPop(validArgs, context);
    }
  • TypeScript interface StashOptions defining the input parameters for stash operations, used for type checking and validation.
    export interface StashOptions extends GitOptions, BasePathOptions {
      message?: string;
      index?: number;
      includeUntracked?: boolean;  // Include untracked files
      keepIndex?: boolean;  // Keep staged changes
      all?: boolean;  // Include ignored files
    }
  • Type guard function isStashOptions used to validate input arguments before calling the handler.
    export function isStashOptions(obj: any): obj is StashOptions {
      return obj && validatePath(obj.path);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Apply and remove a stash' implies a destructive operation (removing the stash after applying), but it doesn't clarify critical behaviors: whether this requires a clean working directory, what happens if conflicts occur during application, whether the operation is reversible, or what the typical output/confirmation looks like. The description is too minimal 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 extremely concise at just three words ('Apply and remove a stash'), with zero wasted words. It's front-loaded with the core action and resource. While it may be too brief for completeness, it earns full marks for conciseness.

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 this is a destructive mutation tool with no annotations and no output schema, the description is insufficiently complete. It should explain more about the behavioral implications (conflict handling, irreversibility), typical usage patterns, and what to expect after execution. The current description leaves too many open questions for safe and effective use.

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%, with both parameters ('index' and 'path') well-documented in the schema. The description adds no additional parameter semantics beyond what the schema already provides (e.g., it doesn't explain what 'stash index' means in practice or provide examples of when to use index vs default). This meets the baseline for high schema coverage.

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 'Apply and remove a stash' clearly states the action (apply and remove) and resource (a stash), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'stash_list' or 'stash_save', which would require more specific language about this being a destructive operation that both applies stash changes and deletes the stash.

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 when to choose 'stash_pop' over 'stash_list' (for viewing) or 'stash_save' (for creating), nor does it specify prerequisites like having stashes available or being in a git repository 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

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