Class: Legion::MCP::Tools::CreateRelationship

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

Class Method Summary collapse

Class Method Details

.call(**attrs) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/mcp/tools/create_relationship.rb', line 21

def call(**attrs)
  log.info('Starting legion.mcp.tools.create_relationship.call')
  return error_response('legion-data is not connected') unless data_connected?
  return error_response('relationship data model is not available') unless relationship_model?

  id = Legion::Data::Model::Relationship.insert(attrs)
  record = Legion::Data::Model::Relationship[id]
  text_response(record.values)
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.create_relationship.call')
  log.warn("CreateRelationship#call failed: #{e.message}")
  error_response("Failed to create relationship: #{e.message}")
end