Skip to main content
Glama

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

Input Schema

NameRequiredDescriptionDefault
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)

Input Schema (JSON Schema)

{ "properties": { "path": { "description": "Path to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)", "type": "string" } }, "required": [], "type": "object" }

Implementation Reference

  • 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' } ); }
  • 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); }
  • 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: [], },

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