Execute a Mistral workflow
workflow_executeStart a Mistral workflow execution with input, with option to wait for result or poll for status.
Instructions
Start a Mistral Workflow execution.
workflowIdentifier is the workflow name or ID (visible in mistral://workflows).
input is a free-form JSON object matching the workflow's input schema.
Modes:
waitForResult=false (default): returns immediately with execution_id and RUNNING status. Poll workflow_status to track completion.
waitForResult=true: blocks until the workflow finishes and returns the result inline. Use timeoutSeconds (default 30) to cap the wait.
Use deploymentName to target a specific deployment slot when multiple are configured.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflowIdentifier | Yes | Workflow name or ID. | |
| input | No | Input payload matching the workflow input schema. | |
| executionId | No | Optional custom execution ID. Auto-generated if omitted. | |
| waitForResult | No | Block until completion and return result inline. Default: false. | |
| timeoutSeconds | No | Max wait time when waitForResult=true. Default: 30. | |
| deploymentName | No | Target a specific deployment slot. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow_name | Yes | ||
| execution_id | Yes | ||
| sync | Yes | true when waitForResult=true (result is inline). | |
| status | No | ||
| result | No | ||
| root_execution_id | No | ||
| start_time | No | ||
| end_time | No | ||
| total_duration_ms | No |
Implementation Reference
- src/tools-workflows.ts:113-180 (handler)The async handler function for the workflow_execute tool. It calls mistral.workflows.executeWorkflow() with the provided input (workflowIdentifier, input, executionId, waitForResult, timeoutSeconds, deploymentName), then processes the response into a structured output distinguishing sync vs async execution modes.
async (input) => { try { const res = await mistral.workflows.executeWorkflow({ workflowIdentifier: input.workflowIdentifier, workflowExecutionRequest: { input: input.input ?? null, executionId: input.executionId, waitForResult: input.waitForResult ?? false, timeoutSeconds: input.timeoutSeconds, deploymentName: input.deploymentName, }, }); const sync = input.waitForResult === true; let structured: z.infer<typeof WorkflowExecuteOutputSchema>; if (sync && "result" in res && !("status" in res)) { // WorkflowExecutionSyncResponse const syncRes = res as { workflowName: string; executionId: string; result: unknown }; structured = { workflow_name: syncRes.workflowName, execution_id: syncRes.executionId, sync: true, result: syncRes.result, }; } else { // WorkflowExecutionResponse const asyncRes = res as { workflowName: string; executionId: string; rootExecutionId: string; status: string | null; startTime: Date; endTime: Date | null; result: unknown; totalDurationMs?: number | null; }; structured = { workflow_name: asyncRes.workflowName, execution_id: asyncRes.executionId, sync: false, status: asyncRes.status, result: asyncRes.result, root_execution_id: asyncRes.rootExecutionId, start_time: asyncRes.startTime instanceof Date ? asyncRes.startTime.toISOString() : String(asyncRes.startTime), end_time: asyncRes.endTime instanceof Date ? asyncRes.endTime.toISOString() : asyncRes.endTime ? String(asyncRes.endTime) : null, total_duration_ms: asyncRes.totalDurationMs ?? null, }; } const summary = sync ? `Workflow ${structured.workflow_name} completed (${structured.execution_id}).` : `Workflow ${structured.workflow_name} started as ${structured.execution_id} — status: ${structured.status}.`; return { content: [toTextBlock(summary)], structuredContent: structured, }; } catch (err) { return errorResult("workflow_execute", err); } } - src/tools-workflows.ts:61-181 (registration)Registration of the workflow_execute tool on the MCP server via server.registerTool(), including title, description, inputSchema with all parameters (workflowIdentifier, input, executionId, waitForResult, timeoutSeconds, deploymentName), outputSchema using WorkflowExecuteOutputShape, and annotations.
server.registerTool( "workflow_execute", { title: "Execute a Mistral workflow", description: [ "Start a Mistral Workflow execution.", "", "`workflowIdentifier` is the workflow name or ID (visible in mistral://workflows).", "`input` is a free-form JSON object matching the workflow's input schema.", "", "Modes:", " - waitForResult=false (default): returns immediately with execution_id and RUNNING status.", " Poll workflow_status to track completion.", " - waitForResult=true: blocks until the workflow finishes and returns the result inline.", " Use timeoutSeconds (default 30) to cap the wait.", "", "Use deploymentName to target a specific deployment slot when multiple are configured.", ].join("\n"), inputSchema: { workflowIdentifier: z.string().min(1).describe("Workflow name or ID."), input: z .record(z.string(), z.unknown()) .optional() .describe("Input payload matching the workflow input schema."), executionId: z .string() .optional() .describe("Optional custom execution ID. Auto-generated if omitted."), waitForResult: z .boolean() .optional() .describe("Block until completion and return result inline. Default: false."), timeoutSeconds: z .number() .int() .positive() .optional() .describe("Max wait time when waitForResult=true. Default: 30."), deploymentName: z .string() .optional() .describe("Target a specific deployment slot."), }, outputSchema: WorkflowExecuteOutputShape, annotations: { title: "Execute Mistral workflow", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true, }, }, async (input) => { try { const res = await mistral.workflows.executeWorkflow({ workflowIdentifier: input.workflowIdentifier, workflowExecutionRequest: { input: input.input ?? null, executionId: input.executionId, waitForResult: input.waitForResult ?? false, timeoutSeconds: input.timeoutSeconds, deploymentName: input.deploymentName, }, }); const sync = input.waitForResult === true; let structured: z.infer<typeof WorkflowExecuteOutputSchema>; if (sync && "result" in res && !("status" in res)) { // WorkflowExecutionSyncResponse const syncRes = res as { workflowName: string; executionId: string; result: unknown }; structured = { workflow_name: syncRes.workflowName, execution_id: syncRes.executionId, sync: true, result: syncRes.result, }; } else { // WorkflowExecutionResponse const asyncRes = res as { workflowName: string; executionId: string; rootExecutionId: string; status: string | null; startTime: Date; endTime: Date | null; result: unknown; totalDurationMs?: number | null; }; structured = { workflow_name: asyncRes.workflowName, execution_id: asyncRes.executionId, sync: false, status: asyncRes.status, result: asyncRes.result, root_execution_id: asyncRes.rootExecutionId, start_time: asyncRes.startTime instanceof Date ? asyncRes.startTime.toISOString() : String(asyncRes.startTime), end_time: asyncRes.endTime instanceof Date ? asyncRes.endTime.toISOString() : asyncRes.endTime ? String(asyncRes.endTime) : null, total_duration_ms: asyncRes.totalDurationMs ?? null, }; } const summary = sync ? `Workflow ${structured.workflow_name} completed (${structured.execution_id}).` : `Workflow ${structured.workflow_name} started as ${structured.execution_id} — status: ${structured.status}.`; return { content: [toTextBlock(summary)], structuredContent: structured, }; } catch (err) { return errorResult("workflow_execute", err); } } ); - src/tools-workflows.ts:22-33 (schema)Output schema (WorkflowExecuteOutputShape and WorkflowExecuteOutputSchema) defining the shape of the response: workflow_name, execution_id, sync, status, result, root_execution_id, start_time, end_time, total_duration_ms.
export const WorkflowExecuteOutputShape = { workflow_name: z.string(), execution_id: z.string(), sync: z.boolean().describe("true when waitForResult=true (result is inline)."), status: z.string().nullable().optional(), result: z.unknown().nullable().optional(), root_execution_id: z.string().optional(), start_time: z.string().optional(), end_time: z.string().nullable().optional(), total_duration_ms: z.number().nullable().optional(), }; export const WorkflowExecuteOutputSchema = z.object(WorkflowExecuteOutputShape); - src/shared.ts:97-103 (handler)Helper function errorResult used by the workflow_execute handler to format error responses (line 178 in tools-workflows.ts).
export function errorResult(tool: string, err: unknown) { const message = err instanceof Error ? err.message : String(err); return { content: [toTextBlock(`[mistral-mcp:${tool}] ${message}`)], isError: true as const, }; } - src/index.ts:82-83 (registration)Top-level invocation where registerWorkflowTools is called in the main server setup, making workflow_execute available in every profile.
// workflow tools are present in every profile registerWorkflowTools(server, mistral);