(ctx context.Context, client *github.Client, args map[string]any, owner, ownerType string)
| 882 | } |
| 883 | |
| 884 | func listProjectItems(ctx context.Context, client *github.Client, args map[string]any, owner, ownerType string) (*mcp.CallToolResult, any, error) { |
| 885 | projectNumber, err := RequiredInt(args, "project_number") |
| 886 | if err != nil { |
| 887 | return utils.NewToolResultError(err.Error()), nil, nil |
| 888 | } |
| 889 | |
| 890 | queryStr, err := OptionalParam[string](args, "query") |
| 891 | if err != nil { |
| 892 | return utils.NewToolResultError(err.Error()), nil, nil |
| 893 | } |
| 894 | |
| 895 | fields, err := OptionalBigIntArrayParam(args, "fields") |
| 896 | if err != nil { |
| 897 | return utils.NewToolResultError(err.Error()), nil, nil |
| 898 | } |
| 899 | |
| 900 | pagination, err := extractPaginationOptionsFromArgs(args) |
| 901 | if err != nil { |
| 902 | return utils.NewToolResultError(err.Error()), nil, nil |
| 903 | } |
| 904 | |
| 905 | var resp *github.Response |
| 906 | var projectItems []*github.ProjectV2Item |
| 907 | |
| 908 | opts := &github.ListProjectItemsOptions{ |
| 909 | Fields: fields, |
| 910 | ListProjectsOptions: github.ListProjectsOptions{ |
| 911 | ListProjectsPaginationOptions: pagination, |
| 912 | Query: queryStr, |
| 913 | }, |
| 914 | } |
| 915 | |
| 916 | if ownerType == "org" { |
| 917 | projectItems, resp, err = client.Projects.ListOrganizationProjectItems(ctx, owner, projectNumber, opts) |
| 918 | } else { |
| 919 | projectItems, resp, err = client.Projects.ListUserProjectItems(ctx, owner, projectNumber, opts) |
| 920 | } |
| 921 | |
| 922 | if err != nil { |
| 923 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 924 | ProjectListFailedError, |
| 925 | resp, |
| 926 | err, |
| 927 | ), nil, nil |
| 928 | } |
| 929 | defer func() { _ = resp.Body.Close() }() |
| 930 | |
| 931 | minimalItems := make([]MinimalProjectItem, 0, len(projectItems)) |
| 932 | for _, item := range projectItems { |
| 933 | minimalItems = append(minimalItems, convertToMinimalProjectItem(item)) |
| 934 | } |
| 935 | |
| 936 | response := map[string]any{ |
| 937 | "items": minimalItems, |
| 938 | "pageInfo": buildPageInfo(resp), |
| 939 | } |
| 940 | |
| 941 | r, err := json.Marshal(response) |
no test coverage detected