Skip to content

feat: add upvoteCount to list_discussions and get_discussion#2667

Open
rodboev wants to merge 1 commit into
github:mainfrom
rodboev:pr/discussions-upvote-count
Open

feat: add upvoteCount to list_discussions and get_discussion#2667
rodboev wants to merge 1 commit into
github:mainfrom
rodboev:pr/discussions-upvote-count

Conversation

@rodboev

@rodboev rodboev commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Adds upvoteCount to the list_discussions and get_discussion tool responses. This field is on the Discussion type 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 NodeFragment struct in pkg/github/discussions.go does not include UpvoteCount, so the GraphQL queries for both tools never request it. For get_discussion, the inline anonymous struct similarly omits it. For list_discussions, the conversion path NodeFragment -> fragmentToDiscussion -> *github.Discussion also drops the field because go-github's Discussion type does not expose upvoteCount (it is a GraphQL-only field).

Fixes #2661

What changed

  • pkg/github/discussions.go: Added UpvoteCount githubv4.Int to NodeFragment and to get_discussion's inline struct. Added "upvoteCount" to the get_discussion response map. Changed list_discussions to build response maps directly from NodeFragment instead of converting through *github.Discussion, surfacing upvoteCount along with isAnswered, closed, and answerChosenAt that were previously lost in conversion. Removed the now-unused fragmentToDiscussion helper and the go-github import.
  • pkg/github/discussions_test.go: Updated Test_ListDiscussions and Test_GetDiscussion to include upvoteCount in mock data, query matchers, and response assertions.

Response key changes in list_discussions

The old list_discussions path converted GraphQL results through fragmentToDiscussion into *github.Discussion, which serialized with REST-style JSON tags (html_url, user). The new path builds maps directly from NodeFragment, using the same key names as get_discussion already uses (url, author). This aligns the two discussion tools with each other and with the underlying GraphQL field names. Full mapping:

Before After Reason
html_url url Matches get_discussion and GraphQL url field
user.login author.login Matches get_discussion pattern and GraphQL author field

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
    list_discussions and get_discussion now include upvoteCount; list_discussions also changes response keys from html_url / user.login to url / author.login and surfaces closed, isAnswered, and answerChosenAt. Tool names, parameters, descriptions, and annotations are unchanged, so toolsnaps and generated docs are unaffected.
  • New tool added

Prompts tested (tool changes only)

  • "List recent discussions in owner/repo and include their upvote counts."
  • "Get discussion Port CLI Server #1 in owner/repo and show whether it is answered and how many upvotes it has."

Security / limits

  • No security or limits impact
  • Auth / permissions considered
    The additional discussion fields are available through the existing read:discussion scope; no new OAuth scope or permission check is added.
  • Data exposure, filtering, or token/size limits considered
    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

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
    Not run locally.

  • Tested locally with ./script/test
    Not 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

  • Not needed
    Tool names, parameters, descriptions, and annotations are unchanged. Toolsnaps and generated docs are unaffected.

@rodboev rodboev requested a review from a team as a code owner June 10, 2026 20:36
@rodboev rodboev force-pushed the pr/discussions-upvote-count branch from 66e90e7 to dc446c2 Compare June 11, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list_discussions and get_discussion should include upvoteCount

1 participant