types.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5package mcp
 6
 7import (
 8	"encoding/json"
 9	"fmt"
10)
11
12// Goal management requests
13
14// SetGoalRequest represents the request structure for project_management__set_goal
15type SetGoalRequest struct {
16	Title       string `json:"title" validate:"required"`
17	Description string `json:"description" validate:"required"`
18}
19
20// ChangeGoalRequest represents the request structure for project_management__change_goal
21type ChangeGoalRequest struct {
22	Title       string `json:"title" validate:"required"`
23	Description string `json:"description" validate:"required"`
24	Reason      string `json:"reason" validate:"required"`
25}
26
27// Task management requests
28
29// AddTasksRequest represents the request structure for project_management__add_tasks
30type AddTasksRequest struct {
31	Tasks []MCPTaskInput `json:"tasks" validate:"required,min=1"`
32}
33
34// MCPTaskInput represents a single task input for adding tasks
35type MCPTaskInput struct {
36	Title       string `json:"title" validate:"required"`
37	Description string `json:"description"`
38}
39
40// GetTasksRequest represents the request structure for project_management__get_tasks
41type GetTasksRequest struct {
42	Status string `json:"status,omitempty"`
43}
44
45// UpdateTaskStatusesRequest represents the request structure for project_management__update_task_statuses
46type UpdateTaskStatusesRequest struct {
47	Tasks []MCPTaskUpdateInput `json:"tasks" validate:"required,min=1"`
48}
49
50// MCPTaskUpdateInput represents a single task update input
51type MCPTaskUpdateInput struct {
52	TaskID string `json:"task_id" validate:"required"`
53	Status string `json:"status" validate:"required,oneof=pending in_progress completed cancelled failed"`
54}
55
56// DeleteTasksRequest represents the request structure for project_management__delete_tasks
57type DeleteTasksRequest struct {
58	TaskIDs []string `json:"task_ids" validate:"required,min=1"`
59}
60
61// parseRequest is a generic helper function to parse map[string]any to struct without validation
62func parseRequest[T any](arguments map[string]any, dest *T) error {
63	// Convert map to JSON then unmarshal to struct
64	jsonData, err := json.Marshal(arguments)
65	if err != nil {
66		return fmt.Errorf("failed to marshal arguments: %w", err)
67	}
68
69	if err := json.Unmarshal(jsonData, dest); err != nil {
70		return fmt.Errorf("failed to unmarshal request: %w", err)
71	}
72
73	return nil
74}