Class: Legion::MCP::Tools::ListChains

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

Class Method Summary collapse

Class Method Details

.call(limit: 25) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/legion/mcp/tools/list_chains.rb', line 19

def call(limit: 25)
  log.info('Starting legion.mcp.tools.list_chains.call')
  return error_response('legion-data is not connected') unless data_connected?
  return error_response('chain data model is not available') unless chain_model?

  limit = limit.to_i.clamp(1, 100)
  text_response(Legion::Data::Model::Chain.order(:id).limit(limit).all.map(&:values))
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.list_chains.call')
  log.warn("ListChains#call failed: #{e.message}")
  error_response("Failed to list chains: #{e.message}")
end