Skip to main content
Glama

list_most_recently_checked_out_branches

Track the latest branch activity in your project by listing the n most recently checked out branches. Simply input the project name and desired count to retrieve updated branch data efficiently.

Instructions

List the n most recently checked out branches in the project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nNo
project_nameYes

Implementation Reference

  • Handler function implementing the tool logic. Registered via @mcp.tool() decorator. Defines input schema via type annotations. Calls helper get_recent_branches.
    @mcp.tool()
    @log_inputs_outputs()
    def list_most_recently_checked_out_branches(
        project_name: str,
        n: Annotated[int, Field(ge=20, le=50)] = 20,
    ) -> ToolResponse:
        """List the n most recently checked out branches in the project"""
        project = _get_project_or_error(project_name)
        return MCPToolOutput(text="\n".join(get_recent_branches(project.git_path, n))).render()
  • Core helper function that retrieves the list of recently checked out branches from git reflog.
    def get_recent_branches(repo_path: Path, limit: int = 10) -> list[str]:
        """Get the list of up to `limit` recently checked out branches in the given git repo."""
        repo = Repo(repo_path)
        reflog = repo.git.reflog()
        branches = _branches_from_reflog(reflog, limit)
        return branches
  • Internal helper that parses the reflog to extract branch names from checkout entries.
    def _branches_from_reflog(reflog: str, limit: int) -> list[str]:
        branches = []
        for line in reflog.splitlines():
            if "checkout:" in line:
                branch = line.split("to ")[-1].strip()
                if branch not in branches:
                    branches.append(branch)
                    if len(branches) >= limit:
                        break
        return branches

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/jurasofish/mcpunk'

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