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

Function GetDiscussion

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

Source from the content-addressed store, hash-verified

283}
284
285func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
286 return NewTool(
287 ToolsetMetadataDiscussions,
288 mcp.Tool{
289 Name: "get_discussion",
290 Description: t("TOOL_GET_DISCUSSION_DESCRIPTION", "Get a specific discussion by ID"),
291 Annotations: &mcp.ToolAnnotations{
292 Title: t("TOOL_GET_DISCUSSION_USER_TITLE", "Get discussion"),
293 ReadOnlyHint: true,
294 },
295 InputSchema: &jsonschema.Schema{
296 Type: "object",
297 Properties: map[string]*jsonschema.Schema{
298 "owner": {
299 Type: "string",
300 Description: "Repository owner",
301 },
302 "repo": {
303 Type: "string",
304 Description: "Repository name",
305 },
306 "discussionNumber": {
307 Type: "number",
308 Description: "Discussion Number",
309 },
310 },
311 Required: []string{"owner", "repo", "discussionNumber"},
312 },
313 },
314 []scopes.Scope{scopes.Repo},
315 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
316 // Decode params
317 var params struct {
318 Owner string
319 Repo string
320 DiscussionNumber int32
321 }
322 if err := mapstructure.WeakDecode(args, &params); err != nil {
323 return utils.NewToolResultError(err.Error()), nil, nil
324 }
325 client, err := deps.GetGQLClient(ctx)
326 if err != nil {
327 return utils.NewToolResultError(fmt.Sprintf("failed to get GitHub GQL client: %v", err)), nil, nil
328 }
329
330 var q struct {
331 Repository struct {
332 Discussion struct {
333 Number githubv4.Int
334 Title githubv4.String
335 Body githubv4.String
336 CreatedAt githubv4.DateTime
337 Closed githubv4.Boolean
338 IsAnswered githubv4.Boolean
339 AnswerChosenAt *githubv4.DateTime
340 URL githubv4.String `graphql:"url"`
341 Category struct {
342 Name githubv4.String

Callers 3

AllToolsFunction · 0.85
Test_GetDiscussionFunction · 0.85

Calls 7

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
NewToolFunction · 0.85
GetGQLClientMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by 2

Test_GetDiscussionFunction · 0.68