MCPcopy Index your code
hub / github.com/github/github-mcp-server / uiGetReviewers

Function uiGetReviewers

pkg/github/ui_tools.go:466–555  ·  view source on GitHub ↗
(ctx context.Context, deps ToolDependencies, args map[string]any, owner string)

Source from the content-addressed store, hash-verified

464}
465
466func uiGetReviewers(ctx context.Context, deps ToolDependencies, args map[string]any, owner string) (*mcp.CallToolResult, any, error) {
467 repo, err := RequiredParam[string](args, "repo")
468 if err != nil {
469 return utils.NewToolResultError(err.Error()), nil, nil
470 }
471
472 client, err := deps.GetClient(ctx)
473 if err != nil {
474 return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
475 }
476
477 collaboratorOpts := &github.ListCollaboratorsOptions{
478 Affiliation: "all",
479 ListOptions: github.ListOptions{PerPage: 100},
480 }
481 var allCollaborators []*github.User
482 hasMore := false
483 for page := 1; ; page++ {
484 collaborators, resp, err := client.Repositories.ListCollaborators(ctx, owner, repo, collaboratorOpts)
485 if err != nil {
486 return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list reviewers", resp, err), nil, nil
487 }
488 allCollaborators = append(allCollaborators, collaborators...)
489 if resp != nil && resp.Body != nil {
490 _ = resp.Body.Close()
491 }
492 if resp.NextPage == 0 {
493 break
494 }
495 if page >= uiGetMaxPages {
496 hasMore = true
497 break
498 }
499 collaboratorOpts.Page = resp.NextPage
500 }
501
502 teamOpts := &github.ListOptions{PerPage: 100}
503 var allTeams []*github.Team
504 for page := 1; ; page++ {
505 teams, resp, err := client.Repositories.ListTeams(ctx, owner, repo, teamOpts)
506 if err != nil {
507 return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list reviewer teams", resp, err), nil, nil
508 }
509 allTeams = append(allTeams, teams...)
510 if resp != nil && resp.Body != nil {
511 _ = resp.Body.Close()
512 }
513 if resp.NextPage == 0 {
514 break
515 }
516 if page >= uiGetMaxPages {
517 hasMore = true
518 break
519 }
520 teamOpts.Page = resp.NextPage
521 }
522
523 users := make([]map[string]string, 0, len(allCollaborators))

Callers 1

UIGetFunction · 0.85

Calls 6

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
CloseMethod · 0.80
GetClientMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected