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