Skip to content

Adding comments sorting for list_issues #854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025

Conversation

MattBabbage
Copy link
Contributor

@MattBabbage MattBabbage commented Aug 11, 2025

Summary

This PR adds comment count support to the list_issues tool in the GitHub MCP Server, enabling users to view and sort issues by their comment activity.

Changes Made

Core Functionality

  • Added comment count field: Modified IssueFragment struct to include a Comments.TotalCount field that fetches the total number of comments for each issue via GraphQL
  • Enhanced issue data: Updated fragmentToIssue() function to include the comment count in the returned issue object
  • New sorting option: Added "COMMENTS" as a sorting option for the orderBy parameter in the list_issues tool

Files Modified

  • pkg/github/issues.go: Core implementation changes
  • pkg/github/issues_test.go: Updated tests with comment count mock data and GraphQL query validation
  • pkg/github/__toolsnaps__/list_issues.snap: Updated tool snapshot to reflect new enum option

Benefits

  • Enhanced issue prioritization: Users can now sort issues by engagement level (comment count) to identify the most discussed or problematic issues
  • Better context: Comment counts provide immediate insight into issue activity without needing to fetch comments separately
  • Improved workflow: Enables data-driven approaches to issue triage and management

Usage Example

// Sort issues by comment count (most commented first)
list_issues({
  owner: "github",
  repo: "github-mcp-server", 
  orderBy: "COMMENTS",
  direction: "DESC"
})

Result

image

@MattBabbage MattBabbage requested a review from a team as a code owner August 11, 2025 14:14
@Copilot Copilot AI review requested due to automatic review settings August 11, 2025 14:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for sorting issues by comment count in the list_issues functionality. The implementation extends the GraphQL query to include comment counts and adds "COMMENTS" as a new ordering option.

  • Adds comment count data to the GraphQL issue fragment and response mapping
  • Introduces "COMMENTS" as a new sorting option for the orderBy parameter
  • Updates test data to include comment counts for proper test coverage

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/github/issues.go Adds comment count field to GraphQL fragment, updates issue mapping, and adds COMMENTS enum option
pkg/github/issues_test.go Updates test data with comment counts and GraphQL query strings to match new implementation
pkg/github/toolsnaps/list_issues.snap Updates tool snapshot to include COMMENTS in the orderBy enum options

@MattBabbage MattBabbage merged commit f818830 into main Aug 11, 2025
16 checks passed
@MattBabbage MattBabbage deleted the fix/add-comment-sorting-to-list-issues branch August 11, 2025 14:48
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.

2 participants