@@ -21,20 +21,7 @@ import (
2121var ListIssuesQuery struct {
2222 Repository struct {
2323 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"`
3825 PageInfo struct {
3926 HasNextPage githubv4.Boolean
4027 HasPreviousPage githubv4.Boolean
@@ -46,6 +33,54 @@ var ListIssuesQuery struct {
4633 } `graphql:"repository(owner: $owner, name: $repo)"`
4734}
4835
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+
4984// GetIssue creates a tool to get details of a specific issue in a GitHub repository.
5085func GetIssue (getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
5186 return mcp .NewTool ("get_issue" ,
@@ -865,11 +900,6 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
865900 return nil , err
866901 }
867902
868- if paginationParams .After == nil {
869- defaultAfter := string ("" )
870- paginationParams .After = & defaultAfter
871- }
872-
873903 // Use default of 30 if pagination was not explicitly provided
874904 if ! paginationExplicit {
875905 defaultFirst := int32 (DefaultGraphQLPageSize )
@@ -901,7 +931,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
901931 }
902932
903933 //We must filter based on labels after fetching all issues
904- var issues []map [ string ] interface {}
934+ var issues []* github. Issue
905935 for _ , issue := range ListIssuesQuery .Repository .Issues .Nodes {
906936 var issueLabels []string
907937 for _ , label := range issue .Labels .Nodes {
@@ -931,15 +961,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
931961 continue // Skip this issue as it doesn't match any requested labels
932962 }
933963 }
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 ))
943965 }
944966
945967 // Create response with issues
0 commit comments