// Copyright 2025 eat-pray-ai & OpenWaygate
// SPDX-License-Identifier: Apache-2.0
package comment
import (
"io"
"github.com/eat-pray-ai/yutu/cmd"
"github.com/eat-pray-ai/yutu/pkg/comment"
"github.com/eat-pray-ai/yutu/pkg/utils"
"github.com/google/jsonschema-go/jsonschema"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/spf13/cobra"
)
const (
deleteTool = "comment-delete"
deleteShort = "Delete YouTube comments"
deleteLong = "Delete YouTube comments by ids"
)
var deleteInSchema = &jsonschema.Schema{
Type: "object",
Required: []string{"ids"},
Properties: map[string]*jsonschema.Schema{
"ids": {
Type: "array", Description: idsUsage,
Items: &jsonschema.Schema{Type: "string"},
},
},
}
func init() {
mcp.AddTool(
cmd.Server, &mcp.Tool{
Name: deleteTool, Title: deleteShort, Description: deleteLong,
InputSchema: deleteInSchema, Annotations: &mcp.ToolAnnotations{
DestructiveHint: jsonschema.Ptr(true),
IdempotentHint: false,
OpenWorldHint: jsonschema.Ptr(true),
ReadOnlyHint: false,
},
}, cmd.GenToolHandler(
deleteTool, func(input comment.Comment, writer io.Writer) error {
return input.Delete(writer)
},
),
)
commentCmd.AddCommand(deleteCmd)
deleteCmd.Flags().StringSliceVarP(&ids, "ids", "i", []string{}, idsUsage)
_ = deleteCmd.MarkFlagRequired("ids")
}
var deleteCmd = &cobra.Command{
Use: "delete",
Short: deleteShort,
Long: deleteLong,
Run: func(cmd *cobra.Command, args []string) {
input := comment.NewComment(comment.WithIds(ids))
utils.HandleCmdError(input.Delete(cmd.OutOrStdout()), cmd)
},
}