Class: TrakFlow::Mcp::Tools::TaskCreate

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/trak_flow/mcp/tools/task_create.rb

Instance Method Summary collapse

Methods inherited from BaseTool

with_database

Instance Method Details

#call(title:, type: "task", priority: 2, description: nil, assignee: nil, parent_id: nil, labels: []) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/trak_flow/mcp/tools/task_create.rb', line 20

def call(title:, type: "task", priority: 2, description: nil, assignee: nil, parent_id: nil, labels: [])
  self.class.with_database do |db|
    task = if parent_id
        db.create_child_task(parent_id, {
          title: title,
          description: description,
          type: type,
          priority: priority,
          assignee: assignee
        })
      else
        new_task = Models::Task.new(
          title: title,
          description: description,
          type: type,
          priority: priority,
          assignee: assignee
        )
        db.create_task(new_task)
      end

    labels.each do |label_name|
      db.add_label(Models::Label.new(task_id: task.id, name: label_name))
    end

    task.to_h
  end
end