28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/legion/mcp/tools/run_task.rb', line 28
def call(task:, params: {})
log.info('Starting legion.mcp.tools.run_task.call')
parts = task.split('.')
return error_response("Invalid dot notation '#{task}'. Expected format: extension.runner.function") unless parts.length == 3
ext_name, runner_name, function_name = parts
runner_class = resolve_runner_class(ext_name, runner_name)
result = Legion::Ingress.run(
payload: params,
runner_class: runner_class,
function: function_name.to_sym,
source: 'mcp',
check_subtask: true,
generate_task: true
)
text_response(result)
rescue NameError => e
handle_exception(e, level: :warn, operation: 'legion.mcp.tools.run_task.call')
log.warn("RunTask#call runner not found: #{e.message}")
error_response("Runner not found: #{e.message}")
rescue StandardError => e
handle_exception(e, level: :warn, operation: 'legion.mcp.tools.run_task.call')
log.warn("RunTask#call execution failed: #{e.message}")
error_response("Task execution failed: #{e.message}")
end
|