Class: McpServer::NotYetStartedTool

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/jirametrics/mcp_server.rb

Class Method Summary collapse

Class Method Details

.call(server_context:, project: nil, project_name: nil, current_status: nil, current_column: nil, history_field: nil, history_value: nil, ever_blocked: nil, ever_stalled: nil, currently_blocked: nil, currently_stalled: nil) ⇒ Object



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/jirametrics/mcp_server.rb', line 395

def self.call(server_context:, project: nil, project_name: nil, current_status: nil, current_column: nil,
              history_field: nil, history_value: nil, ever_blocked: nil, ever_stalled: nil,
              currently_blocked: nil, currently_stalled: nil, **)
  project ||= project_name
  rows = []
  allowed_projects = McpServer.resolve_projects(server_context, project)

  server_context[:projects].each do |project_name, project_data|
    next if allowed_projects && !allowed_projects.include?(project_name)

    project_data[:issues].each do |issue|
      started, stopped = issue.started_stopped_times
      next if started || stopped
      next if current_status && issue.status.name != current_status
      next if current_column && McpServer.column_name_for(issue.board, issue.status.id) != current_column
      unless McpServer.matches_history?(issue, project_data[:end_time],
                                        history_field, history_value, ever_blocked, ever_stalled,
                                        currently_blocked, currently_stalled)
        next
      end

      rows << {
        key: issue.key,
        summary: issue.summary,
        status: issue.status.name,
        type: issue.type,
        created: issue.created.to_date,
        project: project_name
      }
    end
  end

  rows.sort_by! { |r| r[:created] }

  if rows.empty?
    text = 'No unstarted work found.'
  else
    lines = rows.map do |r|
      "#{r[:key]} | #{r[:project]} | #{r[:type]} | #{r[:status]} | Created: #{r[:created]} | #{r[:summary]}"
    end
    text = lines.join("\n")
  end

  MCP::Tool::Response.new([{ type: 'text', text: text }])
end