Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pkg/github/discussions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/github/github-mcp-server/pkg/ifc"
"github.com/github/github-mcp-server/pkg/inventory"
"github.com/github/github-mcp-server/pkg/sanitize"
"github.com/github/github-mcp-server/pkg/scopes"
"github.com/github/github-mcp-server/pkg/translations"
"github.com/github/github-mcp-server/pkg/utils"
Expand Down Expand Up @@ -99,7 +100,7 @@ type WithCategoryNoOrder struct {
func fragmentToDiscussion(fragment NodeFragment) *github.Discussion {
return &github.Discussion{
Number: github.Ptr(int(fragment.Number)),
Title: github.Ptr(string(fragment.Title)),
Title: github.Ptr(sanitize.Sanitize(string(fragment.Title))),
HTMLURL: github.Ptr(string(fragment.URL)),
CreatedAt: &github.Timestamp{Time: fragment.CreatedAt.Time},
UpdatedAt: &github.Timestamp{Time: fragment.UpdatedAt.Time},
Expand Down Expand Up @@ -360,8 +361,8 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
// like ListDiscussions and GetDiscussionComments).
response := map[string]any{
"number": int(d.Number),
"title": string(d.Title),
"body": string(d.Body),
"title": sanitize.Sanitize(string(d.Title)),
"body": sanitize.Sanitize(string(d.Body)),
"url": string(d.URL),
"closed": bool(d.Closed),
"isAnswered": bool(d.IsAnswered),
Expand Down Expand Up @@ -522,14 +523,14 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
for _, c := range q.Repository.Discussion.Comments.Nodes {
comment := MinimalDiscussionComment{
ID: fmt.Sprintf("%v", c.ID),
Body: string(c.Body),
Body: sanitize.Sanitize(string(c.Body)),
IsAnswer: bool(c.IsAnswer),
ReplyTotalCount: c.Replies.TotalCount,
}
for _, r := range c.Replies.Nodes {
comment.Replies = append(comment.Replies, MinimalDiscussionComment{
ID: fmt.Sprintf("%v", r.ID),
Body: string(r.Body),
Body: sanitize.Sanitize(string(r.Body)),
IsAnswer: bool(r.IsAnswer),
})
}
Expand Down Expand Up @@ -564,7 +565,7 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
for _, c := range q.Repository.Discussion.Comments.Nodes {
comments = append(comments, MinimalDiscussionComment{
ID: fmt.Sprintf("%v", c.ID),
Body: string(c.Body),
Body: sanitize.Sanitize(string(c.Body)),
IsAnswer: bool(c.IsAnswer),
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/minimal_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func convertToMinimalPullRequestReview(review *github.PullRequestReview) Minimal
m := MinimalPullRequestReview{
ID: review.GetID(),
State: review.GetState(),
Body: review.GetBody(),
Body: sanitize.Sanitize(review.GetBody()),
HTMLURL: review.GetHTMLURL(),
User: convertToMinimalUser(review.GetUser()),
CommitID: review.GetCommitID(),
Expand Down Expand Up @@ -1909,7 +1909,7 @@ func convertToMinimalReviewThread(thread reviewThreadNode) MinimalReviewThread {

func convertToMinimalReviewComment(c reviewCommentNode) MinimalReviewComment {
m := MinimalReviewComment{
Body: string(c.Body),
Body: sanitize.Sanitize(string(c.Body)),
Path: string(c.Path),
Author: string(c.Author.Login),
HTMLURL: c.URL.String(),
Expand Down