-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I prepared this Issue with Claude Code and edited/reviewed it heavily, but did not audit its specific code references, so apologies if e.g. line numbers are not quite precise; consider it pseudocode but hopefully it's pretty actionable.
Related to: #671 (but I broke this out because 670 here should be less controversial/very aligned with current designs)
Describe the feature or problem you'd like to solve
I'm building out some workflows that will pull and summarize Discussions, and some notably missing pieces that I think make sense to add from a tool design perspective to list_discussions
are readily available in the GraphQL API:
Current missing data in list_discussions
(pkg/github/discussions.go:71-78, 110-118):
author.login
information in responseupdatedAt
field in response (onlycreatedAt
)orderBy
parameter (can't sort by UPDATED_AT)direction
parameter (can't control ASC/DESC)
This makes it difficult to:
- Find recently active discussions (those with new comments/updates)
- Know who started discussions without making out of band API calls
Proposed solution
1. Add missing fields to the GraphQL query (pkg/github/discussions.go:71-78):
Nodes []struct {
Number githubv4.Int
Title githubv4.String
CreatedAt githubv4.DateTime
UpdatedAt githubv4.DateTime // Add
Author struct { // Add
Login githubv4.String
}
Category struct {
Name githubv4.String
}
URL githubv4.String `graphql:"url"`
}
2. Add orderBy parameters to the tool definition (pkg/github/discussions.go:16-34):
mcp.WithString("orderBy",
mcp.Description("Sort discussions by field"),
mcp.Enum("CREATED_AT", "UPDATED_AT"),
),
mcp.WithString("direction",
mcp.Description("Sort direction"),
mcp.Enum("ASC", "DESC"),
),
3. Update the GraphQL query to use ordering (pkg/github/discussions.go:80, 119):
} `graphql:"discussions(first: 100, orderBy: $orderBy)"`
The GitHub GraphQL API fully supports these fields, as demonstrated:
query {
repository(owner: "vercel", name: "next.js") {
discussions(first: 3, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
number
title
createdAt
updatedAt
author {
login
}
}
}
}
}
Example prompts or workflows (for tools/toolsets only)
-
"Show me discussions that have been updated in the last 24 hours"
- Sort by UPDATED_AT, then filter client-side by date
-
"List the most recently active discussions with their authors"
orderBy: "UPDATED_AT", direction: "DESC"
to get recently active threads- Use
author.login
to see who started each discussion
-
"Monitor discussions started by external contributors"
- Filter by author.login to identify non-team discussions
- Sort by UPDATED_AT to catch new activity
-
"Generate a weekly discussion activity report"
- Sort by UPDATED_AT to find all discussions with recent activity
- Group by author.login to show top contributors
-
"Find stale discussions that need attention"
- Sort by UPDATED_AT in ASC order
- Compare updatedAt vs createdAt to find abandoned threads
Additional context
Comparison with other tools in the codebase:
list_issues
already has bothsort
(including "updated") andsince
parameters (pkg/github/issues.go:351-361)list_pull_requests
hassort
with "updated" option (pkg/github/pullrequests.go:356-358)- Discussions should have feature parity with these other tools
GraphQL API verification:
The DiscussionOrderField enum supports both CREATED_AT and UPDATED_AT:
{"name":"CREATED_AT","description":"Order discussions by creation time."},
{"name":"UPDATED_AT","description":"Order discussions by most recent modification time."}