Skip to content

Commit 6689033

Browse files
committed
make repo optional, and default to .github when not provided. improve tool description
1 parent efef8ae commit 6689033

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/github/discussions.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func getQueryType(useOrdering bool, categoryID *githubv4.ID) any {
119119

120120
func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
121121
return mcp.NewTool("list_discussions",
122-
mcp.WithDescription(t("TOOL_LIST_DISCUSSIONS_DESCRIPTION", "List discussions for a repository")),
122+
mcp.WithDescription(t("TOOL_LIST_DISCUSSIONS_DESCRIPTION", "List discussions for a repository or organisation.")),
123123
mcp.WithToolAnnotation(mcp.ToolAnnotation{
124124
Title: t("TOOL_LIST_DISCUSSIONS_USER_TITLE", "List discussions"),
125125
ReadOnlyHint: ToBoolPtr(true),
@@ -129,8 +129,7 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
129129
mcp.Description("Repository owner"),
130130
),
131131
mcp.WithString("repo",
132-
mcp.Required(),
133-
mcp.Description("Repository name"),
132+
mcp.Description("Repository name. If not provided, discussions will be queried at the organisation level."),
134133
),
135134
mcp.WithString("category",
136135
mcp.Description("Optional filter by discussion category ID. If provided, only discussions with this category are listed."),
@@ -150,10 +149,15 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
150149
if err != nil {
151150
return mcp.NewToolResultError(err.Error()), nil
152151
}
153-
repo, err := RequiredParam[string](request, "repo")
152+
repo, err := OptionalParam[string](request, "repo")
154153
if err != nil {
155154
return mcp.NewToolResultError(err.Error()), nil
156155
}
156+
// when not provided, default to the .github repository
157+
// this will query discussions at the organisation level
158+
if repo == "" {
159+
repo = ".github"
160+
}
157161

158162
category, err := OptionalParam[string](request, "category")
159163
if err != nil {

0 commit comments

Comments
 (0)