Class: Sidekiq::Mcp::Tools::StreamStatsTool

Inherits:
Sidekiq::Mcp::Tool show all
Defined in:
lib/sidekiq/mcp/tools/stream_stats_tool.rb

Instance Method Summary collapse

Methods inherited from Sidekiq::Mcp::Tool

arguments, #call, description, schema_to_json_schema, to_tool_definition

Instance Method Details

#perform(interval: 5) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sidekiq/mcp/tools/stream_stats_tool.rb', line 16

def perform(interval: 5)
  # This tool is designed to work with SSE streaming
  # In a real implementation, this would start a background task
  # For now, we'll return the current stats with streaming info
  
  stats = Sidekiq::Stats.new
  current_stats = {
    timestamp: Time.now.utc.iso8601,
    processed: stats.processed,
    failed: stats.failed,
    busy: stats.workers_size,
    enqueued: stats.enqueued,
    scheduled: stats.scheduled_size,
    retry: stats.retry_size,
    dead: stats.dead_size,
    processes: stats.processes_size,
    default_queue_latency: stats.default_queue_latency
  }
  
  {
    message: "Stats streaming initiated with #{interval}s interval",
    current_stats: current_stats,
    sse_endpoint: "/sidekiq-mcp/sse",
    note: "Connect to SSE endpoint to receive real-time updates"
  }.to_json
end