21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/legion/mcp/tools/update_chain.rb', line 21
def call(id:, **attrs)
log.info('Starting legion.mcp.tools.update_chain.call')
return error_response('legion-data is not connected') unless data_connected?
return error_response('chain data model is not available') unless chain_model?
record = Legion::Data::Model::Chain[id.to_i]
return error_response("Chain #{id} not found") unless record
record.update(attrs) unless attrs.empty?
record.refresh
text_response(record.values)
rescue StandardError => e
handle_exception(e, level: :warn, operation: 'legion.mcp.tools.update_chain.call')
log.warn("UpdateChain#call failed: #{e.message}")
error_response("Failed to update chain: #{e.message}")
end
|