start_workflow
Initiate a workflow execution with step-by-step control, enabling structured and customizable task management through the MCP workflow server.
Instructions
Start a workflow execution session with step-by-step control
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| inputs | No |
Implementation Reference
- src/index.ts:494-542 (handler)The primary handler function that executes the start_workflow tool. It retrieves the specified workflow, validates inputs, initializes a new execution session tracking variables and step progress, and generates instructions for the first workflow step.private async startWorkflow(args: unknown) { const parsed = StartWorkflowSchema.parse(args); const workflow = await this.storage.get(parsed.id); if (!workflow) { throw new Error(`Workflow not found: ${parsed.id}`); } if (workflow.is_deleted) { throw new Error('Cannot run deleted workflow'); } // Validate inputs const inputs = parsed.inputs || {}; const inputValidation = WorkflowValidator.validateInputs(workflow, inputs); if (!inputValidation.success) { throw new Error(`Input validation failed: ${inputValidation.error}`); } // Create new execution session const executionId = uuidv4(); const session: WorkflowSession = { workflow_id: workflow.id, execution_id: executionId, workflow_name: workflow.name, current_step_index: 0, total_steps: workflow.steps.length, variables: { ...inputs }, status: 'active', started_at: new Date().toISOString(), step_outputs: {}, previous_variables: {}, }; this.sessions.set(executionId, session); // Generate instructions for the first step const firstStep = workflow.steps[0]; const stepInstructions = this.generateStepInstructions(workflow, firstStep, session); return { content: [ { type: 'text', text: stepInstructions, }, ], }; }
- src/index.ts:65-68 (schema)Zod schema defining the input structure for the start_workflow tool: a required workflow ID string and optional inputs object.const StartWorkflowSchema = z.object({ id: z.string(), inputs: z.record(z.any()).optional(), });
- src/index.ts:277-281 (registration)Tool registration in the getTools() method, defining the name, description, and input schema for the MCP tool list.{ name: 'start_workflow', description: 'Start a workflow execution session with step-by-step control', inputSchema: zodToJsonSchema(StartWorkflowSchema), },
- src/index.ts:132-133 (registration)Dispatch registration in the CallToolRequestSchema handler switch statement, routing 'start_workflow' calls to the startWorkflow method.case 'start_workflow': return await this.startWorkflow(args);