MCPcopy Index your code
hub / github.com/github/github-mcp-server / ListDiscussions

Function ListDiscussions

pkg/github/discussions.go:128–283  ·  view source on GitHub ↗
(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

126}
127
128func ListDiscussions(t translations.TranslationHelperFunc) inventory.ServerTool {
129 return NewTool(
130 ToolsetMetadataDiscussions,
131 mcp.Tool{
132 Name: "list_discussions",
133 Description: t("TOOL_LIST_DISCUSSIONS_DESCRIPTION", "List discussions for a repository or organisation."),
134 Annotations: &mcp.ToolAnnotations{
135 Title: t("TOOL_LIST_DISCUSSIONS_USER_TITLE", "List discussions"),
136 ReadOnlyHint: true,
137 },
138 InputSchema: WithCursorPagination(&jsonschema.Schema{
139 Type: "object",
140 Properties: map[string]*jsonschema.Schema{
141 "owner": {
142 Type: "string",
143 Description: "Repository owner",
144 },
145 "repo": {
146 Type: "string",
147 Description: "Repository name. If not provided, discussions will be queried at the organisation level.",
148 },
149 "category": {
150 Type: "string",
151 Description: "Optional filter by discussion category ID. If provided, only discussions with this category are listed.",
152 },
153 "orderBy": {
154 Type: "string",
155 Description: "Order discussions by field. If provided, the 'direction' also needs to be provided.",
156 Enum: []any{"CREATED_AT", "UPDATED_AT"},
157 },
158 "direction": {
159 Type: "string",
160 Description: "Order direction.",
161 Enum: []any{"ASC", "DESC"},
162 },
163 },
164 Required: []string{"owner"},
165 }),
166 },
167 []scopes.Scope{scopes.Repo},
168 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
169 owner, err := RequiredParam[string](args, "owner")
170 if err != nil {
171 return utils.NewToolResultError(err.Error()), nil, nil
172 }
173 repo, err := OptionalParam[string](args, "repo")
174 if err != nil {
175 return utils.NewToolResultError(err.Error()), nil, nil
176 }
177 // when not provided, default to the .github repository
178 // this will query discussions at the organisation level
179 if repo == "" {
180 repo = ".github"
181 }
182
183 category, err := OptionalParam[string](args, "category")
184 if err != nil {
185 return utils.NewToolResultError(err.Error()), nil, nil

Callers 2

AllToolsFunction · 0.85
Test_ListDiscussionsFunction · 0.85

Calls 13

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
NewToolFunction · 0.85
WithCursorPaginationFunction · 0.85
getQueryTypeFunction · 0.85
fragmentToDiscussionFunction · 0.85
GetGQLClientMethod · 0.65
GetDiscussionFragmentMethod · 0.65
ErrorMethod · 0.45
ToGraphQLParamsMethod · 0.45

Tested by 1

Test_ListDiscussionsFunction · 0.68