feat: add upvoteCount to list_discussions and get_discussion#2667
Open
rodboev wants to merge 1 commit into
Open
feat: add upvoteCount to list_discussions and get_discussion#2667rodboev wants to merge 1 commit into
rodboev wants to merge 1 commit into
Conversation
66e90e7 to
dc446c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
upvoteCountto thelist_discussionsandget_discussiontool responses. This field is on theDiscussiontype in GitHub's GraphQL API and is the primary signal for gauging community demand on feature-request discussions; without it, agents triaging feature requests have only comment count or last-activity date as proxies.Why
The
NodeFragmentstruct inpkg/github/discussions.godoes not includeUpvoteCount, so the GraphQL queries for both tools never request it. Forget_discussion, the inline anonymous struct similarly omits it. Forlist_discussions, the conversion pathNodeFragment->fragmentToDiscussion->*github.Discussionalso drops the field because go-github'sDiscussiontype does not exposeupvoteCount(it is a GraphQL-only field).Fixes #2661
What changed
pkg/github/discussions.go: AddedUpvoteCount githubv4.InttoNodeFragmentand toget_discussion's inline struct. Added"upvoteCount"to theget_discussionresponse map. Changedlist_discussionsto build response maps directly fromNodeFragmentinstead of converting through*github.Discussion, surfacingupvoteCountalong withisAnswered,closed, andanswerChosenAtthat were previously lost in conversion. Removed the now-unusedfragmentToDiscussionhelper and thego-githubimport.pkg/github/discussions_test.go: UpdatedTest_ListDiscussionsandTest_GetDiscussionto includeupvoteCountin mock data, query matchers, and response assertions.Response key changes in
list_discussionsThe old
list_discussionspath converted GraphQL results throughfragmentToDiscussioninto*github.Discussion, which serialized with REST-style JSON tags (html_url,user). The new path builds maps directly fromNodeFragment, using the same key names asget_discussionalready uses (url,author). This aligns the two discussion tools with each other and with the underlying GraphQL field names. Full mapping:html_urlurlget_discussionand GraphQLurlfielduser.loginauthor.loginget_discussionpattern and GraphQLauthorfieldMCP impact
list_discussionsandget_discussionnow includeupvoteCount;list_discussionsalso changes response keys fromhtml_url/user.logintourl/author.loginand surfacesclosed,isAnswered, andanswerChosenAt. Tool names, parameters, descriptions, and annotations are unchanged, so toolsnaps and generated docs are unaffected.Prompts tested (tool changes only)
Security / limits
The additional discussion fields are available through the existing
read:discussionscope; no new OAuth scope or permission check is added.The response includes additional discussion fields already returned by GitHub's GraphQL API for authorized discussion reads, and does not add extra API calls or pagination changes.
Tool renaming
deprecated_tool_aliases.goLint & tests
Linted locally with
./script/lintNot run locally.
Tested locally with
./script/testNot run locally. The full race suite was not run locally.
go test -race ./pkg/github -run 'Test_(ListDiscussions|GetDiscussion)$'- covers: upvoteCount presence and correct value in both list and get responses; isAnswered and closed now surfaced in list_discussions; query matcher includes upvoteCount field.Docs
Tool names, parameters, descriptions, and annotations are unchanged. Toolsnaps and generated docs are unaffected.