@@ -98,19 +98,29 @@ func (s *Server) registerTools(mcpServer *server.MCPServer) {
)
mcpServer.AddTool(getTasksTool, s.handleGetTasks)
- // Register update_task_status tool
- updateTaskStatusTool := mcp.NewTool("update_task_status",
- mcp.WithDescription("Update the status of a specific task. Maintain your planning workflow by regularly updating task statuses as you make progress."),
- mcp.WithString("task_id",
- mcp.Required(),
- mcp.Description("The task ID to update"),
- ),
- mcp.WithString("status",
+ // Register update_tasks tool
+ updateTasksTool := mcp.NewTool("update_tasks",
+ mcp.WithDescription("Update the status of one or more tasks. Maintain your planning workflow by regularly updating task statuses as you make progress."),
+ mcp.WithArray("tasks",
mcp.Required(),
- mcp.Description("New status: pending, in_progress, completed, or failed"),
+ mcp.Description("Array of task updates"),
+ mcp.Items(map[string]any{
+ "type": "object",
+ "properties": map[string]any{
+ "task_id": map[string]any{
+ "type": "string",
+ "description": "The task ID to update",
+ },
+ "status": map[string]any{
+ "type": "string",
+ "description": "New status: pending, in_progress, completed, or failed",
+ },
+ },
+ "required": []string{"task_id", "status"},
+ }),
),
)
- mcpServer.AddTool(updateTaskStatusTool, s.handleUpdateTaskStatus)
+ mcpServer.AddTool(updateTasksTool, s.handleUpdateTasks)
}
// handleUpdateGoal handles the update_goal tool call
@@ -284,49 +294,110 @@ func (s *Server) handleGetTasks(ctx context.Context, request mcp.CallToolRequest
}, nil
}
-// handleUpdateTaskStatus handles the update_task_status tool call
-func (s *Server) handleUpdateTaskStatus(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
- s.logger.Info("Received update_task_status tool call")
+// handleUpdateTasks handles the update_tasks tool call
+func (s *Server) handleUpdateTasks(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
+ s.logger.Info("Received update_tasks tool call")
// Extract parameters
arguments := request.GetArguments()
- taskID, ok := arguments["task_id"].(string)
- if !ok || taskID == "" {
+ tasksRaw, ok := arguments["tasks"]
+ if !ok {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.TextContent{
Type: "text",
- Text: "Error: task_id parameter is required and must be a string",
+ Text: "Error: tasks parameter is required",
},
},
IsError: true,
}, nil
}
- statusStr, ok := arguments["status"].(string)
- if !ok || statusStr == "" {
+ // Convert to slice of interfaces
+ tasksSlice, ok := tasksRaw.([]any)
+ if !ok {
+ return &mcp.CallToolResult{
+ Content: []mcp.Content{
+ mcp.TextContent{
+ Type: "text",
+ Text: "Error: tasks parameter must be an array",
+ },
+ },
+ IsError: true,
+ }, nil
+ }
+
+ if len(tasksSlice) == 0 {
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.TextContent{
Type: "text",
- Text: "Error: status parameter is required and must be a string",
+ Text: "Error: at least one task update is required",
},
},
IsError: true,
}, nil
}
- // Parse status
- status := planning.ParseStatus(statusStr)
+ // Parse task updates
+ updates := make([]planning.TaskUpdate, 0, len(tasksSlice))
+ for _, taskRaw := range tasksSlice {
+ taskMap, ok := taskRaw.(map[string]any)
+ if !ok {
+ return &mcp.CallToolResult{
+ Content: []mcp.Content{
+ mcp.TextContent{
+ Type: "text",
+ Text: "Error: each task update must be an object",
+ },
+ },
+ IsError: true,
+ }, nil
+ }
+
+ taskID, ok := taskMap["task_id"].(string)
+ if !ok || taskID == "" {
+ return &mcp.CallToolResult{
+ Content: []mcp.Content{
+ mcp.TextContent{
+ Type: "text",
+ Text: "Error: each task update must have a non-empty task_id",
+ },
+ },
+ IsError: true,
+ }, nil
+ }
+
+ statusStr, ok := taskMap["status"].(string)
+ if !ok || statusStr == "" {
+ return &mcp.CallToolResult{
+ Content: []mcp.Content{
+ mcp.TextContent{
+ Type: "text",
+ Text: "Error: each task update must have a non-empty status",
+ },
+ },
+ IsError: true,
+ }, nil
+ }
+
+ // Parse status
+ status := planning.ParseStatus(statusStr)
+
+ updates = append(updates, planning.TaskUpdate{
+ TaskID: taskID,
+ Status: status,
+ })
+ }
- // Update task status
- if err := s.planner.UpdateTaskStatus(taskID, status); err != nil {
- s.logger.Error("Failed to update task status", "error", err)
+ // Update task statuses
+ if err := s.planner.UpdateTasks(updates); err != nil {
+ s.logger.Error("Failed to update task statuses", "error", err)
return &mcp.CallToolResult{
Content: []mcp.Content{
mcp.TextContent{
Type: "text",
- Text: fmt.Sprintf("Error updating task status: %v", err),
+ Text: fmt.Sprintf("Error updating task statuses: %v", err),
},
},
IsError: true,