@mastra/mcp-docs-server 0.13.38 → 0.13.39-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Freact.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +11 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
- package/.docs/organized/changelogs/create-mastra.md +7 -7
- package/.docs/organized/changelogs/mastra.md +18 -18
- package/.docs/raw/agents/overview.mdx +2 -2
- package/.docs/raw/auth/jwt.mdx +2 -2
- package/.docs/raw/auth/supabase.mdx +2 -2
- package/.docs/raw/auth/workos.mdx +2 -2
- package/.docs/raw/course/02-agent-tools-mcp/04-initializing-mcp-tools.md +2 -2
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +24 -8
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +1 -1
- package/.docs/raw/frameworks/servers/express.mdx +1 -1
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +34 -18
- package/.docs/raw/getting-started/installation.mdx +7 -7
- package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
- package/.docs/raw/getting-started/studio.mdx +27 -17
- package/.docs/raw/getting-started/templates.mdx +12 -4
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/mastra-cloud/dashboard.mdx +6 -6
- package/.docs/raw/mastra-cloud/observability.mdx +2 -2
- package/.docs/raw/mastra-cloud/overview.mdx +1 -1
- package/.docs/raw/mastra-cloud/setting-up.mdx +1 -1
- package/.docs/raw/memory/overview.mdx +1 -1
- package/.docs/raw/memory/semantic-recall.mdx +2 -4
- package/.docs/raw/memory/threads-and-resources.mdx +1 -1
- package/.docs/raw/memory/working-memory.mdx +1 -1
- package/.docs/raw/observability/ai-tracing/exporters/default.mdx +6 -6
- package/.docs/raw/observability/ai-tracing/overview.mdx +7 -7
- package/.docs/raw/observability/overview.mdx +1 -1
- package/.docs/raw/reference/agents/agent.mdx +2 -2
- package/.docs/raw/reference/agents/listScorers.mdx +69 -0
- package/.docs/raw/reference/agents/listTools.mdx +69 -0
- package/.docs/raw/reference/agents/listWorkflows.mdx +69 -0
- package/.docs/raw/reference/cli/mastra.mdx +1 -1
- package/.docs/raw/reference/client-js/agents.mdx +1 -1
- package/.docs/raw/reference/client-js/logs.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
- package/.docs/raw/reference/client-js/memory.mdx +1 -1
- package/.docs/raw/reference/client-js/tools.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +1 -1
- package/.docs/raw/reference/core/getScorerByName.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.mdx +35 -0
- package/.docs/raw/reference/core/listLogs.mdx +96 -0
- package/.docs/raw/reference/core/listLogsByRunId.mdx +87 -0
- package/.docs/raw/reference/core/listScorers.mdx +43 -0
- package/.docs/raw/reference/core/listWorkflows.mdx +45 -0
- package/.docs/raw/reference/memory/memory-class.mdx +2 -1
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -1
- package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +10 -14
- package/.docs/raw/reference/processors/language-detector.mdx +20 -32
- package/.docs/raw/reference/processors/moderation-processor.mdx +46 -30
- package/.docs/raw/reference/processors/pii-detector.mdx +47 -32
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +20 -30
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +24 -29
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +14 -23
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +12 -14
- package/.docs/raw/reference/rag/document.mdx +1 -1
- package/.docs/raw/reference/scorers/run-experiment.mdx +1 -1
- package/.docs/raw/reference/storage/mssql.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +1 -1
- package/.docs/raw/reference/tools/mcp-client.mdx +8 -8
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/workflows/step.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +72 -2
- package/.docs/raw/reference/workflows/workflow.mdx +0 -14
- package/.docs/raw/scorers/overview.mdx +5 -5
- package/.docs/raw/server-db/middleware.mdx +4 -4
- package/.docs/raw/tools-mcp/overview.mdx +2 -2
- package/.docs/raw/workflows/agents-and-tools.mdx +2 -6
- package/.docs/raw/workflows/control-flow.mdx +208 -165
- package/.docs/raw/workflows/inngest-workflow.mdx +2 -2
- package/.docs/raw/workflows/overview.mdx +106 -54
- package/.docs/raw/workflows/suspend-and-resume.mdx +1 -9
- package/CHANGELOG.md +10 -0
- package/package.json +4 -4
- package/.docs/raw/workflows/input-data-mapping.mdx +0 -107
|
@@ -16,7 +16,7 @@ Workflows let you define complex sequences of tasks using clear, structured step
|
|
|
16
16
|
|
|
17
17
|
Use workflows for tasks that are clearly defined upfront and involve multiple steps with a specific execution order. They give you fine-grained control over how data flows and transforms between steps, and which primitives are called at each stage.
|
|
18
18
|
|
|
19
|
-
> **📹 Watch**:
|
|
19
|
+
> **📹 Watch**: → An introduction to workflows, and how they compare to agents [YouTube (7 minutes)](https://youtu.be/0jg2g3sNvgw)
|
|
20
20
|
|
|
21
21
|
## Core principles
|
|
22
22
|
|
|
@@ -38,18 +38,18 @@ import { createStep } from "@mastra/core/workflows";
|
|
|
38
38
|
const step1 = createStep({
|
|
39
39
|
id: "step-1",
|
|
40
40
|
inputSchema: z.object({
|
|
41
|
-
message: z.string()
|
|
41
|
+
message: z.string()
|
|
42
42
|
}),
|
|
43
43
|
outputSchema: z.object({
|
|
44
|
-
formatted: z.string()
|
|
44
|
+
formatted: z.string()
|
|
45
45
|
}),
|
|
46
46
|
execute: async ({ inputData }) => {
|
|
47
47
|
const { message } = inputData;
|
|
48
48
|
|
|
49
49
|
return {
|
|
50
|
-
formatted: message.toUpperCase()
|
|
50
|
+
formatted: message.toUpperCase()
|
|
51
51
|
};
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ const step1 = createStep({
|
|
|
57
57
|
|
|
58
58
|
### Using agents and tools
|
|
59
59
|
|
|
60
|
-
Workflow steps can also call registered agents or import and execute tools directly, visit the [
|
|
60
|
+
Workflow steps can also call registered agents or import and execute tools directly, visit the [Using Tools](/docs/agents/using-tools) page for more information.
|
|
61
61
|
|
|
62
62
|
## Creating a workflow
|
|
63
63
|
|
|
@@ -80,55 +80,123 @@ export const testWorkflow = createWorkflow({
|
|
|
80
80
|
})
|
|
81
81
|
.then(step1)
|
|
82
82
|
.commit();
|
|
83
|
-
|
|
84
83
|
```
|
|
85
84
|
|
|
86
85
|
> See the [Workflow Class](/reference/workflows/workflow) for a full list of configuration options.
|
|
87
86
|
|
|
88
87
|
### Understanding control flow
|
|
89
88
|
|
|
90
|
-
Workflows can be composed using a number of different methods. The method you choose determines how each step's schema should be structured. Visit the [Control Flow](
|
|
89
|
+
Workflows can be composed using a number of different methods. The method you choose determines how each step's schema should be structured. Visit the [Control Flow](/docs/workflows/control-flow) page for more information.
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
## Workflow state
|
|
93
92
|
|
|
94
|
-
|
|
93
|
+
Workflow state lets you share values across steps without passing them through every step’s inputSchema and outputSchema. All state values are defined in the workflow’s stateSchema, but each step only declares the values it needs. To set initial values, use initialState when running the workflow.
|
|
95
94
|
|
|
96
|
-
```typescript
|
|
95
|
+
```typescript title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
97
96
|
const step1 = createStep({
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
outputSchema: z.object({
|
|
103
|
-
formatted: z.string(),
|
|
97
|
+
// ...
|
|
98
|
+
stateSchema: z.object({
|
|
99
|
+
processedItems: z.array(z.string()),
|
|
104
100
|
}),
|
|
101
|
+
execute: async ({ inputData, state, setState }) => {
|
|
102
|
+
const { message } = inputData;
|
|
103
|
+
const { processedItems } = state;
|
|
104
|
+
|
|
105
|
+
setState({
|
|
106
|
+
...state,
|
|
107
|
+
processedItems: [...processedItems, "item-1", "item-2"],
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
formatted: message.toUpperCase(),
|
|
112
|
+
};
|
|
113
|
+
},
|
|
105
114
|
});
|
|
106
115
|
|
|
107
116
|
const step2 = createStep({
|
|
108
117
|
// ...
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
emphasized: z.string(),
|
|
118
|
+
stateSchema: z.object({
|
|
119
|
+
metadata: z.object({
|
|
120
|
+
processedBy: z.string(),
|
|
121
|
+
}),
|
|
114
122
|
}),
|
|
123
|
+
execute: async ({ inputData, state }) => {
|
|
124
|
+
const { formatted } = inputData;
|
|
125
|
+
const { metadata } = state;
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
emphasized: `${formatted}!! ${metadata.processedBy}`,
|
|
129
|
+
};
|
|
130
|
+
},
|
|
115
131
|
});
|
|
116
132
|
|
|
117
133
|
export const testWorkflow = createWorkflow({
|
|
118
134
|
// ...
|
|
135
|
+
stateSchema: z.object({
|
|
136
|
+
processedItems: z.array(z.string()),
|
|
137
|
+
metadata: z.object({
|
|
138
|
+
processedBy: z.string(),
|
|
139
|
+
}),
|
|
140
|
+
}),
|
|
141
|
+
})
|
|
142
|
+
.then(step1)
|
|
143
|
+
.then(step2)
|
|
144
|
+
.commit();
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Workflows as steps
|
|
148
|
+
|
|
149
|
+
Use a workflow as a step to reuse its logic within a larger composition. Input and output follow the same schema rules described in [Core principles](/docs/workflows/control-flow).
|
|
150
|
+
|
|
151
|
+
```typescript {26} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
152
|
+
const step1 = createStep({...});
|
|
153
|
+
const step2 = createStep({...});
|
|
154
|
+
|
|
155
|
+
const childWorkflow = createWorkflow({
|
|
156
|
+
id: "child-workflow",
|
|
119
157
|
inputSchema: z.object({
|
|
120
|
-
message: z.string()
|
|
158
|
+
message: z.string()
|
|
121
159
|
}),
|
|
122
160
|
outputSchema: z.object({
|
|
123
|
-
emphasized: z.string()
|
|
124
|
-
})
|
|
161
|
+
emphasized: z.string()
|
|
162
|
+
})
|
|
125
163
|
})
|
|
126
164
|
.then(step1)
|
|
127
165
|
.then(step2)
|
|
128
166
|
.commit();
|
|
167
|
+
|
|
168
|
+
export const testWorkflow = createWorkflow({
|
|
169
|
+
id: "test-workflow",
|
|
170
|
+
inputSchema: z.object({
|
|
171
|
+
message: z.string()
|
|
172
|
+
}),
|
|
173
|
+
outputSchema: z.object({
|
|
174
|
+
emphasized: z.string()
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
.then(childWorkflow)
|
|
178
|
+
.commit();
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Cloning a workflow
|
|
182
|
+
|
|
183
|
+
Clone a workflow using `cloneWorkflow()` when you want to reuse its logic but track it separately under a new ID. Each clone runs independently and appears as a distinct workflow in logs and observability tools.
|
|
184
|
+
|
|
185
|
+
```typescript {6} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
186
|
+
import { cloneWorkflow } from "@mastra/core/workflows";
|
|
187
|
+
|
|
188
|
+
const step1 = createStep({...});
|
|
189
|
+
|
|
190
|
+
const parentWorkflow = createWorkflow({...})
|
|
191
|
+
const clonedWorkflow = cloneWorkflow(parentWorkflow, { id: "cloned-workflow" });
|
|
192
|
+
|
|
193
|
+
export const testWorkflow = createWorkflow({...})
|
|
194
|
+
.then(step1)
|
|
195
|
+
.then(clonedWorkflow)
|
|
196
|
+
.commit();
|
|
129
197
|
```
|
|
130
198
|
|
|
131
|
-
|
|
199
|
+
## Registering a workflow
|
|
132
200
|
|
|
133
201
|
Register your workflow in the Mastra instance to make it available throughout your application. Once registered, it can be called from agents or tools and has access to shared resources such as logging and observability features:
|
|
134
202
|
|
|
@@ -149,22 +217,16 @@ You can run workflows from agents, tools, the Mastra Client, or the command line
|
|
|
149
217
|
```typescript showLineNumbers copy
|
|
150
218
|
const testWorkflow = mastra.getWorkflow("testWorkflow");
|
|
151
219
|
```
|
|
152
|
-
|
|
153
220
|
:::info
|
|
154
|
-
|
|
155
221
|
`mastra.getWorkflow()` is preferred over a direct import, since it provides access to the Mastra instance configuration (logger, telemetry, storage, registered agents, and vector stores).
|
|
156
|
-
|
|
157
222
|
:::
|
|
158
223
|
|
|
159
|
-
> See [Running Workflows](/examples/workflows_legacy/creating-a-workflow) for more information.
|
|
160
|
-
|
|
161
224
|
## Running workflows
|
|
162
225
|
|
|
163
226
|
Workflows can be run in two modes: start waits for all steps to complete before returning, and stream emits events during execution. Choose the approach that fits your use case: start when you only need the final result, and stream when you want to monitor progress or trigger actions as steps complete.
|
|
164
227
|
|
|
165
228
|
<Tabs>
|
|
166
229
|
<TabItem value="start" label="Start">
|
|
167
|
-
|
|
168
230
|
Create a workflow run instance using `createRunAsync()`, then call `.start()` with `inputData` matching the workflow's `inputSchema`. The workflow executes all steps and returns the final result.
|
|
169
231
|
|
|
170
232
|
```typescript showLineNumbers copy
|
|
@@ -172,16 +234,14 @@ const run = await testWorkflow.createRunAsync();
|
|
|
172
234
|
|
|
173
235
|
const result = await run.start({
|
|
174
236
|
inputData: {
|
|
175
|
-
message: "Hello world"
|
|
176
|
-
}
|
|
237
|
+
message: "Hello world"
|
|
238
|
+
}
|
|
177
239
|
});
|
|
178
240
|
|
|
179
241
|
console.log(result);
|
|
180
242
|
```
|
|
181
|
-
|
|
182
243
|
</TabItem>
|
|
183
244
|
<TabItem value="stream" label="Stream">
|
|
184
|
-
|
|
185
245
|
Create a workflow run instance using `.createRunAsync()`, then call `.stream()` with `inputData` matching the workflow's `inputSchema`. The workflow emits events as each step executes, which you can iterate over to track progress.
|
|
186
246
|
|
|
187
247
|
```typescript showLineNumbers copy
|
|
@@ -189,15 +249,14 @@ const run = await testWorkflow.createRunAsync();
|
|
|
189
249
|
|
|
190
250
|
const result = await run.stream({
|
|
191
251
|
inputData: {
|
|
192
|
-
message: "Hello world"
|
|
193
|
-
}
|
|
252
|
+
message: "Hello world"
|
|
253
|
+
}
|
|
194
254
|
});
|
|
195
255
|
|
|
196
256
|
for await (const chunk of result.stream) {
|
|
197
257
|
console.log(chunk);
|
|
198
258
|
}
|
|
199
259
|
```
|
|
200
|
-
|
|
201
260
|
</TabItem>
|
|
202
261
|
</Tabs>
|
|
203
262
|
|
|
@@ -217,7 +276,7 @@ The workflow output includes the full execution lifecycle, showing the input and
|
|
|
217
276
|
},
|
|
218
277
|
"output": {
|
|
219
278
|
"formatted": "HELLO WORLD"
|
|
220
|
-
}
|
|
279
|
+
},
|
|
221
280
|
},
|
|
222
281
|
"step-2": {
|
|
223
282
|
"status": "success",
|
|
@@ -226,7 +285,7 @@ The workflow output includes the full execution lifecycle, showing the input and
|
|
|
226
285
|
},
|
|
227
286
|
"output": {
|
|
228
287
|
"emphasized": "HELLO WORLD!!!"
|
|
229
|
-
}
|
|
288
|
+
},
|
|
230
289
|
}
|
|
231
290
|
},
|
|
232
291
|
"input": {
|
|
@@ -252,28 +311,21 @@ const step1 = createStep({
|
|
|
252
311
|
execute: async ({ runtimeContext }) => {
|
|
253
312
|
const userTier = runtimeContext.get("user-tier") as UserTier["user-tier"];
|
|
254
313
|
|
|
255
|
-
const maxResults = userTier === "enterprise"
|
|
314
|
+
const maxResults = userTier === "enterprise"
|
|
315
|
+
? 1000
|
|
316
|
+
: 50;
|
|
256
317
|
|
|
257
318
|
return { maxResults };
|
|
258
|
-
}
|
|
319
|
+
}
|
|
259
320
|
});
|
|
260
321
|
```
|
|
261
322
|
|
|
262
323
|
> See [Runtime Context](/docs/server-db/runtime-context) for more information.
|
|
263
324
|
|
|
264
|
-
## Testing with
|
|
325
|
+
## Testing with Studio
|
|
265
326
|
|
|
266
|
-
Use
|
|
327
|
+
Use [Studio](/docs/getting-started/studio) to easily run workflows with different inputs, visualize the execution lifecycle, see the inputs and outputs for each step, and inspect each part of the workflow in more detail.
|
|
267
328
|
|
|
268
329
|
## Related
|
|
269
330
|
|
|
270
331
|
For a closer look at workflows, see our [Workflow Guide](/guides/guide/ai-recruiter), which walks through the core concepts with a practical example.
|
|
271
|
-
|
|
272
|
-
- [Parallel Steps workflow example](/examples/workflows_legacy/parallel-steps)
|
|
273
|
-
- [Conditional Branching workflow example](/examples/workflows_legacy/conditional-branching)
|
|
274
|
-
- [Inngest workflow example](/examples/workflows/inngest-workflow)
|
|
275
|
-
- [Suspend and Resume workflow example](/examples/workflows_legacy/human-in-the-loop)
|
|
276
|
-
|
|
277
|
-
## Workflows (Legacy)
|
|
278
|
-
|
|
279
|
-
For legacy workflow documentation, see [Workflows (Legacy)](../workflows-legacy/overview).
|
|
@@ -5,15 +5,7 @@ description: "Suspend and resume in Mastra workflows allows you to pause executi
|
|
|
5
5
|
|
|
6
6
|
# Suspend & Resume
|
|
7
7
|
|
|
8
|
-
Workflows can be paused at any step,
|
|
9
|
-
|
|
10
|
-
Common scenarios for suspending workflows include:
|
|
11
|
-
|
|
12
|
-
- Waiting for human approval or input
|
|
13
|
-
- Pausing until external API resources become available
|
|
14
|
-
- Collecting additional data needed for later steps
|
|
15
|
-
- Rate limiting or throttling expensive operations
|
|
16
|
-
- Handling event-driven processes with external triggers
|
|
8
|
+
Workflows can be paused at any step to collect additional data, wait for API callbacks, throttle expensive operations, or wait for [Human in the Loop](./human-in-the-loop) input. When a workflow is suspended, its current state can be persisted as a [snapshot](./snapshots) and later resumed from the same point. Snapshots are stored in the configured storage system and persist across deployments and application restarts.
|
|
17
9
|
|
|
18
10
|
> **New to suspend and resume?** Watch these official video tutorials:
|
|
19
11
|
>
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 0.13.39-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc), [`6d7e90d`](https://github.com/mastra-ai/mastra/commit/6d7e90db09713e6250f4d6c3d3cff1b4740e50f9), [`f78b908`](https://github.com/mastra-ai/mastra/commit/f78b9080e11af765969b36b4a619761056030840), [`23c2614`](https://github.com/mastra-ai/mastra/commit/23c26140fdbf04b8c59e8d7d52106d67dad962ec), [`e365eda`](https://github.com/mastra-ai/mastra/commit/e365eda45795b43707310531cac1e2ce4e5a0712)]:
|
|
10
|
+
- @mastra/mcp@0.14.2-alpha.0
|
|
11
|
+
- @mastra/core@0.24.0-alpha.0
|
|
12
|
+
|
|
3
13
|
## 0.13.38
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.39-alpha.0",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"uuid": "^11.1.0",
|
|
34
34
|
"zod": "^3.25.76",
|
|
35
35
|
"zod-to-json-schema": "^3.24.6",
|
|
36
|
-
"@mastra/
|
|
37
|
-
"@mastra/
|
|
36
|
+
"@mastra/core": "0.24.0-alpha.0",
|
|
37
|
+
"@mastra/mcp": "^0.14.2-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@hono/node-server": "^1.19.5",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
51
|
"vitest": "^3.2.4",
|
|
52
52
|
"@internal/lint": "0.0.57",
|
|
53
|
-
"@mastra/core": "0.
|
|
53
|
+
"@mastra/core": "0.24.0-alpha.0"
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://mastra.ai",
|
|
56
56
|
"repository": {
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Input Data Mapping | Workflows | Mastra Docs"
|
|
3
|
-
description: "Learn how to use workflow input mapping to create more dynamic data flows in your Mastra workflows."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Input Data Mapping
|
|
7
|
-
|
|
8
|
-
Input data mapping allows explicit mapping of values for the inputs of the next step. These values can come from a number of sources:
|
|
9
|
-
|
|
10
|
-
- The outputs of a previous step
|
|
11
|
-
- The runtime context
|
|
12
|
-
- A constant value
|
|
13
|
-
- The initial input of the workflow
|
|
14
|
-
|
|
15
|
-
## Mapping with `.map()`
|
|
16
|
-
|
|
17
|
-
In this example the `output` from `step1` is transformed to match the `inputSchema` required for the `step2`. The value from `step1` is available using the `inputData` parameter of the `.map` function.
|
|
18
|
-
|
|
19
|
-

|
|
20
|
-
|
|
21
|
-
```typescript {9} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
22
|
-
const step1 = createStep({...});
|
|
23
|
-
const step2 = createStep({...});
|
|
24
|
-
|
|
25
|
-
export const testWorkflow = createWorkflow({...})
|
|
26
|
-
.then(step1)
|
|
27
|
-
.map(async ({ inputData }) => {
|
|
28
|
-
const { value } = inputData;
|
|
29
|
-
return {
|
|
30
|
-
output: `new ${value}`
|
|
31
|
-
};
|
|
32
|
-
})
|
|
33
|
-
.then(step2)
|
|
34
|
-
.commit();
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Using `inputData`
|
|
38
|
-
|
|
39
|
-
Use `inputData` to access the full output of the previous step:
|
|
40
|
-
|
|
41
|
-
```typescript {3} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
42
|
-
.then(step1)
|
|
43
|
-
.map(({ inputData }) => {
|
|
44
|
-
console.log(inputData);
|
|
45
|
-
})
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Using `getStepResult()`
|
|
49
|
-
|
|
50
|
-
Use `getStepResult` to access the full output of a specific step by referencing the step's instance:
|
|
51
|
-
|
|
52
|
-
```typescript {3} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
53
|
-
.then(step1)
|
|
54
|
-
.map(async ({ getStepResult }) => {
|
|
55
|
-
console.log(getStepResult(step1));
|
|
56
|
-
})
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Using `getInitData()`
|
|
60
|
-
|
|
61
|
-
Use `getInitData` to access the initial input data provided to the workflow:
|
|
62
|
-
|
|
63
|
-
```typescript {3} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
64
|
-
.then(step1)
|
|
65
|
-
.map(async ({ getInitData }) => {
|
|
66
|
-
console.log(getInitData());
|
|
67
|
-
})
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Using `mapVariable()`
|
|
71
|
-
|
|
72
|
-
To use `mapVariable` import the necessary function from the workflows module:
|
|
73
|
-
|
|
74
|
-
```typescript title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
75
|
-
import { mapVariable } from "@mastra/core/workflows";
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Renaming step with `mapVariable()`
|
|
79
|
-
|
|
80
|
-
You can rename step outputs using the object syntax in `.map()`. In the example below, the `value` output from `step1` is renamed to `details`:
|
|
81
|
-
|
|
82
|
-
```typescript {3-6} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
83
|
-
.then(step1)
|
|
84
|
-
.map({
|
|
85
|
-
details: mapVariable({
|
|
86
|
-
step: step,
|
|
87
|
-
path: "value"
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Renaming workflows with `mapVariable()`
|
|
93
|
-
|
|
94
|
-
You can rename workflow outputs by using **referential composition**. This involves passing the workflow instance as the `initData`.
|
|
95
|
-
|
|
96
|
-
```typescript {6-9} title="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
97
|
-
export const testWorkflow = createWorkflow({...});
|
|
98
|
-
|
|
99
|
-
testWorkflow
|
|
100
|
-
.then(step1)
|
|
101
|
-
.map({
|
|
102
|
-
details: mapVariable({
|
|
103
|
-
initData: testWorkflow,
|
|
104
|
-
path: "value"
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
```
|