diff --git a/src/ClaudeDo.Worker/External/ExternalMcpService.cs b/src/ClaudeDo.Worker/External/ExternalMcpService.cs index 4550988..c8aede6 100644 --- a/src/ClaudeDo.Worker/External/ExternalMcpService.cs +++ b/src/ClaudeDo.Worker/External/ExternalMcpService.cs @@ -10,6 +10,8 @@ using TaskStatus = ClaudeDo.Data.Models.TaskStatus; namespace ClaudeDo.Worker.External; public sealed record TaskListDto(string Id, string Name, string? WorkingDir); +public sealed record DeleteTaskResult(bool Deleted, string Id); +public sealed record CancelTaskResult(bool Cancelled, string Id); public sealed record TaskDto( string Id, @@ -206,16 +208,16 @@ public sealed class ExternalMcpService await _broadcaster.TaskUpdated(taskId); } - [McpServerTool, Description("Cancel a running task. Returns true if the task was running and cancellation was requested.")] - public async Task CancelTask(string taskId, CancellationToken cancellationToken) + [McpServerTool, Description("Cancel a running task. Returns { cancelled: true, id } if the task was running and cancellation was requested; cancelled is false if the task was not running.")] + public async Task CancelTask(string taskId, CancellationToken cancellationToken) { var cancelled = _queue.CancelTask(taskId); if (cancelled) await _broadcaster.TaskUpdated(taskId); - return cancelled; + return new CancelTaskResult(cancelled, taskId); } - [McpServerTool, Description("Delete a task. Refuses if the task is currently Running — cancel it first.")] - public async Task DeleteTask(string taskId, CancellationToken cancellationToken) + [McpServerTool, Description("Delete a task. Returns { deleted: true, id } on success. Throws if the task is not found or is currently Running — cancel it first.")] + public async Task DeleteTask(string taskId, CancellationToken cancellationToken) { var task = await _tasks.GetByIdAsync(taskId, cancellationToken) ?? throw new InvalidOperationException($"Task {taskId} not found."); @@ -224,6 +226,7 @@ public sealed class ExternalMcpService await _tasks.DeleteAsync(taskId, cancellationToken); await _broadcaster.TaskUpdated(taskId); + return new DeleteTaskResult(true, taskId); } private static TaskDto ToDto(TaskEntity t) => new(