Skip to main content
Glama
jakedx6
by jakedx6

execute_workflow_rule

Manually execute a workflow rule for testing by providing rule ID and test data, with optional dry-run simulation.

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

  • Main handler function that executes the workflow rule: validates input, fetches rule, loops through actions executing them (using helper), collects results, logs execution if not dry-run, returns summary.
    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 for input validation: rule_id (required), test_data (optional object), dry_run (boolean, default false).
    const ExecuteWorkflowRuleSchema = z.object({ rule_id: z.string().min(1), test_data: z.record(z.any()).optional(), dry_run: z.boolean().default(false) })
  • MCPTool registration object defining name, description, and inputSchema for the tool.
    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'] } }
  • Handler map registration including execute_workflow_rule mapped to executeWorkflowRule function.
    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 handler to execute individual actions based on action_type, supports dry_run simulation.
    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