create_workflow_rule
Automate project management by creating rules that trigger actions based on specific events like task changes or document updates.
Instructions
Create an automation rule that triggers actions based on events
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the automation rule | |
| description | No | Description of what this rule does | |
| trigger | Yes | ||
| actions | Yes | Actions to perform when rule is triggered | |
| project_id | No | Project this rule applies to (optional for global rules) | |
| enabled | No | Whether this rule is active |
Implementation Reference
- src/tools/workflow-automation.ts:92-111 (handler)The core handler function for the 'create_workflow_rule' tool. It validates input using Zod schema, logs the action, delegates to supabaseService.createWorkflowRule (a placeholder implementation), and returns the created rule with a success message.export const createWorkflowRule = requireAuth(async (args: any) => { const { name, description, trigger, actions, project_id, enabled } = CreateWorkflowRuleSchema.parse(args) logger.info('Creating workflow rule', { name, trigger: trigger.event_type, actions: actions.length }) const rule = await supabaseService.createWorkflowRule({ name, description, trigger, actions, project_id, enabled, created_at: new Date().toISOString() }) return { rule, message: `Workflow rule "${name}" created successfully` } })
- Zod schema used for input validation in the createWorkflowRule handler, defining structure for name, description, trigger, actions, project_id, and enabled.const CreateWorkflowRuleSchema = z.object({ name: z.string().min(1).max(200), description: z.string().optional(), trigger: z.object({ event_type: z.enum(['task_status_changed', 'task_created', 'task_overdue', 'project_status_changed', 'document_created', 'document_updated']), conditions: z.record(z.any()).optional() }), actions: z.array(z.object({ action_type: z.enum(['create_task', 'update_task', 'send_notification', 'assign_task', 'move_task', 'create_document']), parameters: z.record(z.any()) })).min(1), project_id: z.string().optional(), enabled: z.boolean().default(true) })
- src/tools/workflow-automation.ts:15-75 (registration)MCPTool registration for 'create_workflow_rule', including the tool name, description, and detailed JSON inputSchema defining expected parameters.export const createWorkflowRuleTool: MCPTool = { name: 'create_workflow_rule', description: 'Create an automation rule that triggers actions based on events', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the automation rule' }, description: { type: 'string', description: 'Description of what this rule does' }, trigger: { type: 'object', properties: { event_type: { type: 'string', enum: ['task_status_changed', 'task_created', 'task_overdue', 'project_status_changed', 'document_created', 'document_updated'], description: 'Type of event that triggers this rule' }, conditions: { type: 'object', description: 'Conditions that must be met for trigger to fire' } }, required: ['event_type'] }, actions: { type: 'array', items: { type: 'object', properties: { action_type: { type: 'string', enum: ['create_task', 'update_task', 'send_notification', 'assign_task', 'move_task', 'create_document'], description: 'Type of action to perform' }, parameters: { type: 'object', description: 'Parameters for the action' } }, required: ['action_type', 'parameters'] }, description: 'Actions to perform when rule is triggered' }, project_id: { type: 'string', description: 'Project this rule applies to (optional for global rules)' }, enabled: { type: 'boolean', default: true, description: 'Whether this rule is active' } }, required: ['name', 'trigger', 'actions'] } }
- src/tools/workflow-automation.ts:602-608 (registration)Registration of the createWorkflowRule handler in the workflowAutomationHandlers object, mapping tool name to handler function.export const workflowAutomationHandlers = { create_workflow_rule: createWorkflowRule, list_workflow_rules: listWorkflowRules, execute_workflow_rule: executeWorkflowRule, create_trigger_automation: createTriggerAutomation, get_automation_analytics: getAutomationAnalytics }
- src/tools/workflow-automation.ts:594-601 (registration)Export of workflowAutomationTools object including createWorkflowRuleTool for overall tool registration.export const workflowAutomationTools = { createWorkflowRuleTool, listWorkflowRulesTool, executeWorkflowRuleTool, createTriggerAutomationTool, getAutomationAnalyticsTool }