Skip to main content
Glama
jakedx6

Helios-9 MCP Server

by jakedx6

execute_workflow_rule

Manually execute a workflow rule with test data to simulate trigger events and verify behavior before deployment.

Instructions

Manually execute a workflow rule for testing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYesID of the rule to execute
test_dataNoTest data to simulate the trigger event
dry_runNoIf true, only simulate execution without performing actions

Implementation Reference

  • The primary handler function for the 'execute_workflow_rule' tool. It validates input, retrieves the workflow rule, executes each action (or simulates in dry_run mode), handles errors, logs execution, and returns detailed results.
    export const executeWorkflowRule = requireAuth(async (args: any) => {
      const { rule_id, test_data, dry_run } = ExecuteWorkflowRuleSchema.parse(args)
      
      logger.info('Executing workflow rule', { rule_id, dry_run })
    
      const rule = await supabaseService.getWorkflowRule(rule_id)
      if (!rule) {
        throw new Error('Workflow rule not found')
      }
    
      if (!rule.enabled && !dry_run) {
        throw new Error('Cannot execute disabled rule (use dry_run for testing)')
      }
    
      const executionResults = []
      
      for (const action of rule.actions) {
        try {
          const result = await executeAction(action, test_data, dry_run)
          executionResults.push({
            action_type: action.action_type,
            success: true,
            result,
            dry_run
          })
        } catch (error) {
          logger.error(`Failed to execute action ${action.action_type}:`, error)
          executionResults.push({
            action_type: action.action_type,
            success: false,
            error: error instanceof Error ? error.message : 'Unknown error',
            dry_run
          })
        }
      }
    
      // Log execution if not dry run
      if (!dry_run) {
        await supabaseService.logWorkflowExecution({
          rule_id,
          trigger_data: test_data,
          execution_results: executionResults,
          executed_at: new Date().toISOString()
        })
      }
    
      return {
        rule_name: rule.name,
        executed_actions: executionResults.length,
        successful_actions: executionResults.filter(r => r.success).length,
        failed_actions: executionResults.filter(r => !r.success).length,
        results: executionResults,
        dry_run
      }
    })
  • Zod schema used for input validation in the executeWorkflowRule handler.
    const ExecuteWorkflowRuleSchema = z.object({
      rule_id: z.string().min(1),
      test_data: z.record(z.any()).optional(),
      dry_run: z.boolean().default(false)
    })
  • MCPTool object definition registering the 'execute_workflow_rule' tool with name, description, and input schema.
    export const executeWorkflowRuleTool: MCPTool = {
      name: 'execute_workflow_rule',
      description: 'Manually execute a workflow rule for testing',
      inputSchema: {
        type: 'object',
        properties: {
          rule_id: {
            type: 'string',
            description: 'ID of the rule to execute'
          },
          test_data: {
            type: 'object',
            description: 'Test data to simulate the trigger event'
          },
          dry_run: {
            type: 'boolean',
            default: false,
            description: 'If true, only simulate execution without performing actions'
          }
        },
        required: ['rule_id']
      }
    }
  • Export mapping tool names to their handler functions, registering execute_workflow_rule to executeWorkflowRule.
    export const workflowAutomationHandlers = {
      create_workflow_rule: createWorkflowRule,
      list_workflow_rules: listWorkflowRules,
      execute_workflow_rule: executeWorkflowRule,
      create_trigger_automation: createTriggerAutomation,
      get_automation_analytics: getAutomationAnalytics
    }
  • Helper function called by the handler to execute individual actions within a workflow rule, supporting dry_run and various action types.
    async function executeAction(action: any, testData: any, dryRun: boolean): Promise<any> {
      if (dryRun) {
        return { simulated: true, action_type: action.action_type, parameters: action.parameters }
      }
    
      switch (action.action_type) {
        case 'create_task':
          return await supabaseService.createTask({
            title: action.parameters.title,
            description: action.parameters.description,
            project_id: action.parameters.project_id || testData?.project_id,
            initiative_id: null,
            priority: action.parameters.priority || 'medium',
            assignee_id: action.parameters.assignee_id,
            status: 'todo',
            due_date: null
          })
    
        case 'update_task':
          return await supabaseService.updateTask(
            action.parameters.task_id || testData?.task_id,
            action.parameters.updates
          )
    
        case 'send_notification':
          // Would integrate with notification service
          return { 
            notification_sent: true, 
            recipient: action.parameters.recipient,
            message: action.parameters.message 
          }
    
        case 'assign_task':
          return await supabaseService.updateTask(
            action.parameters.task_id || testData?.task_id,
            { assignee_id: action.parameters.assignee_id }
          )
    
        case 'move_task':
          return await supabaseService.updateTask(
            action.parameters.task_id || testData?.task_id,
            { status: action.parameters.new_status }
          )
    
        case 'create_document':
          return await supabaseService.createDocument({
            title: action.parameters.title,
            content: action.parameters.content,
            project_id: action.parameters.project_id || testData?.project_id,
            document_type: action.parameters.document_type || 'note'
          })
    
        default:
          throw new Error(`Unknown action type: ${action.action_type}`)
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jakedx6/helios9-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server