Configuration parameters for the step
Unique identifier for the step
Optional description of what the step does
Zod schema defining the input structure
Zod schema defining the output structure
Function that performs the step's operations
A Step object that can be added to the workflow
import { createStep } from '@mastra/core/workflows';
import { z } from 'zod';
const greet = createStep({
id: 'greet',
inputSchema: z.string(),
outputSchema: z.string(),
execute: async ({ inputData }) => `Hello, ${inputData}!`,
});
@mastra/core/package.json with your project's resolver or package-manager
tooling, then read dist/docs/SKILL.md from that package root and follow its
reference links. Use package-manager tools for virtual or archived packages.Creates a step from an agent (defaults to { text: string } output)
OptionalagentOptions: Omit<AgentStepOptions<{}>, "structuredOutput"> & {}Creates a step from an agent with structured output
Creates a step from a tool
OptionaltoolOptions: {}Creates a workflow step from a configured Classifier.
Optionaloptions: ClassifierStepOptions<TStepInput>Creates a step from a Processor - wraps a Processor as a workflow step Note: We require at least one processor method to distinguish from StepParams
IMPORTANT: Fallback overload - provides better error messages when StepParams doesn't match This should be LAST and will show clearer errors about what's wrong This is a copy of first one, KEEP THIS IN SYNC!
Creates a workflow for composing typed steps. Declaring a schedule
registers cron fires with the Mastra scheduler. It also switches the
workflow to the evented engine, but only when the MASTRA_WORKERS
environment variable is set (split-worker deployments); otherwise the
engine does not change.
yourStep is a configured step with string input and output.
import { createWorkflow } from '@mastra/core/workflows';
import { z } from 'zod';
const workflow = createWorkflow({
id: 'greeting',
inputSchema: z.string(),
outputSchema: z.string(),
}).then(yourStep).commit();
@mastra/core/package.json with your project's resolver or package-manager
tooling, then read dist/docs/SKILL.md from that package root and follow its
reference links. Use package-manager tools for virtual or archived packages.OptionalexecutionThe deployment execution fence, or undefined for an explicitly unfenced
host. THE accessor for it, for the same reason as pubsub: a route that
built its own store could be gating a different database than the runtime
it sits in front of. Thread-DO signal routes read it off scope.init.
OptionalpubsubThe host pubsub identity, or undefined when unconfigured. THE accessor for it: consumers take the identity from here instead of constructing their own, which is what keeps it single per DO.
OptionalstartThe deployment's start reservations, or undefined for a { storage } host
with no database to reserve against. THE accessor for it, for the same
reason as executionFence: a surface that built its own store could be
reserving into a different database than the runtime that settles.
Creates a step from explicit params (IMPORTANT: FIRST overload for best error messages when using .then in workflows)