Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_stash

Save uncommitted changes temporarily to switch branches or tasks, then restore them later when needed. Manage stashed changes with push, pop, list, apply, drop, and clear operations.

Instructions

Stash changes in working directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoRepository directory
actionNoStash actionpush
messageNoStash message (for push)
indexNoStash index (for pop/apply/drop)

Implementation Reference

  • The main handler function that implements the git_stash tool logic, handling different stash actions like push, pop, list, apply, drop, and clear using git commands.
    export async function gitStash(args: z.infer<typeof gitStashSchema>): Promise<ToolResponse> {
      switch (args.action) {
        case 'push':
          const message = args.message ? `-m "${args.message}"` : '';
          return executeGitCommand(`git stash push ${message}`.trim(), args.cwd);
        case 'pop':
          const popIndex = args.index !== undefined ? `stash@{${args.index}}` : '';
          return executeGitCommand(`git stash pop ${popIndex}`.trim(), args.cwd);
        case 'list':
          return executeGitCommand('git stash list', args.cwd);
        case 'apply':
          const applyIndex = args.index !== undefined ? `stash@{${args.index}}` : '';
          return executeGitCommand(`git stash apply ${applyIndex}`.trim(), args.cwd);
        case 'drop':
          const dropIndex = args.index !== undefined ? `stash@{${args.index}}` : '';
          return executeGitCommand(`git stash drop ${dropIndex}`.trim(), args.cwd);
        case 'clear':
          return executeGitCommand('git stash clear', args.cwd);
        default:
          return {
            content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Invalid stash action' }, null, 2) }],
            isError: true
          };
      }
    }
  • Zod schema used for input validation of git_stash tool arguments in the dispatch handler.
    export const gitStashSchema = z.object({
      cwd: z.string().optional().describe('Repository directory'),
      action: z.enum(['push', 'pop', 'list', 'apply', 'drop', 'clear']).optional().default('push').describe('Stash action'),
      message: z.string().optional().describe('Stash message (for push)'),
      index: z.number().optional().describe('Stash index (for pop/apply/drop)')
    });
  • src/index.ts:417-419 (registration)
    Dispatch logic in the main MCP server that registers and routes 'git_stash' tool calls to the handler function after validation.
    if (name === 'git_stash') {
      const validated = gitStashSchema.parse(args);
      return await gitStash(validated);
  • MCP tool definition including name, description, and input schema advertised in the listTools response.
    {
      name: 'git_stash',
      description: 'Stash changes in working directory',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: { type: 'string', description: 'Repository directory' },
          action: { type: 'string', enum: ['push', 'pop', 'list', 'apply', 'drop', 'clear'], default: 'push', description: 'Stash action' },
          message: { type: 'string', description: 'Stash message (for push)' },
          index: { type: 'number', description: 'Stash index (for pop/apply/drop)' }
        }
      }
    },
  • Shared helper function that executes git commands via child_process.exec and formats the ToolResponse.
    async function executeGitCommand(command: string, cwd?: string): Promise<ToolResponse> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: cwd || process.cwd(),
          shell: '/bin/bash',
          maxBuffer: 10 * 1024 * 1024 // 10MB buffer
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: true,
                command: command,
                stdout: stdout.trim(),
                stderr: stderr.trim(),
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: false,
                command: command,
                stdout: error.stdout?.trim() || '',
                stderr: error.stderr?.trim() || error.message,
                exitCode: error.code || 1,
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
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. 'Stash changes' implies a write operation that temporarily saves modifications, but the description doesn't clarify what happens to working directory changes after stashing, whether stashes persist across sessions, or potential side effects like conflicts during pop/apply. It mentions the action but lacks details about the tool's behavior beyond the basic concept.

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 a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately sized for a tool with comprehensive schema documentation and gets straight to the point with zero wasted text.

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?

For a Git operation tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what stashing actually does behaviorally, when to use different actions, what the tool returns, or error conditions. The combination of mutation capability and lack of structured documentation means the description should provide more context about this tool's operation.

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 already documents all 4 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. It mentions 'stash' which aligns with the action parameter but provides no additional context about parameter usage, relationships, or edge cases. Baseline 3 is appropriate when schema does the heavy lifting.

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 'Stash changes in working directory' clearly states the verb ('stash') and resource ('changes in working directory'), making the purpose immediately understandable. It distinguishes this tool from sibling Git tools like git_commit or git_reset by focusing specifically on stashing operations. However, it doesn't explicitly differentiate from all siblings beyond the Git category.

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 stashing is appropriate (e.g., before switching branches with uncommitted changes) or when other tools might be better (e.g., git_commit for permanent changes). No context about prerequisites or typical workflows is provided.

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/ConnorBoetig-dev/mcp2'

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