@@ -741,7 +741,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
741
741
),
742
742
mcp .WithString ("state" ,
743
743
mcp .Description ("Filter by state" ),
744
- mcp .Enum ("open " , "closed" , "all " ),
744
+ mcp .Enum ("OPEN " , "CLOSED " ),
745
745
),
746
746
mcp .WithArray ("labels" ,
747
747
mcp .Description ("Filter by labels" ),
@@ -751,13 +751,13 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
751
751
},
752
752
),
753
753
),
754
- mcp .WithString ("sort " ,
755
- mcp .Description ("Sort order " ),
756
- mcp .Enum ("created " , "updated" , "comments " ),
754
+ mcp .WithString ("orderBy " ,
755
+ mcp .Description ("Order discussions by field. If provided, the 'direction' also needs to be provided. " ),
756
+ mcp .Enum ("CREATED_AT " , "UPDATED_AT " ),
757
757
),
758
758
mcp .WithString ("direction" ,
759
- mcp .Description ("Sort direction" ),
760
- mcp .Enum ("asc " , "desc " ),
759
+ mcp .Description ("Order direction. " ),
760
+ mcp .Enum ("ASC " , "DESC " ),
761
761
),
762
762
mcp .WithString ("since" ,
763
763
mcp .Description ("Filter by date (ISO 8601 timestamp)" ),
@@ -774,49 +774,56 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
774
774
return mcp .NewToolResultError (err .Error ()), nil
775
775
}
776
776
777
- opts := & github.IssueListByRepoOptions {}
778
-
779
777
// Set optional parameters if provided
780
- opts . State , err = OptionalParam [string ](request , "state" )
778
+ state , err : = OptionalParam [string ](request , "state" )
781
779
if err != nil {
782
780
return mcp .NewToolResultError (err .Error ()), nil
783
781
}
782
+ if state == "" {
783
+ state = "OPEN" // Default to OPEN if not provided
784
+ }
784
785
785
786
// Get labels
786
- opts . Labels , err = OptionalStringArrayParam (request , "labels" )
787
+ //labels , err : = OptionalStringArrayParam(request, "labels")
787
788
if err != nil {
788
789
return mcp .NewToolResultError (err .Error ()), nil
789
790
}
790
791
791
- opts . Sort , err = OptionalParam [string ](request , "sort " )
792
+ orderBy , err : = OptionalParam [string ](request , "orderBy " )
792
793
if err != nil {
793
794
return mcp .NewToolResultError (err .Error ()), nil
794
795
}
796
+ if orderBy == "" {
797
+ orderBy = "CREATED_AT"
798
+ }
795
799
796
- opts . Direction , err = OptionalParam [string ](request , "direction" )
800
+ direction , err : = OptionalParam [string ](request , "direction" )
797
801
if err != nil {
798
802
return mcp .NewToolResultError (err .Error ()), nil
799
803
}
804
+ if direction == "" {
805
+ direction = "DESC"
806
+ }
800
807
801
808
since , err := OptionalParam [string ](request , "since" )
802
809
if err != nil {
803
810
return mcp .NewToolResultError (err .Error ()), nil
804
811
}
805
812
if since != "" {
806
- timestamp , err := parseISOTimestamp (since )
813
+ // timestamp, err := parseISOTimestamp(since)
807
814
if err != nil {
808
815
return mcp .NewToolResultError (fmt .Sprintf ("failed to list issues: %s" , err .Error ())), nil
809
816
}
810
- opts . Since = timestamp
817
+ //since = timestamp
811
818
}
812
819
813
- if page , ok := request .GetArguments ()["page" ].(float64 ); ok {
814
- opts . ListOptions .Page = int (page )
815
- }
820
+ // if page, ok := request.GetArguments()["page"].(float64); ok {
821
+ //listOptions .Page = int(page)
822
+ // }
816
823
817
- if perPage , ok := request .GetArguments ()["perPage" ].(float64 ); ok {
818
- opts . ListOptions .PerPage = int (perPage )
819
- }
824
+ // if perPage, ok := request.GetArguments()["perPage"].(float64); ok {
825
+ // .PerPage = int(perPage)
826
+ // }
820
827
821
828
client , err := getGQLClient (ctx )
822
829
if err != nil {
@@ -825,53 +832,61 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
825
832
826
833
var q struct {
827
834
Repository struct {
828
- DiscussionCategories struct {
835
+ Issues struct {
829
836
Nodes []struct {
830
- ID githubv4.ID
831
- Name githubv4.String
832
- }
833
- PageInfo struct {
834
- HasNextPage githubv4.Boolean
835
- HasPreviousPage githubv4.Boolean
836
- StartCursor githubv4.String
837
- EndCursor githubv4.String
837
+ Number githubv4.Int
838
+ Title githubv4.String
839
+ Body githubv4.String
840
+ Author struct {
841
+ Login githubv4.String
842
+ }
843
+ CreatedAt githubv4.DateTime
844
+ Labels struct {
845
+ Nodes []struct {
846
+ Name githubv4.String
847
+ }
848
+ } `graphql:"labels(first: 10)"`
838
849
}
839
- TotalCount int
840
- } `graphql:"discussionCategories(first: $first)"`
850
+ } `graphql:"issues(first: $first, states: $states, orderBy: {field: $orderBy, direction: $direction})"`
841
851
} `graphql:"repository(owner: $owner, name: $repo)"`
842
852
}
843
853
vars := map [string ]interface {}{
844
- //"owner": githubv4.String(params.Owner),
845
- //"repo": githubv4.String(params.Repo),
846
- "first" : githubv4 .Int (25 ),
854
+ "owner" : githubv4 .String (owner ),
855
+ "repo" : githubv4 .String (repo ),
856
+ "first" : githubv4 .Int (100 ),
857
+ "states" : []githubv4.IssueState {githubv4 .IssueState (state )},
858
+ "orderBy" : githubv4 .IssueOrderField (orderBy ),
859
+ "direction" : githubv4 .OrderDirection (direction ),
847
860
}
848
861
if err := client .Query (ctx , & q , vars ); err != nil {
849
862
return mcp .NewToolResultError (err .Error ()), nil
850
863
}
851
864
852
- var categories []map [string ]string
853
- for _ , c := range q .Repository .DiscussionCategories .Nodes {
854
- categories = append (categories , map [string ]string {
855
- "id" : fmt .Sprint (c .ID ),
856
- "name" : string (c .Name ),
865
+ var issues []map [string ]interface {}
866
+ for _ , issue := range q .Repository .Issues .Nodes {
867
+ var labels []string
868
+ for _ , label := range issue .Labels .Nodes {
869
+ labels = append (labels , string (label .Name ))
870
+ }
871
+
872
+ issues = append (issues , map [string ]interface {}{
873
+ "number" : int (issue .Number ),
874
+ "title" : string (issue .Title ),
875
+ "body" : string (issue .Body ),
876
+ "author" : string (issue .Author .Login ),
877
+ "createdAt" : issue .CreatedAt .Time ,
878
+ "labels" : labels ,
857
879
})
858
880
}
859
881
860
- // Create response with pagination info
882
+ // Create response with issues
861
883
response := map [string ]interface {}{
862
- "categories" : categories ,
863
- "pageInfo" : map [string ]interface {}{
864
- "hasNextPage" : q .Repository .DiscussionCategories .PageInfo .HasNextPage ,
865
- "hasPreviousPage" : q .Repository .DiscussionCategories .PageInfo .HasPreviousPage ,
866
- "startCursor" : string (q .Repository .DiscussionCategories .PageInfo .StartCursor ),
867
- "endCursor" : string (q .Repository .DiscussionCategories .PageInfo .EndCursor ),
868
- },
869
- "totalCount" : q .Repository .DiscussionCategories .TotalCount ,
884
+ "issues" : issues ,
870
885
}
871
886
872
887
out , err := json .Marshal (response )
873
888
if err != nil {
874
- return nil , fmt .Errorf ("failed to marshal discussion categories : %w" , err )
889
+ return nil , fmt .Errorf ("failed to marshal issues : %w" , err )
875
890
}
876
891
return mcp .NewToolResultText (string (out )), nil
877
892
}
0 commit comments