GetIssueParent returns the parent issue of the given issue, or a null parent when the issue is not a sub-issue of any other issue. It reads the GraphQL Issue.parent field, the upward counterpart to the downward get_sub_issues read.
(ctx context.Context, client *githubv4.Client, owner string, repo string, issueNumber int)
| 904 | // when the issue is not a sub-issue of any other issue. It reads the GraphQL |
| 905 | // Issue.parent field, the upward counterpart to the downward get_sub_issues read. |
| 906 | func GetIssueParent(ctx context.Context, client *githubv4.Client, owner string, repo string, issueNumber int) (*mcp.CallToolResult, error) { |
| 907 | var query struct { |
| 908 | Repository struct { |
| 909 | Issue struct { |
| 910 | Parent *struct { |
| 911 | Number githubv4.Int |
| 912 | Title githubv4.String |
| 913 | State githubv4.String |
| 914 | URL githubv4.String |
| 915 | Repository struct { |
| 916 | NameWithOwner githubv4.String |
| 917 | } |
| 918 | } |
| 919 | } `graphql:"issue(number: $issueNumber)"` |
| 920 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 921 | } |
| 922 | |
| 923 | vars := map[string]any{ |
| 924 | "owner": githubv4.String(owner), |
| 925 | "repo": githubv4.String(repo), |
| 926 | "issueNumber": githubv4.Int(issueNumber), // #nosec G115 - issue numbers are always small positive integers |
| 927 | } |
| 928 | |
| 929 | if err := client.Query(ctx, &query, vars); err != nil { |
| 930 | return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get issue parent", err), nil |
| 931 | } |
| 932 | |
| 933 | parent := query.Repository.Issue.Parent |
| 934 | if parent == nil { |
| 935 | return MarshalledTextResult(map[string]any{"parent": nil}), nil |
| 936 | } |
| 937 | |
| 938 | return MarshalledTextResult(map[string]any{ |
| 939 | "parent": map[string]any{ |
| 940 | "number": int(parent.Number), |
| 941 | "title": string(parent.Title), |
| 942 | "state": string(parent.State), |
| 943 | "url": string(parent.URL), |
| 944 | "repository": string(parent.Repository.NameWithOwner), |
| 945 | }, |
| 946 | }), nil |
| 947 | } |
| 948 | |
| 949 | func GetIssueLabels(ctx context.Context, client *githubv4.Client, owner string, repo string, issueNumber int) (*mcp.CallToolResult, error) { |
| 950 | // Get current labels on the issue using GraphQL |
no test coverage detected