Class: RosettAi::Mcp::Tools::WorkflowExecuteTool

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/mcp/tools/workflow_execute_tool.rb

Overview

MCP tool: execute a named workflow.

Runs a declarative workflow by name. Write operation — executes workflow steps.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =

Returns MCP tool identifier string.

Returns:

  • (String)

    MCP tool identifier string.

'rai_workflow_execute'
DESCRIPTION =

Returns Human-readable description of this tool.

Returns:

  • (String)

    Human-readable description of this tool.

'Execute a named rai workflow'
ANNOTATIONS =

Returns MCP protocol annotations describing tool capabilities.

Returns:

  • (Hash)

    MCP protocol annotations describing tool capabilities.

{
  'readOnlyHint' => false,
  'destructiveHint' => false,
  'idempotentHint' => false,
  'openWorldHint' => false
}.freeze
INPUT_SCHEMA =

Returns JSON Schema defining the tool input parameters.

Returns:

  • (Hash)

    JSON Schema defining the tool input parameters.

{
  type: 'object',
  properties: {
    name: {
      type: 'string',
      description: 'Workflow name to execute'
    },
    resume: {
      type: 'boolean',
      description: 'Resume a previously interrupted workflow (default: false)'
    }
  },
  required: ['name']
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(name:, resume: false) ⇒ Hash

Executes the named workflow.

Parameters:

  • name (String)

    workflow name

  • resume (Boolean) (defaults to: false)

    resume a previously interrupted workflow

Returns:

  • (Hash)

    execution results



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rosett_ai/mcp/tools/workflow_execute_tool.rb', line 51

def call(name:, resume: false)
  return ResponseHelper.error('Workflow name is required') if name.nil? || name.empty?

  path = resolve_workflow(name)
  return ResponseHelper.error("Workflow '#{name}' not found") unless path

  engine = RosettAi::Workflow::Engine.new(workflow_path: path)
  build_result(name, engine.execute(resume: resume))
rescue StandardError => e
  ResponseHelper.error("Workflow execute failed: #{e.message}")
end