Migrate list_issues tool from REST to GraphQL API#833
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the list_issues tool from GitHub's REST API to GraphQL API to improve performance and provide more efficient data fetching capabilities.
- Replaced REST API client with GraphQL client for issue listing functionality
- Implemented conditional GraphQL query structures based on label filtering requirements
- Migrated from page-based to cursor-based pagination with improved user guidance
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pkg/github/tools.go | Updated tool registration to use GraphQL client instead of REST client |
| pkg/github/queries.json | Added sample GraphQL response data and mock JSON structures |
| pkg/github/issues.go | Complete migration of list_issues implementation from REST to GraphQL with new data structures and pagination |
tommaso-moro
reviewed
Aug 7, 2025
nickytonline
pushed a commit
to nickytonline/github-mcp-http
that referenced
this pull request
Oct 4, 2025
* initial changes * Further advances on list_issues tool to use GRPC * Updating pagination for Graphql ListIssues * Sorting data structures & returning mapped Issue * Adding dynamic label queries * Adding dynamic state queries for list_issues * Add optional since filter, to get issues based on last update to issue * Move ListIssues test to graphql format & removal of temp file * Update documentation and fix linter issues * Removal of redundant code, and increase limit on label return * Fixing context for status to allow for better interactions * Update tool snaps with tool description * Update docs for final changes to context
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.
Migrate
list_issuestool from REST to GraphQL APIOverview
The key requirement was to ignore PRs when the
list_issuestool was used. As per #790. To accomplish this, the tool had to be migrated away from the REST API, as this was not an allowed request. Therefore this PR migrates thelist_issuestool from GitHub's REST API to GraphQL API, bringing it in line with other tools likelist_discussions. The migration provides cursor-based pagination, improved filtering, and better performance.Key Changes
github.Client(REST) togithubv4.Client(GraphQL)after,perPage)sinceparameter for date filtering (ISO 8601 format)GraphQL vs REST
Parameter Updates:
page→after(cursor-based pagination)sort→orderBywith new enum values"open"→"OPEN","closed"→"CLOSED""asc"→"ASC","desc"→"DESC""created"→"CREATED_AT","updated"→"UPDATED_AT"Implementation
Dynamic Query Selection: Factory pattern selects appropriate GraphQL query based on filtering requirements (4 query types: base, with labels, with since, with both).
Fragment Architecture: Reusable
IssueFragmentwith common interface for consistent data conversion.Testing & Quality
githubv4mockThis migration provides better performance, consistent API patterns, and enhanced filtering while maintaining backward compatibility. 🚀
Before & After
Before: Returns correct info (but included PRs) and lots of URLs.
[ { "id": 1234567890, "number": 842, "state": "open", "locked": false, "title": "[sanitized] Tool reports success when a non-existent repo owner is used", "body": "[sanitized] Bug description with reproduction steps...", "author_association": "NONE", "user": { "login": "[username]", "id": 12345678, "node_id": "[sanitized_node_id]", "avatar_url": "[sanitized_avatar_url]", "html_url": "[sanitized_profile_url]", "gravatar_id": "", "type": "User", "site_admin": false, "url": "[sanitized_api_url]", "events_url": "[sanitized_events_url]", "following_url": "[sanitized_following_url]", "followers_url": "[sanitized_followers_url]", "gists_url": "[sanitized_gists_url]", "organizations_url": "[sanitized_orgs_url]", "received_events_url": "[sanitized_received_events_url]", "repos_url": "[sanitized_repos_url]", "starred_url": "[sanitized_starred_url]", "subscriptions_url": "[sanitized_subscriptions_url]" }, "labels": [ { "id": 1234567890, "url": "[sanitized_label_url]", "name": "bug", "color": "d73a4a", "description": "Something isn't working", "default": true, "node_id": "[sanitized_node_id]" } ], "comments": 0, "created_at": "2025-08-08T02:29:19Z", "updated_at": "2025-08-08T07:32:39Z", "url": "[sanitized_api_url]", "html_url": "[sanitized_web_url]", "comments_url": "[sanitized_comments_url]", "events_url": "[sanitized_events_url]", "labels_url": "[sanitized_labels_url]", "repository_url": "[sanitized_repo_url]", "reactions": { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "confused": 0, "heart": 0, "hooray": 0, "rocket": 0, "eyes": 0, "url": "[sanitized_reactions_url]" }, "node_id": "[sanitized_node_id]" } ]After: Reduction in context, avoiding unnecessary URLs, irrelevant data and does not return PRs.
{ "issues": [ { "id": 1234567890, "number": 1234, "state": "OPEN", "title": "[sanitized] Sample issue title", "body": "[sanitized] Issue description and reproduction steps...", "user": { "login": "[username]" }, "labels": [ { "name": "bug", "description": "Something isn't working", "node_id": "[sanitized_node_id]" } ], "created_at": "2025-08-07T17:21:22Z", "updated_at": "2025-08-07T17:21:22Z" } ], "pageInfo": { "endCursor": "[base64_cursor]", "hasNextPage": true, "hasPreviousPage": false, "startCursor": "[base64_cursor]" }, "totalCount": 622 }