create_workflow_rule
Automate project management by creating rules that trigger actions based on 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 primary handler function for the 'create_workflow_rule' MCP tool. It validates input using Zod, logs the operation, 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 validation schema used in the handler to parse and validate the input arguments for creating a workflow rule.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 object defining the 'create_workflow_rule' tool, including its name, description, and JSON input schema mirroring the Zod schema.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)Export of handlers map where the 'create_workflow_rule' handler function is registered under its tool name, likely used for MCP tool dispatching.export const workflowAutomationHandlers = { create_workflow_rule: createWorkflowRule, list_workflow_rules: listWorkflowRules, execute_workflow_rule: executeWorkflowRule, create_trigger_automation: createTriggerAutomation, get_automation_analytics: getAutomationAnalytics }