44 "time"
55
66 "github.com/google/go-github/v82/github"
7+
8+ "github.com/github/github-mcp-server/pkg/sanitize"
79)
810
911// MinimalUser is the output type for user and organization search results.
@@ -176,7 +178,7 @@ type MinimalIssue struct {
176178 StateReason string `json:"state_reason,omitempty"`
177179 Draft bool `json:"draft,omitempty"`
178180 Locked bool `json:"locked,omitempty"`
179- HTMLURL string `json:"html_url"`
181+ HTMLURL string `json:"html_url,omitempty "`
180182 User * MinimalUser `json:"user,omitempty"`
181183 AuthorAssociation string `json:"author_association,omitempty"`
182184 Labels []string `json:"labels,omitempty"`
@@ -191,6 +193,13 @@ type MinimalIssue struct {
191193 IssueType string `json:"issue_type,omitempty"`
192194}
193195
196+ // MinimalIssuesResponse is the trimmed output for a paginated list of issues.
197+ type MinimalIssuesResponse struct {
198+ Issues []MinimalIssue `json:"issues"`
199+ TotalCount int `json:"totalCount"`
200+ PageInfo MinimalPageInfo `json:"pageInfo"`
201+ }
202+
194203// MinimalIssueComment is the trimmed output type for issue comment objects to reduce verbosity.
195204type MinimalIssueComment struct {
196205 ID int64 `json:"id"`
@@ -376,6 +385,45 @@ func convertToMinimalIssue(issue *github.Issue) MinimalIssue {
376385 return m
377386}
378387
388+ func fragmentToMinimalIssue (fragment IssueFragment ) MinimalIssue {
389+ m := MinimalIssue {
390+ Number : int (fragment .Number ),
391+ Title : sanitize .Sanitize (string (fragment .Title )),
392+ Body : sanitize .Sanitize (string (fragment .Body )),
393+ State : string (fragment .State ),
394+ Comments : int (fragment .Comments .TotalCount ),
395+ CreatedAt : fragment .CreatedAt .Format (time .RFC3339 ),
396+ UpdatedAt : fragment .UpdatedAt .Format (time .RFC3339 ),
397+ User : & MinimalUser {
398+ Login : string (fragment .Author .Login ),
399+ },
400+ }
401+
402+ for _ , label := range fragment .Labels .Nodes {
403+ m .Labels = append (m .Labels , string (label .Name ))
404+ }
405+
406+ return m
407+ }
408+
409+ func convertToMinimalIssuesResponse (fragment IssueQueryFragment ) MinimalIssuesResponse {
410+ minimalIssues := make ([]MinimalIssue , 0 , len (fragment .Nodes ))
411+ for _ , issue := range fragment .Nodes {
412+ minimalIssues = append (minimalIssues , fragmentToMinimalIssue (issue ))
413+ }
414+
415+ return MinimalIssuesResponse {
416+ Issues : minimalIssues ,
417+ TotalCount : fragment .TotalCount ,
418+ PageInfo : MinimalPageInfo {
419+ HasNextPage : bool (fragment .PageInfo .HasNextPage ),
420+ HasPreviousPage : bool (fragment .PageInfo .HasPreviousPage ),
421+ StartCursor : string (fragment .PageInfo .StartCursor ),
422+ EndCursor : string (fragment .PageInfo .EndCursor ),
423+ },
424+ }
425+ }
426+
379427func convertToMinimalIssueComment (comment * github.IssueComment ) MinimalIssueComment {
380428 m := MinimalIssueComment {
381429 ID : comment .GetID (),
@@ -650,10 +698,10 @@ func convertToMinimalCommit(commit *github.RepositoryCommit, includeDiffs bool)
650698
651699// MinimalPageInfo contains pagination cursor information.
652700type MinimalPageInfo struct {
653- HasNextPage bool `json:"has_next_page "`
654- HasPreviousPage bool `json:"has_previous_page "`
655- StartCursor string `json:"start_cursor ,omitempty"`
656- EndCursor string `json:"end_cursor ,omitempty"`
701+ HasNextPage bool `json:"hasNextPage "`
702+ HasPreviousPage bool `json:"hasPreviousPage "`
703+ StartCursor string `json:"startCursor ,omitempty"`
704+ EndCursor string `json:"endCursor ,omitempty"`
657705}
658706
659707// MinimalReviewComment is the trimmed output type for PR review comment objects.
@@ -679,8 +727,8 @@ type MinimalReviewThread struct {
679727// MinimalReviewThreadsResponse is the trimmed output for a paginated list of PR review threads.
680728type MinimalReviewThreadsResponse struct {
681729 ReviewThreads []MinimalReviewThread `json:"review_threads"`
682- TotalCount int `json:"total_count "`
683- PageInfo MinimalPageInfo `json:"page_info "`
730+ TotalCount int `json:"totalCount "`
731+ PageInfo MinimalPageInfo `json:"pageInfo "`
684732}
685733
686734func convertToMinimalPRFiles (files []* github.CommitFile ) []MinimalPRFile {
0 commit comments