Class: HTM::MCP::FailoverTool

Inherits:
FastMcp::Tool
  • Object
show all
Defined in:
lib/htm/mcp/group_tools.rb

Overview

Tool: Trigger automatic failover

Instance Method Summary collapse

Instance Method Details

#call(group_name:) ⇒ Object



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/htm/mcp/group_tools.rb', line 338

def call(group_name:)
  Session.logger&.info "FailoverTool called: group=#{group_name.inspect}"

  group = GroupSession.get_group(group_name)
  unless group
    return { success: false, error: "Group '#{group_name}' not found in this session" }.to_json
  end

  promoted = group.failover!

  Session.logger&.info "Failover complete: #{promoted} promoted to active in group #{group_name}"

  {
    success:        true,
    group_name:     group_name,
    promoted_robot: promoted,
    message:        "Failover complete. Robot '#{promoted}' is now active."
  }.to_json
rescue RuntimeError => e
  { success: false, error: e.message }.to_json
end