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
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | ||
| project_name | Yes |
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
- mcpunk/tools.py:418-426 (handler)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()
- mcpunk/git_analysis.py:6-11 (helper)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
- mcpunk/git_analysis.py:14-23 (helper)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