@@ -741,7 +741,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
741741 ),
742742 mcp .WithString ("state" ,
743743 mcp .Description ("Filter by state" ),
744- mcp .Enum ("open " , "closed" , "all " ),
744+ mcp .Enum ("OPEN " , "CLOSED " ),
745745 ),
746746 mcp .WithArray ("labels" ,
747747 mcp .Description ("Filter by labels" ),
@@ -751,13 +751,13 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
751751 },
752752 ),
753753 ),
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 " ),
757757 ),
758758 mcp .WithString ("direction" ,
759- mcp .Description ("Sort direction" ),
760- mcp .Enum ("asc " , "desc " ),
759+ mcp .Description ("Order direction. " ),
760+ mcp .Enum ("ASC " , "DESC " ),
761761 ),
762762 mcp .WithString ("since" ,
763763 mcp .Description ("Filter by date (ISO 8601 timestamp)" ),
@@ -774,49 +774,56 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
774774 return mcp .NewToolResultError (err .Error ()), nil
775775 }
776776
777- opts := & github.IssueListByRepoOptions {}
778-
779777 // Set optional parameters if provided
780- opts . State , err = OptionalParam [string ](request , "state" )
778+ state , err : = OptionalParam [string ](request , "state" )
781779 if err != nil {
782780 return mcp .NewToolResultError (err .Error ()), nil
783781 }
782+ if state == "" {
783+ state = "OPEN" // Default to OPEN if not provided
784+ }
784785
785786 // Get labels
786- opts . Labels , err = OptionalStringArrayParam (request , "labels" )
787+ //labels , err : = OptionalStringArrayParam(request, "labels")
787788 if err != nil {
788789 return mcp .NewToolResultError (err .Error ()), nil
789790 }
790791
791- opts . Sort , err = OptionalParam [string ](request , "sort " )
792+ orderBy , err : = OptionalParam [string ](request , "orderBy " )
792793 if err != nil {
793794 return mcp .NewToolResultError (err .Error ()), nil
794795 }
796+ if orderBy == "" {
797+ orderBy = "CREATED_AT"
798+ }
795799
796- opts . Direction , err = OptionalParam [string ](request , "direction" )
800+ direction , err : = OptionalParam [string ](request , "direction" )
797801 if err != nil {
798802 return mcp .NewToolResultError (err .Error ()), nil
799803 }
804+ if direction == "" {
805+ direction = "DESC"
806+ }
800807
801808 since , err := OptionalParam [string ](request , "since" )
802809 if err != nil {
803810 return mcp .NewToolResultError (err .Error ()), nil
804811 }
805812 if since != "" {
806- timestamp , err := parseISOTimestamp (since )
813+ // timestamp, err := parseISOTimestamp(since)
807814 if err != nil {
808815 return mcp .NewToolResultError (fmt .Sprintf ("failed to list issues: %s" , err .Error ())), nil
809816 }
810- opts . Since = timestamp
817+ //since = timestamp
811818 }
812819
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+ // }
816823
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+ // }
820827
821828 client , err := getGQLClient (ctx )
822829 if err != nil {
@@ -825,53 +832,61 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
825832
826833 var q struct {
827834 Repository struct {
828- DiscussionCategories struct {
835+ Issues struct {
829836 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)"`
838849 }
839- TotalCount int
840- } `graphql:"discussionCategories(first: $first)"`
850+ } `graphql:"issues(first: $first, states: $states, orderBy: {field: $orderBy, direction: $direction})"`
841851 } `graphql:"repository(owner: $owner, name: $repo)"`
842852 }
843853 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 ),
847860 }
848861 if err := client .Query (ctx , & q , vars ); err != nil {
849862 return mcp .NewToolResultError (err .Error ()), nil
850863 }
851864
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 ,
857879 })
858880 }
859881
860- // Create response with pagination info
882+ // Create response with issues
861883 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 ,
870885 }
871886
872887 out , err := json .Marshal (response )
873888 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 )
875890 }
876891 return mcp .NewToolResultText (string (out )), nil
877892 }
0 commit comments