MCPcopy
hub / github.com/github/github-mcp-server / ReprioritizeSubIssue

Function ReprioritizeSubIssue

pkg/github/issues.go:1480–1527  ·  view source on GitHub ↗
(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int, afterID int, beforeID int)

Source from the content-addressed store, hash-verified

1478}
1479
1480func ReprioritizeSubIssue(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int, afterID int, beforeID int) (*mcp.CallToolResult, error) {
1481 // Validate that either after_id or before_id is specified, but not both
1482 if afterID == 0 && beforeID == 0 {
1483 return utils.NewToolResultError("either after_id or before_id must be specified"), nil
1484 }
1485 if afterID != 0 && beforeID != 0 {
1486 return utils.NewToolResultError("only one of after_id or before_id should be specified, not both"), nil
1487 }
1488
1489 subIssueRequest := github.SubIssueRequest{
1490 SubIssueID: int64(subIssueID),
1491 }
1492
1493 if afterID != 0 {
1494 afterIDInt64 := int64(afterID)
1495 subIssueRequest.AfterID = &afterIDInt64
1496 }
1497 if beforeID != 0 {
1498 beforeIDInt64 := int64(beforeID)
1499 subIssueRequest.BeforeID = &beforeIDInt64
1500 }
1501
1502 subIssue, resp, err := client.SubIssue.Reprioritize(ctx, owner, repo, int64(issueNumber), subIssueRequest)
1503 if err != nil {
1504 return ghErrors.NewGitHubAPIErrorResponse(ctx,
1505 "failed to reprioritize sub-issue",
1506 resp,
1507 err,
1508 ), nil
1509 }
1510
1511 defer func() { _ = resp.Body.Close() }()
1512
1513 if resp.StatusCode != http.StatusOK {
1514 body, err := io.ReadAll(resp.Body)
1515 if err != nil {
1516 return nil, fmt.Errorf("failed to read response body: %w", err)
1517 }
1518 return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to reprioritize sub-issue", resp, body), nil
1519 }
1520
1521 r, err := json.Marshal(subIssue)
1522 if err != nil {
1523 return nil, fmt.Errorf("failed to marshal response: %w", err)
1524 }
1525
1526 return utils.NewToolResultText(string(r)), nil
1527}
1528
1529// SearchIssues creates a tool to search for issues.
1530func SearchIssues(t translations.TranslationHelperFunc) inventory.ServerTool {

Callers 2

SubIssueWriteFunction · 0.85

Calls 3

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
CloseMethod · 0.80

Tested by

no test coverage detected