github_list_branches
Retrieve branch information from any GitHub repository to track development work, manage code versions, and understand project structure.
Instructions
List branches in a GitHub repository.
Args: repo_name: Full repository name (e.g., "owner/repo") limit: Maximum number of branches to return (default: 20)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| repo_name | Yes |
Implementation Reference
- mpo_mcp/server.py:82-90 (handler)MCP tool handler for 'github_list_branches'. Decorated with @mcp.tool() to register and execute the tool, delegating to GitHubTools.list_branches.@mcp.tool() async def github_list_branches(repo_name: str, limit: int = 20) -> list: """List branches in a GitHub repository. Args: repo_name: Full repository name (e.g., "owner/repo") limit: Maximum number of branches to return (default: 20) """ return await github_tools.list_branches(repo_name=repo_name, limit=limit)
- mpo_mcp/github_tools.py:216-252 (helper)Core helper method in GitHubTools class that implements the branch listing logic using PyGithub library, fetching repository branches and formatting results.async def list_branches( self, repo_name: str, limit: int = 20 ) -> List[Dict[str, Any]]: """ List branches in a repository. Args: repo_name: Full repository name (e.g., "owner/repo") limit: Maximum number of branches to return Returns: List of branch information """ self._check_client() try: repo = self.client.get_repo(repo_name) branches = repo.get_branches() results = [] for i, branch in enumerate(branches): if i >= limit: break results.append( { "name": branch.name, "protected": branch.protected, "commit_sha": branch.commit.sha, } ) return results except GithubException as e: logger.error(f"GitHub API error: {e}") raise ValueError(f"Failed to list branches: {str(e)}")