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

Function listProjectStatusUpdates

pkg/github/projects.go:1326–1407  ·  view source on GitHub ↗

listProjectStatusUpdates lists status updates for a project via GraphQL.

(ctx context.Context, gqlClient *githubv4.Client, args map[string]any, owner, ownerType string)

Source from the content-addressed store, hash-verified

1324
1325// listProjectStatusUpdates lists status updates for a project via GraphQL.
1326func listProjectStatusUpdates(ctx context.Context, gqlClient *githubv4.Client, args map[string]any, owner, ownerType string) (*mcp.CallToolResult, bool, any, error) {
1327 if ownerType != "user" && ownerType != "org" {
1328 return utils.NewToolResultError(fmt.Sprintf("invalid owner_type %q: must be \"user\" or \"org\"", ownerType)), false, nil, nil
1329 }
1330
1331 projectNumber, err := RequiredInt(args, "project_number")
1332 if err != nil {
1333 return utils.NewToolResultError(err.Error()), false, nil, nil
1334 }
1335
1336 perPage, err := OptionalIntParamWithDefault(args, "per_page", MaxProjectsPerPage)
1337 if err != nil {
1338 return utils.NewToolResultError(err.Error()), false, nil, nil
1339 }
1340 if perPage > MaxProjectsPerPage {
1341 perPage = MaxProjectsPerPage
1342 }
1343 if perPage < 1 {
1344 perPage = MaxProjectsPerPage
1345 }
1346
1347 afterCursor, err := OptionalParam[string](args, "after")
1348 if err != nil {
1349 return utils.NewToolResultError(err.Error()), false, nil, nil
1350 }
1351
1352 vars := map[string]any{
1353 "owner": githubv4.String(owner),
1354 "projectNumber": githubv4.Int(int32(projectNumber)), //nolint:gosec // Project numbers are small integers
1355 "first": githubv4.Int(int32(perPage)), //nolint:gosec // perPage is bounded by MaxProjectsPerPage
1356 }
1357 if afterCursor != "" {
1358 vars["after"] = githubv4.String(afterCursor)
1359 } else {
1360 vars["after"] = (*githubv4.String)(nil)
1361 }
1362
1363 var nodes []statusUpdateNode
1364 var pi PageInfoFragment
1365 var isPrivate bool
1366
1367 if ownerType == "org" {
1368 var q statusUpdatesOrgQuery
1369 if err := gqlClient.Query(ctx, &q, vars); err != nil {
1370 return utils.NewToolResultError(fmt.Sprintf("%s: %v", ProjectStatusUpdateListFailedError, err)), false, nil, nil
1371 }
1372 project := q.Organization.ProjectV2
1373 nodes = project.StatusUpdates.Nodes
1374 pi = project.StatusUpdates.PageInfo
1375 isPrivate = !bool(project.Public)
1376 } else {
1377 var q statusUpdatesUserQuery
1378 if err := gqlClient.Query(ctx, &q, vars); err != nil {
1379 return utils.NewToolResultError(fmt.Sprintf("%s: %v", ProjectStatusUpdateListFailedError, err)), false, nil, nil
1380 }
1381 project := q.User.ProjectV2
1382 nodes = project.StatusUpdates.Nodes
1383 pi = project.StatusUpdates.PageInfo

Callers 1

ProjectsListFunction · 0.85

Calls 7

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
RequiredIntFunction · 0.85
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected