Class: Legion::MCP::Tools::Absorb

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

Class Method Summary collapse

Class Method Details

.call(input:, scope: 'global') ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/legion/mcp/tools/absorb.rb', line 23

def call(input:, scope: 'global')
  log.info('Starting legion.mcp.tools.absorb.call')
  return error_response('AbsorberDispatch not available') unless dispatch_available?

  scope_str = scope.to_s
  allowed_scopes = { 'local' => :local, 'global' => :global, 'all' => :all }
  return error_response("invalid scope: #{scope}") unless allowed_scopes.key?(scope_str)

  result = Legion::Extensions::Actors::AbsorberDispatch.dispatch(
    input:   input,
    context: { scope: allowed_scopes[scope_str] }
  )

  if result[:success]
    text_response(result)
  else
    error_response(result[:error] || 'absorption failed')
  end
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.absorb.call')
  log.warn("Absorb MCP tool failed: #{e.message}")
  error_response("Absorption failed: #{e.message}")
end