Skip to main content
Glama

stash_save

Save uncommitted changes to a Git stash with a custom message. Optionally include untracked files, preserve staged changes, or add ignored files for flexible repository management.

Instructions

Save changes to stash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allNoInclude ignored files
includeUntrackedNoInclude untracked files
keepIndexNoKeep staged changes
messageNoStash message
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)

Implementation Reference

  • The core handler function that constructs and executes the 'git stash' command with appropriate flags based on the provided StashOptions.
    static async stashSave({ path, message, includeUntracked, keepIndex, all }: StashOptions, context: GitToolContext): Promise<GitToolResult> {
      const resolvedPath = this.getPath({ path });
      return await this.executeOperation(
        context.operation,
        resolvedPath,
        async () => {
          const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath);
          let command = 'stash';
          if (typeof message === 'string' && message.length > 0) {
            command += ` save "${message}"`;
          }
          if (includeUntracked) {
            command += ' --include-untracked';
          }
          if (keepIndex) {
            command += ' --keep-index';
          }
          if (all) {
            command += ' --all';
          }
          const result = await CommandExecutor.executeGitCommand(
            command,
            context.operation,
            repoPath
          );
    
          return {
            content: [{
              type: 'text',
              text: `Changes stashed successfully\n${CommandExecutor.formatOutput(result)}`
            }]
          };
        },
        {
          command: 'stash_save',
          invalidateCache: true, // Invalidate stash and status caches
          stateType: RepoStateType.STASH
        }
      );
    }
  • Registers the 'stash_save' tool with the MCP server, including its description and input schema definition.
    {
      name: 'stash_save',
      description: 'Save changes to stash',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: `Path to repository. ${PATH_DESCRIPTION}`,
          },
          message: {
            type: 'string',
            description: 'Stash message',
          },
          includeUntracked: {
            type: 'boolean',
            description: 'Include untracked files',
            default: false
          },
          keepIndex: {
            type: 'boolean',
            description: 'Keep staged changes',
            default: false
          },
          all: {
            type: 'boolean',
            description: 'Include ignored files',
            default: false
          }
        },
        required: [],
      },
    },
  • TypeScript interface defining the shape of parameters accepted by the stash_save tool.
    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 used to validate input arguments conform to StashOptions before dispatching to handler.
    export function isStashOptions(obj: any): obj is StashOptions {
      return obj && validatePath(obj.path);
    }
  • Dispatch handler in the main tool executor switch statement that validates arguments and calls the GitOperations.stashSave implementation.
    case 'stash_save': {
      const validArgs = this.validateArguments(operation, args, isStashOptions);
      return await GitOperations.stashSave(validArgs, context);
    }
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. It states 'Save changes to stash' but doesn't explain what happens to the working directory after saving (e.g., whether changes are removed or kept), authentication needs, error conditions, or side effects. This leaves critical behavioral traits undocumented 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 with a single sentence 'Save changes to stash', which is front-loaded and wastes no words. Every part of the sentence contributes to understanding the tool's purpose, making it efficient and easy to parse.

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 operation (mutating state with multiple parameters) and no annotations or output schema, the description is incomplete. It lacks details on behavior, return values, error handling, and how it interacts with sibling tools like 'stash_pop'. For a tool with 5 parameters and no structured safety hints, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/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 5 parameters. The description doesn't add any parameter-specific details beyond what the schema provides, but with high coverage, a baseline of 3 is appropriate. Since no parameters are required, the description's simplicity aligns well, earning a slightly higher score for not overcomplicating.

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 'Save changes to stash' clearly indicates the action (save) and target (stash), but it's somewhat vague about what 'changes' specifically refers to (e.g., uncommitted modifications). It doesn't differentiate from sibling tools like 'stash_list' or 'stash_pop', which describe listing or applying stashed changes, leaving room for ambiguity in tool selection.

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?

No explicit guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing uncommitted changes), exclusions, or compare to siblings like 'commit' for saving changes permanently. The description implies usage for saving changes temporarily, but lacks context for decision-making.

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