Skip to content

Commit bc5abbd

Browse files
committed
Add answered parameter to ListDiscussions
1 parent e10d76a commit bc5abbd

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
628628
- `before`: Pagination - Cursor to end with (string, optional)
629629
- `sort`: Sort by ('CREATED_AT', 'UPDATED_AT') (string, optional)
630630
- `direction`: Sort direction ('ASC', 'DESC') (string, optional)
631+
- `answered`: Filter by whether discussions have been answered or not (boolean, optional)
631632

632633
- **get_discussion** - Get a specific discussion by ID
633634
- `owner`: Repository owner (string, required)

pkg/github/discussions.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
6161
mcp.WithString("before",
6262
mcp.Description("Cursor for pagination, use the 'before' field from the previous response"),
6363
),
64+
mcp.WithBoolean("answered",
65+
mcp.Description("Filter by whether discussions have been answered or not"),
66+
),
6467
),
6568
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
6669
// Decode params
@@ -75,6 +78,7 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
7578
Last int32
7679
After string
7780
Before string
81+
Answered bool
7882
}
7983
if err := mapstructure.Decode(request.Params.Arguments, &params); err != nil {
8084
return mcp.NewToolResultError(err.Error()), nil
@@ -109,7 +113,7 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
109113
} `graphql:"category"`
110114
URL githubv4.String `graphql:"url"`
111115
}
112-
} `graphql:"discussions(categoryId: $categoryId, orderBy: {field: $sort, direction: $direction}, first: $first, after: $after, last: $last, before: $before)"`
116+
} `graphql:"discussions(categoryId: $categoryId, orderBy: {field: $sort, direction: $direction}, first: $first, after: $after, last: $last, before: $before, answered: $answered)"`
113117
} `graphql:"repository(owner: $owner, name: $repo)"`
114118
}
115119
// Build query variables
@@ -123,6 +127,7 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
123127
"last": githubv4.Int(params.Last),
124128
"after": githubv4.String(params.After),
125129
"before": githubv4.String(params.Before),
130+
"answered": githubv4.Boolean(params.Answered),
126131
}
127132
// Execute query
128133
if err := client.Query(ctx, &q, vars); err != nil {

pkg/github/discussions_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func Test_ListDiscussions(t *testing.T) {
5555
} `graphql:"category"`
5656
URL githubv4.String `graphql:"url"`
5757
}
58-
} `graphql:"discussions(categoryId: $categoryId, orderBy: {field: $sort, direction: $direction}, first: $first, after: $after, last: $last, before: $before)"`
58+
} `graphql:"discussions(categoryId: $categoryId, orderBy: {field: $sort, direction: $direction}, first: $first, after: $after, last: $last, before: $before, answered: $answered)"`
5959
} `graphql:"repository(owner: $owner, name: $repo)"`
6060
}
6161

@@ -69,6 +69,7 @@ func Test_ListDiscussions(t *testing.T) {
6969
"last": githubv4.Int(0),
7070
"after": githubv4.String(""),
7171
"before": githubv4.String(""),
72+
"answered": githubv4.Boolean(false),
7273
}
7374

7475
varsListInvalid := map[string]interface{}{
@@ -81,6 +82,7 @@ func Test_ListDiscussions(t *testing.T) {
8182
"last": githubv4.Int(0),
8283
"after": githubv4.String(""),
8384
"before": githubv4.String(""),
85+
"answered": githubv4.Boolean(false),
8486
}
8587

8688
varsListWithCategory := map[string]interface{}{
@@ -93,6 +95,7 @@ func Test_ListDiscussions(t *testing.T) {
9395
"last": githubv4.Int(0),
9496
"after": githubv4.String(""),
9597
"before": githubv4.String(""),
98+
"answered": githubv4.Boolean(false),
9699
}
97100

98101
tests := []struct {

0 commit comments

Comments
 (0)