From 4b2a5a27078bf6198d10b9b1a1e3f0019f49dbe7 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 27 Feb 2026 00:20:27 -0500 Subject: [PATCH] feat(api): add parentTaskId support to task update and MCP create Allow setting ParentTaskId when updating a task via the API (with validation that the parent exists) and when creating a task via the MCP create_task tool. Co-Authored-By: Claude Opus 4.6 --- TaskTracker.Api/Controllers/TasksController.cs | 7 +++++++ TaskTracker.Core/DTOs/UpdateTaskRequest.cs | 1 + TaskTracker.MCP/Tools/TaskTools.cs | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/TaskTracker.Api/Controllers/TasksController.cs b/TaskTracker.Api/Controllers/TasksController.cs index 17a776c..6b1ad7c 100644 --- a/TaskTracker.Api/Controllers/TasksController.cs +++ b/TaskTracker.Api/Controllers/TasksController.cs @@ -173,6 +173,13 @@ public class TasksController(ITaskRepository taskRepo, ILogger if (request.Description is not null) task.Description = request.Description; if (request.Category is not null) task.Category = request.Category; if (request.EstimatedMinutes.HasValue) task.EstimatedMinutes = request.EstimatedMinutes; + if (request.ParentTaskId.HasValue) + { + var parent = await taskRepo.GetByIdAsync(request.ParentTaskId.Value); + if (parent is null) + return BadRequest(ApiResponse.Fail("Parent task not found")); + task.ParentTaskId = request.ParentTaskId; + } await taskRepo.UpdateAsync(task); return Ok(ApiResponse.Ok(task)); diff --git a/TaskTracker.Core/DTOs/UpdateTaskRequest.cs b/TaskTracker.Core/DTOs/UpdateTaskRequest.cs index 24fd07e..b59059b 100644 --- a/TaskTracker.Core/DTOs/UpdateTaskRequest.cs +++ b/TaskTracker.Core/DTOs/UpdateTaskRequest.cs @@ -6,4 +6,5 @@ public class UpdateTaskRequest public string? Description { get; set; } public string? Category { get; set; } public int? EstimatedMinutes { get; set; } + public int? ParentTaskId { get; set; } } diff --git a/TaskTracker.MCP/Tools/TaskTools.cs b/TaskTracker.MCP/Tools/TaskTools.cs index 0226c7f..f7b51ba 100644 --- a/TaskTracker.MCP/Tools/TaskTools.cs +++ b/TaskTracker.MCP/Tools/TaskTools.cs @@ -39,9 +39,10 @@ public sealed class TaskTools HttpClient client, [Description("Title of the task")] string title, [Description("Optional description")] string? description = null, - [Description("Optional category (e.g. Engineering, Email, LaserCutting)")] string? category = null) + [Description("Optional category (e.g. Engineering, Email, LaserCutting)")] string? category = null, + [Description("Optional parent task ID to create this as a subtask")] int? parentTaskId = null) { - var payload = new { title, description, category }; + var payload = new { title, description, category, parentTaskId }; var response = await client.PostAsJsonAsync("/api/tasks", payload, JsonOptions); return await response.Content.ReadAsStringAsync(); }