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); }

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