branch_list
Retrieve a detailed list of all branches in a specified Git repository using an absolute path, enabling efficient branch management and repository navigation.
Instructions
List all branches
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": "branch_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:373-400 (handler)The primary handler function for the 'branch_list' tool. It validates the repository path, executes 'git branch -a' via CommandExecutor, formats the output, and handles caching.
static async branchList(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( 'branch -a', context.operation, repoPath ); const output = result.stdout.trim(); return { content: [{ type: 'text', text: output || 'No branches found' }] }; }, { useCache: true, stateType: RepoStateType.BRANCH, command: 'branch -a' } ); } - src/tool-handler.ts:603-606 (registration)Registers the handler dispatch for 'branch_list' tool in the switch statement of the CallToolRequestSchema handler.
case 'branch_list': { const validArgs = this.validateArguments(operation, args, isPathOnly); return await GitOperations.branchList(validArgs, context); } - src/tool-handler.ts:217-229 (schema)Defines the tool schema including name, description, and input schema (path property) for 'branch_list' in the ListToolsRequestSchema response.
{ name: 'branch_list', description: 'List all branches', inputSchema: { type: 'object', properties: { path: { type: 'string', description: `Path to repository. ${PATH_DESCRIPTION}`, }, }, required: [], },