@@ -21,20 +21,7 @@ import (
21
21
var ListIssuesQuery struct {
22
22
Repository struct {
23
23
Issues struct {
24
- Nodes []struct {
25
- Number githubv4.Int
26
- Title githubv4.String
27
- Body githubv4.String
28
- Author struct {
29
- Login githubv4.String
30
- }
31
- CreatedAt githubv4.DateTime
32
- Labels struct {
33
- Nodes []struct {
34
- Name githubv4.String
35
- }
36
- } `graphql:"labels(first: 10)"`
37
- }
24
+ Nodes []IssueFragment `graphql:"nodes"`
38
25
PageInfo struct {
39
26
HasNextPage githubv4.Boolean
40
27
HasPreviousPage githubv4.Boolean
@@ -46,6 +33,54 @@ var ListIssuesQuery struct {
46
33
} `graphql:"repository(owner: $owner, name: $repo)"`
47
34
}
48
35
36
+ // NodeFragment represents a fragment of an issue node in the GraphQL API.
37
+ type IssueFragment struct {
38
+ Number githubv4.Int
39
+ Title githubv4.String
40
+ Body githubv4.String
41
+ State githubv4.String
42
+ DatabaseID int64
43
+
44
+ Author struct {
45
+ Login githubv4.String
46
+ }
47
+ CreatedAt githubv4.DateTime
48
+ UpdatedAt githubv4.DateTime
49
+ Labels struct {
50
+ Nodes []struct {
51
+ Name githubv4.String
52
+ Id githubv4.String
53
+ Description githubv4.String
54
+ }
55
+ } `graphql:"labels(first: 10)"`
56
+ }
57
+
58
+ func fragmentToIssue (fragment IssueFragment ) * github.Issue {
59
+ // Convert GraphQL labels to GitHub API labels format
60
+ var labels []* github.Label
61
+ for _ , labelNode := range fragment .Labels .Nodes {
62
+ labels = append (labels , & github.Label {
63
+ Name : github .Ptr (string (labelNode .Name )),
64
+ NodeID : github .Ptr (string (labelNode .Id )),
65
+ Description : github .Ptr (string (labelNode .Description )),
66
+ })
67
+ }
68
+
69
+ return & github.Issue {
70
+ Number : github .Ptr (int (fragment .Number )),
71
+ Title : github .Ptr (string (fragment .Title )),
72
+ CreatedAt : & github.Timestamp {Time : fragment .CreatedAt .Time },
73
+ UpdatedAt : & github.Timestamp {Time : fragment .UpdatedAt .Time },
74
+ User : & github.User {
75
+ Login : github .Ptr (string (fragment .Author .Login )),
76
+ },
77
+ State : github .Ptr (string (fragment .State )),
78
+ ID : github .Ptr (fragment .DatabaseID ),
79
+ Body : github .Ptr (string (fragment .Body )),
80
+ Labels : labels ,
81
+ }
82
+ }
83
+
49
84
// GetIssue creates a tool to get details of a specific issue in a GitHub repository.
50
85
func GetIssue (getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
51
86
return mcp .NewTool ("get_issue" ,
@@ -865,11 +900,6 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
865
900
return nil , err
866
901
}
867
902
868
- if paginationParams .After == nil {
869
- defaultAfter := string ("" )
870
- paginationParams .After = & defaultAfter
871
- }
872
-
873
903
// Use default of 30 if pagination was not explicitly provided
874
904
if ! paginationExplicit {
875
905
defaultFirst := int32 (DefaultGraphQLPageSize )
@@ -901,7 +931,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
901
931
}
902
932
903
933
//We must filter based on labels after fetching all issues
904
- var issues []map [ string ] interface {}
934
+ var issues []* github. Issue
905
935
for _ , issue := range ListIssuesQuery .Repository .Issues .Nodes {
906
936
var issueLabels []string
907
937
for _ , label := range issue .Labels .Nodes {
@@ -931,15 +961,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
931
961
continue // Skip this issue as it doesn't match any requested labels
932
962
}
933
963
}
934
-
935
- issues = append (issues , map [string ]interface {}{
936
- "number" : int (issue .Number ),
937
- "title" : string (issue .Title ),
938
- "body" : string (issue .Body ),
939
- "author" : string (issue .Author .Login ),
940
- "createdAt" : issue .CreatedAt .Time ,
941
- "labels" : issueLabels ,
942
- })
964
+ issues = append (issues , fragmentToIssue (issue ))
943
965
}
944
966
945
967
// Create response with issues
0 commit comments