Class: Legion::MCP::Tools::DeleteTask

Inherits:
MCP::Tool
  • Object
show all
Extended by:
Logging::Helper
Defined in:
lib/legion/mcp/tools/delete_task.rb

Class Method Summary collapse

Class Method Details

.call(id:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/mcp/tools/delete_task.rb', line 20

def call(id:)
  log.info('Starting legion.mcp.tools.delete_task.call')
  return error_response('legion-data is not connected') unless data_connected?

  task = Legion::Data::Model::Task[id.to_i]
  return error_response("Task #{id} not found") unless task

  task.delete
  text_response({ deleted: true, id: id })
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.delete_task.call')
  log.warn("DeleteTask#call failed: #{e.message}")
  error_response("Failed to delete task: #{e.message}")
end