(ctx context.Context, client *github.Client, args map[string]any, owner, ownerType string)
| 836 | } |
| 837 | |
| 838 | func listProjectFields(ctx context.Context, client *github.Client, args map[string]any, owner, ownerType string) (*mcp.CallToolResult, any, error) { |
| 839 | projectNumber, err := RequiredInt(args, "project_number") |
| 840 | if err != nil { |
| 841 | return utils.NewToolResultError(err.Error()), nil, nil |
| 842 | } |
| 843 | |
| 844 | pagination, err := extractPaginationOptionsFromArgs(args) |
| 845 | if err != nil { |
| 846 | return utils.NewToolResultError(err.Error()), nil, nil |
| 847 | } |
| 848 | |
| 849 | var resp *github.Response |
| 850 | var projectFields []*github.ProjectV2Field |
| 851 | |
| 852 | opts := &github.ListProjectsOptions{ |
| 853 | ListProjectsPaginationOptions: pagination, |
| 854 | } |
| 855 | |
| 856 | if ownerType == "org" { |
| 857 | projectFields, resp, err = client.Projects.ListOrganizationProjectFields(ctx, owner, projectNumber, opts) |
| 858 | } else { |
| 859 | projectFields, resp, err = client.Projects.ListUserProjectFields(ctx, owner, projectNumber, opts) |
| 860 | } |
| 861 | |
| 862 | if err != nil { |
| 863 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 864 | "failed to list project fields", |
| 865 | resp, |
| 866 | err, |
| 867 | ), nil, nil |
| 868 | } |
| 869 | defer func() { _ = resp.Body.Close() }() |
| 870 | |
| 871 | response := map[string]any{ |
| 872 | "fields": projectFields, |
| 873 | "pageInfo": buildPageInfo(resp), |
| 874 | } |
| 875 | |
| 876 | r, err := json.Marshal(response) |
| 877 | if err != nil { |
| 878 | return nil, nil, fmt.Errorf("failed to marshal response: %w", err) |
| 879 | } |
| 880 | |
| 881 | return utils.NewToolResultText(string(r)), nil, nil |
| 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") |
no test coverage detected