TsgcWSAPIServer_MCP › Events › OnMCPTaskCancel
Raised when a client cancels a task with tasks/cancel.
property OnMCPTaskCancel: TsgcAI_MCP_Server_OnTaskCancelEvent;
// TsgcAI_MCP_Server_OnTaskCancelEvent = procedure(Sender: TObject; const aTask: TsgcAI_MCP_Task) of object
—
Part of the tasks extension of MCP 2026-07-28. The task is already marked as cancelled when the event fires, so aTask.IsCancelled returns True; stop the background work that runs the task. The event is published, so you can assign it in the Object Inspector or in code. See Tasks.
procedure TMainForm.OnMCPTaskCancelEvent(Sender: TObject;
const aTask: TsgcAI_MCP_Task);
begin
MemoLog.Lines.Add('#task_cancel ' + aTask.TaskId);
end;
MCPServer.OnMCPTaskCancel := OnMCPTaskCancelEvent;