Skip to content

Commit 2bfcb8f

Browse files
committed
docs: Add list_branches to README and update pagination handling
1 parent bee75ab commit 2bfcb8f

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
350350
- `page`: Page number (number, optional)
351351
- `perPage`: Results per page (number, optional)
352352

353+
- **list_branches** - List branches in a GitHub repository
354+
- `owner`: Repository owner (string, required)
355+
- `repo`: Repository name (string, required)
356+
- `page`: Page number (number, optional)
357+
- `perPage`: Results per page (number, optional)
358+
353359
### Search
354360

355361
- **search_code** - Search for code across GitHub repositories

pkg/github/repositories.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,7 @@ func listBranches(client *github.Client, t translations.TranslationHelperFunc) (
613613
mcp.Required(),
614614
mcp.Description("Repository name"),
615615
),
616-
mcp.WithNumber("page",
617-
mcp.Description("Page number"),
618-
),
619-
mcp.WithNumber("perPage",
620-
mcp.Description("Results per page"),
621-
),
616+
withPagination(),
622617
),
623618
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
624619
owner, err := requiredParam[string](request, "owner")
@@ -629,19 +624,15 @@ func listBranches(client *github.Client, t translations.TranslationHelperFunc) (
629624
if err != nil {
630625
return mcp.NewToolResultError(err.Error()), nil
631626
}
632-
page, err := optionalIntParamWithDefault(request, "page", 1)
633-
if err != nil {
634-
return mcp.NewToolResultError(err.Error()), nil
635-
}
636-
perPage, err := optionalIntParamWithDefault(request, "per_page", 30)
627+
pagination, err := optionalPaginationParams(request)
637628
if err != nil {
638629
return mcp.NewToolResultError(err.Error()), nil
639630
}
640631

641632
opts := &github.BranchListOptions{
642633
ListOptions: github.ListOptions{
643-
Page: page,
644-
PerPage: perPage,
634+
Page: pagination.page,
635+
PerPage: pagination.perPage,
645636
},
646637
}
647638

0 commit comments

Comments
 (0)