| 391 | } |
| 392 | |
| 393 | func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 394 | return NewTool( |
| 395 | ToolsetMetadataDiscussions, |
| 396 | mcp.Tool{ |
| 397 | Name: "get_discussion_comments", |
| 398 | Description: t("TOOL_GET_DISCUSSION_COMMENTS_DESCRIPTION", "Get comments from a discussion"), |
| 399 | Annotations: &mcp.ToolAnnotations{ |
| 400 | Title: t("TOOL_GET_DISCUSSION_COMMENTS_USER_TITLE", "Get discussion comments"), |
| 401 | ReadOnlyHint: true, |
| 402 | }, |
| 403 | InputSchema: WithCursorPagination(&jsonschema.Schema{ |
| 404 | Type: "object", |
| 405 | Properties: map[string]*jsonschema.Schema{ |
| 406 | "owner": { |
| 407 | Type: "string", |
| 408 | Description: "Repository owner", |
| 409 | }, |
| 410 | "repo": { |
| 411 | Type: "string", |
| 412 | Description: "Repository name", |
| 413 | }, |
| 414 | "discussionNumber": { |
| 415 | Type: "number", |
| 416 | Description: "Discussion Number", |
| 417 | }, |
| 418 | "includeReplies": { |
| 419 | Type: "boolean", |
| 420 | Description: "When true, each top-level comment will include its replies nested within it (up to 100 replies per comment, which is the GitHub API maximum). Defaults to false.", |
| 421 | }, |
| 422 | }, |
| 423 | Required: []string{"owner", "repo", "discussionNumber"}, |
| 424 | }), |
| 425 | }, |
| 426 | []scopes.Scope{scopes.Repo}, |
| 427 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 428 | // Decode params |
| 429 | var params struct { |
| 430 | Owner string |
| 431 | Repo string |
| 432 | DiscussionNumber int32 |
| 433 | } |
| 434 | if err := mapstructure.WeakDecode(args, ¶ms); err != nil { |
| 435 | return utils.NewToolResultError(err.Error()), nil, nil |
| 436 | } |
| 437 | |
| 438 | includeReplies, err := OptionalParam[bool](args, "includeReplies") |
| 439 | if err != nil { |
| 440 | return utils.NewToolResultError(err.Error()), nil, nil |
| 441 | } |
| 442 | |
| 443 | // Get pagination parameters and convert to GraphQL format |
| 444 | pagination, err := OptionalCursorPaginationParams(args) |
| 445 | if err != nil { |
| 446 | return nil, nil, err |
| 447 | } |
| 448 | |
| 449 | // Check if pagination parameters were explicitly provided |
| 450 | _, perPageProvided := args["perPage"] |