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

NameRequiredDescriptionDefault
nNo
project_nameYes

Input Schema (JSON Schema)

{ "properties": { "n": { "default": 20, "maximum": 50, "minimum": 20, "title": "N", "type": "integer" }, "project_name": { "title": "Project Name", "type": "string" } }, "required": [ "project_name" ], "title": "list_most_recently_checked_out_branchesArguments", "type": "object" }

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

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