| 599 | } |
| 600 | |
| 601 | func DiscussionCommentWrite(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 602 | return NewTool( |
| 603 | ToolsetMetadataDiscussions, |
| 604 | mcp.Tool{ |
| 605 | Name: "discussion_comment_write", |
| 606 | Description: t("TOOL_DISCUSSION_COMMENT_WRITE_DESCRIPTION", `Write operations for discussion comments. |
| 607 | Supports adding top-level comments, replying to existing comments, updating comment content, deleting comments, and marking or unmarking comments as the answer.`), |
| 608 | Annotations: &mcp.ToolAnnotations{ |
| 609 | Title: t("TOOL_DISCUSSION_COMMENT_WRITE_USER_TITLE", "Manage discussion comments"), |
| 610 | ReadOnlyHint: false, |
| 611 | DestructiveHint: jsonschema.Ptr(true), |
| 612 | }, |
| 613 | InputSchema: &jsonschema.Schema{ |
| 614 | Type: "object", |
| 615 | Properties: map[string]*jsonschema.Schema{ |
| 616 | "method": { |
| 617 | Type: "string", |
| 618 | Description: `Write operation to perform on a discussion comment. |
| 619 | Options are: |
| 620 | - 'add' - adds a new top-level comment to a discussion. |
| 621 | - 'reply' - replies to a top-level discussion comment (GitHub Discussions only support one level of nesting). |
| 622 | - 'update' - updates an existing discussion comment. |
| 623 | - 'delete' - deletes a discussion comment. |
| 624 | - 'mark_answer' - marks a discussion comment as the answer (Q&A only). |
| 625 | - 'unmark_answer' - unmarks a discussion comment as the answer (Q&A only). |
| 626 | `, |
| 627 | Enum: []any{"add", "reply", "update", "delete", "mark_answer", "unmark_answer"}, |
| 628 | }, |
| 629 | "owner": { |
| 630 | Type: "string", |
| 631 | Description: "Repository owner (required for 'add' and 'reply' methods)", |
| 632 | }, |
| 633 | "repo": { |
| 634 | Type: "string", |
| 635 | Description: "Repository name (required for 'add' and 'reply' methods)", |
| 636 | }, |
| 637 | "discussionNumber": { |
| 638 | Type: "number", |
| 639 | Description: "Discussion number (required for 'add' and 'reply' methods)", |
| 640 | }, |
| 641 | "body": { |
| 642 | Type: "string", |
| 643 | Description: "Comment content (required for 'add', 'reply', and 'update' methods)", |
| 644 | }, |
| 645 | "commentNodeID": { |
| 646 | Type: "string", |
| 647 | Description: "The Node ID of the discussion comment (required for 'reply', 'update', 'delete', 'mark_answer', and 'unmark_answer' methods). For 'reply', this is the top-level comment to reply to; GitHub Discussions only support one level of nesting.", |
| 648 | }, |
| 649 | }, |
| 650 | Required: []string{"method"}, |
| 651 | }, |
| 652 | }, |
| 653 | []scopes.Scope{scopes.Repo}, |
| 654 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 655 | method, err := RequiredParam[string](args, "method") |
| 656 | if err != nil { |
| 657 | return utils.NewToolResultError(err.Error()), nil, nil |
| 658 | } |