stash_list
Retrieve a list of Git stashes from a specified repository path using the Git MCP Server. Supports absolute paths for seamless repository access and management.
Instructions
List stashes
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "stash_list"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Path to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo) |
Implementation Reference
- src/git-operations.ts:692-719 (handler)The core handler function that executes the `git stash list` command within the specified repository path, handles caching, validation, and error handling, and returns the list of stashes as a GitToolResult.
static async stashList(options: BasePathOptions, context: GitToolContext): Promise<GitToolResult> { const path = this.getPath(options); return await this.executeOperation( context.operation, path, async () => { const { path: repoPath } = PathValidator.validateGitRepo(path); const result = await CommandExecutor.executeGitCommand( 'stash list', context.operation, repoPath ); const output = result.stdout.trim(); return { content: [{ type: 'text', text: output || 'No stashes found' }] }; }, { useCache: true, stateType: RepoStateType.STASH, command: 'stash list' } ); } - src/tool-handler.ts:423-436 (registration)Registers the 'stash_list' tool with the MCP server in the ListTools response, defining its name, description, and input schema.
{ name: 'stash_list', description: 'List stashes', inputSchema: { type: 'object', properties: { path: { type: 'string', description: `Path to repository. ${PATH_DESCRIPTION}`, }, }, required: [], }, }, - src/tool-handler.ts:653-656 (helper)The switch case dispatcher in the tool executor that validates arguments using isPathOnly and calls the GitOperations.stashList handler.
case 'stash_list': { const validArgs = this.validateArguments(operation, args, isPathOnly); return await GitOperations.stashList(validArgs, context); } - src/types.ts:35-42 (schema)Type definition for BasePathOptions used as the input type for stash_list tool.
export interface BasePathOptions { /** * MUST be an absolute path to the repository * Example: /Users/username/projects/my-repo * If not provided, will use GIT_DEFAULT_PATH from environment */ path?: string; } - src/types.ts:198-200 (schema)Type guard function isPathOnly used to validate input arguments for path-only tools like stash_list.
export function isPathOnly(obj: any): obj is BasePathOptions { return obj && validatePath(obj.path); }