delete.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5package task
 6
 7import (
 8	"context"
 9
10	"git.secluded.site/lune/internal/mcp/shared"
11	"github.com/modelcontextprotocol/go-sdk/mcp"
12)
13
14// DeleteToolName is the name of the delete task tool.
15const DeleteToolName = "delete_task"
16
17// DeleteToolDescription describes the delete task tool for LLMs.
18const DeleteToolDescription = `Deletes a task from Lunatask.
19
20Required:
21- id: Task UUID or lunatask:// deep link
22
23This action is permanent and cannot be undone.`
24
25// DeleteInput is the input schema for deleting a task.
26type DeleteInput struct {
27	ID string `json:"id" jsonschema:"required"`
28}
29
30// DeleteOutput is the output schema for deleting a task.
31type DeleteOutput struct {
32	Success bool   `json:"success"`
33	ID      string `json:"id"`
34}
35
36// HandleDelete deletes a task.
37func (h *Handler) HandleDelete(
38	ctx context.Context,
39	_ *mcp.CallToolRequest,
40	input DeleteInput,
41) (*mcp.CallToolResult, DeleteOutput, error) {
42	id, err := resolveID(input.ID)
43	if err != nil {
44		return shared.ErrorResult(err.Error()), DeleteOutput{}, nil
45	}
46
47	if _, err := h.client.DeleteTask(ctx, id); err != nil {
48		return shared.ErrorResult(err.Error()), DeleteOutput{}, nil
49	}
50
51	return nil, DeleteOutput{
52		Success: true,
53		ID:      id,
54	}, nil
55}