@mastra/mcp-docs-server 0.13.30 → 0.13.31
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/%40internal%2Fchangeset-cli.md +4 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +15 -15
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +4 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +48 -6
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +120 -120
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Flance.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Frag.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Freact.md +41 -0
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +16 -16
- package/.docs/organized/changelogs/create-mastra.md +41 -41
- package/.docs/organized/changelogs/mastra.md +73 -73
- package/.docs/organized/code-examples/heads-up-game.md +5 -5
- package/.docs/raw/agents/agent-memory.mdx +1 -1
- package/.docs/raw/agents/networks.mdx +0 -2
- package/.docs/raw/agents/overview.mdx +71 -38
- package/.docs/raw/agents/using-tools.mdx +1 -1
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +284 -266
- package/.docs/raw/reference/agents/generate.mdx +13 -5
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/getMemory.mdx +1 -1
- package/.docs/raw/reference/agents/getModel.mdx +1 -1
- package/.docs/raw/reference/agents/getScorers.mdx +1 -1
- package/.docs/raw/reference/cli/create-mastra.mdx +16 -0
- package/.docs/raw/reference/cli/mastra.mdx +7 -1
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -2
- package/.docs/raw/reference/streaming/agents/stream.mdx +18 -10
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +2 -2
- package/.docs/raw/reference/tools/create-tool.mdx +1 -1
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +2 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +2 -2
- package/.docs/raw/reference/vectors/pg.mdx +83 -2
- package/.docs/raw/server-db/runtime-context.mdx +4 -2
- package/.docs/raw/streaming/events.mdx +108 -0
- package/.docs/raw/streaming/overview.mdx +41 -1
- package/.docs/raw/tools-mcp/overview.mdx +2 -38
- package/.docs/raw/workflows/overview.mdx +137 -229
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
|
@@ -3,360 +3,268 @@ title: "Handling Complex LLM Operations | Workflows | Mastra"
|
|
|
3
3
|
description: "Workflows in Mastra help you orchestrate complex sequences of tasks with features like branching, parallel execution, resource suspension, and more."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { Steps } from "nextra/components";
|
|
6
|
+
import { Steps, Callout, Tabs } from "nextra/components";
|
|
7
7
|
|
|
8
8
|
# Workflows overview
|
|
9
9
|
|
|
10
|
-
Workflows
|
|
10
|
+
Workflows let you define complex sequences of tasks using clear, structured steps rather than relying on the reasoning of a single agent. They give you full control over how tasks are broken down, how data moves between them, and what gets executed when.
|
|
11
11
|
|
|
12
12
|

|
|
13
13
|
|
|
14
|
-
## When to use
|
|
14
|
+
## When to use workflows
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
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.
|
|
17
17
|
|
|
18
|
-
1. Handle a user question like “Can I return my last order?”
|
|
19
|
-
2. Fetch user-specific data from a database using their `user_id`.
|
|
20
|
-
3. Check return eligibility via an external API or business logic.
|
|
21
|
-
4. Make a conditional decision (e.g. approve, deny, escalate) based on the data.
|
|
22
|
-
5. Generate a tailored response based on the outcome.
|
|
23
18
|
|
|
24
|
-
Each of these tasks is created as a **step** in a workflow, giving you fine-grained control over data flow, execution order, and side effects.
|
|
25
19
|
|
|
26
20
|
> **📹 Watch**: → An introduction to workflows, and how they compare to agents [YouTube (7 minutes)](https://youtu.be/0jg2g3sNvgw)
|
|
27
21
|
|
|
28
|
-
##
|
|
22
|
+
## Core principles
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
Mastra workflows operate using these principles:
|
|
31
25
|
|
|
32
26
|
- Defining **steps** with `createStep`, specifying input/output schemas and business logic.
|
|
33
27
|
- Composing **steps** with `createWorkflow` to define the execution flow.
|
|
34
28
|
- Running **workflows** to execute the entire sequence, with built-in support for suspension, resumption, and streaming results.
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
## Creating a workflow step
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
Steps are the building blocks of workflows. Create a step using `createStep()` with `inputSchema` and `outputSchema` to define the data it accepts and returns.
|
|
39
33
|
|
|
40
|
-
|
|
34
|
+
```typescript {6,9,14} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
35
|
+
import { createStep } from "@mastra/core/workflows";
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
To use workflows, install the required dependencies:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm install @mastra/core
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Import the necessary functions from the `workflows` subpath:
|
|
52
|
-
|
|
53
|
-
```typescript filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
54
|
-
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
55
|
-
import { z } from "zod";
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Create step
|
|
59
|
-
|
|
60
|
-
Steps are the building blocks of workflows. Create a step using `createStep`:
|
|
61
|
-
|
|
62
|
-
```typescript filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
63
|
-
const step1 = createStep({...});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
> See [createStep](../../reference/workflows/step.mdx) for more information.
|
|
67
|
-
|
|
68
|
-
### Create workflow
|
|
69
|
-
|
|
70
|
-
Create a workflow using `createWorkflow` and complete it with `.commit()`.
|
|
71
|
-
|
|
72
|
-
```typescript {6,17} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
73
|
-
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
74
|
-
import { z } from "zod";
|
|
75
|
-
|
|
76
|
-
const step1 = createStep({...});
|
|
77
|
-
|
|
78
|
-
export const testWorkflow = createWorkflow({
|
|
79
|
-
id: "test-workflow",
|
|
80
|
-
description: 'Test workflow',
|
|
37
|
+
const step1 = createStep({
|
|
38
|
+
id: "step-1",
|
|
81
39
|
inputSchema: z.object({
|
|
82
|
-
|
|
40
|
+
message: z.string()
|
|
83
41
|
}),
|
|
84
42
|
outputSchema: z.object({
|
|
85
|
-
|
|
43
|
+
formatted: z.string()
|
|
86
44
|
}),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
45
|
+
execute: async ({ inputData }) => {
|
|
46
|
+
const { message } = inputData;
|
|
47
|
+
return {
|
|
48
|
+
formatted: message.toUpperCase()
|
|
49
|
+
};
|
|
90
50
|
}
|
|
91
|
-
})
|
|
92
|
-
.then(step1)
|
|
93
|
-
.commit();
|
|
51
|
+
});
|
|
94
52
|
```
|
|
95
53
|
|
|
96
|
-
> See [
|
|
54
|
+
> See the [Step Class](../../reference/workflows/step.mdx) for a full list of configuration options.
|
|
97
55
|
|
|
98
|
-
|
|
56
|
+
## Creating a workflow
|
|
99
57
|
|
|
100
|
-
|
|
58
|
+
Create a workflow using `createWorkflow()` with `inputSchema` and `outputSchema` to define the data it accepts and returns. Add steps using `.then()` and complete the workflow with `.commit()`.
|
|
101
59
|
|
|
102
|
-
```typescript {
|
|
60
|
+
```typescript {9,12,15,16} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
103
61
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
104
62
|
import { z } from "zod";
|
|
105
63
|
|
|
106
64
|
const step1 = createStep({...});
|
|
107
|
-
const step2 = createStep({...});
|
|
108
65
|
|
|
109
66
|
export const testWorkflow = createWorkflow({
|
|
110
67
|
id: "test-workflow",
|
|
111
|
-
description: 'Test workflow',
|
|
112
68
|
inputSchema: z.object({
|
|
113
|
-
|
|
69
|
+
message: z.string()
|
|
114
70
|
}),
|
|
115
71
|
outputSchema: z.object({
|
|
116
72
|
output: z.string()
|
|
117
73
|
})
|
|
118
74
|
})
|
|
119
75
|
.then(step1)
|
|
120
|
-
.then(step2)
|
|
121
76
|
.commit();
|
|
77
|
+
|
|
122
78
|
```
|
|
123
79
|
|
|
124
|
-
>
|
|
80
|
+
> See the [Workflow Class](../../reference/workflows/workflow.mdx) for a full list of configuration options.
|
|
125
81
|
|
|
126
|
-
|
|
82
|
+
### Understanding control flow
|
|
127
83
|
|
|
128
|
-
|
|
84
|
+
Workflows can be composed using a number of different methods. The method you choose determines how each step's schema should be structured.
|
|
129
85
|
|
|
130
|
-
|
|
131
|
-
import { createWorkflow, createStep, cloneStep } from "@mastra/core/workflows";
|
|
132
|
-
import { z } from "zod";
|
|
86
|
+
> See [Control Flow](./control-flow.mdx) for more information.
|
|
133
87
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
88
|
+
#### Composing steps
|
|
89
|
+
|
|
90
|
+
When using `.then()`, steps run sequentially. The `inputSchema` of each step must match the `outputSchema` of the step before it. The final step’s `outputSchema` doesn’t need to match the workflow’s `outputSchema`, which can be defined independently.
|
|
91
|
+
|
|
92
|
+
```typescript {4,7,14,17,24,27} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
93
|
+
const step1 = createStep({
|
|
94
|
+
//...
|
|
95
|
+
inputSchema: z.object({
|
|
96
|
+
message: z.string()
|
|
97
|
+
}),
|
|
98
|
+
outputSchema: z.object({
|
|
99
|
+
formatted: z.string()
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const step2 = createStep({
|
|
104
|
+
// ...
|
|
105
|
+
inputSchema: z.object({
|
|
106
|
+
formatted: z.string()
|
|
107
|
+
}),
|
|
108
|
+
outputSchema: z.object({
|
|
109
|
+
emphasized: z.string()
|
|
110
|
+
})
|
|
111
|
+
});
|
|
137
112
|
|
|
138
113
|
export const testWorkflow = createWorkflow({
|
|
139
|
-
|
|
140
|
-
description: 'Test workflow',
|
|
114
|
+
// ...
|
|
141
115
|
inputSchema: z.object({
|
|
142
|
-
|
|
116
|
+
message: z.string()
|
|
143
117
|
}),
|
|
144
118
|
outputSchema: z.object({
|
|
145
119
|
output: z.string()
|
|
146
120
|
})
|
|
147
121
|
})
|
|
148
122
|
.then(step1)
|
|
149
|
-
.then(clonedStep)
|
|
150
123
|
.then(step2)
|
|
151
124
|
.commit();
|
|
152
125
|
```
|
|
153
126
|
|
|
154
|
-
|
|
127
|
+
### Registering a workflow
|
|
155
128
|
|
|
156
|
-
Register
|
|
129
|
+
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:
|
|
157
130
|
|
|
158
|
-
```typescript {
|
|
131
|
+
```typescript {6} filename="src/mastra/index.ts" showLineNumbers copy
|
|
159
132
|
import { Mastra } from "@mastra/core/mastra";
|
|
160
|
-
import { PinoLogger } from "@mastra/loggers";
|
|
161
|
-
import { LibSQLStore } from "@mastra/libsql";
|
|
162
|
-
|
|
163
133
|
import { testWorkflow } from "./workflows/test-workflow";
|
|
164
134
|
|
|
165
135
|
export const mastra = new Mastra({
|
|
136
|
+
// ...
|
|
166
137
|
workflows: { testWorkflow },
|
|
167
|
-
storage: new LibSQLStore({
|
|
168
|
-
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
169
|
-
url: ":memory:"
|
|
170
|
-
}),
|
|
171
|
-
logger: new PinoLogger({
|
|
172
|
-
name: "Mastra",
|
|
173
|
-
level: "info"
|
|
174
|
-
})
|
|
175
138
|
});
|
|
176
139
|
```
|
|
177
140
|
|
|
178
|
-
##
|
|
179
|
-
|
|
180
|
-
Use `RuntimeContext` to access request-specific values. This lets you conditionally adjust behavior based on the context of the request.
|
|
181
|
-
|
|
182
|
-
```typescript filename="src/mastra/workflows/test-workflow.ts" showLineNumbers
|
|
183
|
-
export type UserTier = {
|
|
184
|
-
"user-tier": "enterprise" | "pro";
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const stepOne = createStep({
|
|
188
|
-
// ...
|
|
189
|
-
execute: async ({ runtimeContext }) => {
|
|
190
|
-
const userTier = runtimeContext.get("user-tier") as UserTier["user-tier"];
|
|
141
|
+
## Referencing a workflow
|
|
191
142
|
|
|
192
|
-
|
|
193
|
-
? 1000
|
|
194
|
-
: 50;
|
|
143
|
+
You can run workflows from agents, tools, the Mastra Client, or the command line. Get a reference by calling `.getWorkflow()` on your `mastra` or `mastraClient` instance, depending on your setup:
|
|
195
144
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
145
|
+
```typescript showLineNumbers copy
|
|
146
|
+
const testWorkflow = mastra.getWorkflow("testWorkflow");
|
|
199
147
|
```
|
|
148
|
+
<Callout type="info">
|
|
149
|
+
<p>
|
|
150
|
+
`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).
|
|
151
|
+
</p>
|
|
152
|
+
</Callout>
|
|
200
153
|
|
|
201
|
-
|
|
202
|
-
There are two ways to run and test workflows.
|
|
203
|
-
|
|
204
|
-
<Steps>
|
|
205
|
-
|
|
206
|
-
### Mastra Playground
|
|
207
|
-
|
|
208
|
-
With the Mastra Dev Server running you can run the workflow from the Mastra Playground by visiting [http://localhost:4111/workflows](http://localhost:4111/workflows) in your browser.
|
|
209
|
-
|
|
210
|
-
> For more information, see the [Local Dev Playground](../server-db/local-dev-playground.mdx) documentation.
|
|
154
|
+
> See [Running Workflows](../../examples/workflows/running-workflows.mdx) for more information.
|
|
211
155
|
|
|
212
|
-
|
|
156
|
+
## Running workflows
|
|
213
157
|
|
|
214
|
-
|
|
158
|
+
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.
|
|
215
159
|
|
|
216
|
-
|
|
217
|
-
|
|
160
|
+
<Tabs items={["Start", "Stream"]}>
|
|
161
|
+
<Tabs.Tab>
|
|
162
|
+
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.
|
|
218
163
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const run = await mastra.getWorkflow("testWorkflow").createRunAsync();
|
|
164
|
+
```typescript showLineNumbers copy
|
|
165
|
+
const run = await testWorkflow.createRunAsync();
|
|
222
166
|
|
|
223
167
|
const result = await run.start({
|
|
224
168
|
inputData: {
|
|
225
|
-
|
|
169
|
+
message: "Hello world"
|
|
226
170
|
}
|
|
227
171
|
});
|
|
228
172
|
|
|
229
173
|
console.log(result);
|
|
230
|
-
|
|
231
|
-
if (result.status === 'success') {
|
|
232
|
-
console.log(result.result.output);
|
|
233
|
-
}
|
|
234
174
|
```
|
|
235
|
-
>
|
|
236
|
-
|
|
237
|
-
|
|
175
|
+
</Tabs.Tab>
|
|
176
|
+
<Tabs.Tab>
|
|
177
|
+
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.
|
|
238
178
|
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
```
|
|
179
|
+
```typescript showLineNumbers copy
|
|
180
|
+
const run = await testWorkflow.createRunAsync();
|
|
242
181
|
|
|
243
|
-
|
|
182
|
+
const result = await run.stream({
|
|
183
|
+
inputData: {
|
|
184
|
+
message: "Hello world"
|
|
185
|
+
}
|
|
186
|
+
});
|
|
244
187
|
|
|
245
|
-
|
|
188
|
+
for await (const chunk of result.stream) {
|
|
189
|
+
console.log(chunk);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
</Tabs.Tab>
|
|
193
|
+
</Tabs>
|
|
246
194
|
|
|
247
|
-
|
|
195
|
+
## Workflow output
|
|
248
196
|
|
|
249
|
-
|
|
197
|
+
The workflow output includes the full execution lifecycle, showing the input and output for each step. It also includes the status of each step, the overall workflow status, and the final result. This gives you clear insight into how data moved through the workflow, what each step produced, and how the workflow completed.
|
|
250
198
|
|
|
251
199
|
```json
|
|
252
200
|
{
|
|
253
201
|
"status": "success",
|
|
254
202
|
"steps": {
|
|
255
|
-
|
|
203
|
+
"input": {
|
|
204
|
+
"message": "Hello world"
|
|
205
|
+
},
|
|
256
206
|
"step-1": {
|
|
257
|
-
|
|
207
|
+
"payload": {
|
|
208
|
+
"message": "Hello world"
|
|
209
|
+
},
|
|
258
210
|
"status": "success",
|
|
211
|
+
"output": {
|
|
212
|
+
"formatted": "HELLO WORLD"
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
"step-2": {
|
|
216
|
+
"payload": {
|
|
217
|
+
"formatted": "HELLO WORLD"
|
|
218
|
+
},
|
|
219
|
+
"status": "success",
|
|
220
|
+
"output": {
|
|
221
|
+
"emphasized": "HELLO WORLD!!!"
|
|
222
|
+
},
|
|
259
223
|
}
|
|
260
224
|
},
|
|
225
|
+
"input": {
|
|
226
|
+
"message": "Hello world"
|
|
227
|
+
},
|
|
261
228
|
"result": {
|
|
262
|
-
"
|
|
229
|
+
"emphasized": "HELLO WORLD!!!"
|
|
263
230
|
}
|
|
264
231
|
}
|
|
265
232
|
```
|
|
266
233
|
|
|
267
|
-
|
|
268
|
-
- **steps**: Lists each step in the workflow, including inputs and outputs
|
|
269
|
-
- **status**: Shows the outcome of each individual step
|
|
270
|
-
- **result**: Includes the final output of the workflow, typed according to the `outputSchema`
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
#### Status suspended
|
|
274
|
-
|
|
275
|
-
```json
|
|
276
|
-
{
|
|
277
|
-
"status": "suspended",
|
|
278
|
-
"steps": {
|
|
279
|
-
// ...
|
|
280
|
-
"step-1": {
|
|
281
|
-
// ...
|
|
282
|
-
"status": "suspended",
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
"suspended": [
|
|
286
|
-
[
|
|
287
|
-
"step-1"
|
|
288
|
-
]
|
|
289
|
-
]
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
- **suspended**: An optional array listing any steps currently awaiting input before continuing
|
|
294
|
-
|
|
295
|
-
#### Status failed
|
|
296
|
-
|
|
297
|
-
```json
|
|
298
|
-
{
|
|
299
|
-
"status": "failed",
|
|
300
|
-
"steps": {
|
|
301
|
-
// ...
|
|
302
|
-
"step-1": {
|
|
303
|
-
// ...
|
|
304
|
-
"status": "failed",
|
|
305
|
-
"error": "Test error",
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
"error": "Test error"
|
|
309
|
-
}
|
|
310
|
-
```
|
|
311
|
-
- **error**: An optional field that includes the error message if the workflow fails
|
|
234
|
+
## Using `RuntimeContext`
|
|
312
235
|
|
|
313
|
-
|
|
236
|
+
Use `RuntimeContext` to access request-specific values. This lets you conditionally adjust behavior based on the context of the request.
|
|
314
237
|
|
|
315
|
-
|
|
238
|
+
```typescript filename="src/mastra/workflows/test-workflow.ts" showLineNumbers
|
|
239
|
+
export type UserTier = {
|
|
240
|
+
"user-tier": "enterprise" | "pro";
|
|
241
|
+
};
|
|
316
242
|
|
|
317
|
-
|
|
318
|
-
|
|
243
|
+
const step1 = createStep({
|
|
244
|
+
// ...
|
|
245
|
+
execute: async ({ runtimeContext }) => {
|
|
246
|
+
const userTier = runtimeContext.get("user-tier") as UserTier["user-tier"];
|
|
319
247
|
|
|
320
|
-
const
|
|
248
|
+
const maxResults = userTier === "enterprise"
|
|
249
|
+
? 1000
|
|
250
|
+
: 50;
|
|
321
251
|
|
|
322
|
-
|
|
323
|
-
inputData: {
|
|
324
|
-
city: "London"
|
|
252
|
+
return { maxResults };
|
|
325
253
|
}
|
|
326
254
|
});
|
|
327
|
-
|
|
328
|
-
for await (const chunk of result.stream) {
|
|
329
|
-
console.log(chunk);
|
|
330
|
-
}
|
|
331
255
|
```
|
|
332
256
|
|
|
333
|
-
> See [
|
|
334
|
-
|
|
335
|
-
## Watch Workflow
|
|
336
|
-
|
|
337
|
-
A workflow can also be watched, allowing you to inspect each event that is emitted.
|
|
257
|
+
> See [Runtime Context](../server-db/runtime-context.mdx) for more information.
|
|
338
258
|
|
|
339
|
-
|
|
340
|
-
import { mastra } from "./mastra";
|
|
259
|
+
## Testing with Mastra Playground
|
|
341
260
|
|
|
342
|
-
|
|
261
|
+
Use the Mastra [Playground](../server-db/local-dev-playground.mdx) 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.
|
|
343
262
|
|
|
344
|
-
run.watch((event) => {
|
|
345
|
-
console.log(event);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
const result = await run.start({
|
|
349
|
-
inputData: {
|
|
350
|
-
city: "London"
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
> See [watch](../../reference/workflows/run-methods/watch.mdx) for more information.
|
|
356
263
|
|
|
357
264
|
## Related
|
|
358
265
|
|
|
359
|
-
|
|
266
|
+
For a closer look at workflows, see our [Workflow Guide](../../guides/guide/ai-recruiter.mdx), which walks through the core concepts with a practical example.
|
|
267
|
+
|
|
360
268
|
- [Parallel Steps workflow example](../../examples/workflows/parallel-steps.mdx)
|
|
361
269
|
- [Conditional Branching workflow example](../../examples/workflows/conditional-branching.mdx)
|
|
362
270
|
- [Inngest workflow example](../../examples/workflows/inngest-workflow.mdx)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 0.13.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`ca85c93`](https://github.com/mastra-ai/mastra/commit/ca85c932b232e6ad820c811ec176d98e68c59b0a), [`a1d40f8`](https://github.com/mastra-ai/mastra/commit/a1d40f88d4ce42c4508774ad22e38ac582157af2), [`01c4a25`](https://github.com/mastra-ai/mastra/commit/01c4a2506c514d5e861c004d3d2fb3791c6391f3), [`cce8aad`](https://github.com/mastra-ai/mastra/commit/cce8aad878a0dd98e5647680f3765caba0b1701c)]:
|
|
8
|
+
- @mastra/core@0.21.1
|
|
9
|
+
|
|
10
|
+
## 0.13.31-alpha.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`ca85c93`](https://github.com/mastra-ai/mastra/commit/ca85c932b232e6ad820c811ec176d98e68c59b0a), [`a1d40f8`](https://github.com/mastra-ai/mastra/commit/a1d40f88d4ce42c4508774ad22e38ac582157af2), [`01c4a25`](https://github.com/mastra-ai/mastra/commit/01c4a2506c514d5e861c004d3d2fb3791c6391f3), [`cce8aad`](https://github.com/mastra-ai/mastra/commit/cce8aad878a0dd98e5647680f3765caba0b1701c)]:
|
|
15
|
+
- @mastra/core@0.21.1-alpha.0
|
|
16
|
+
|
|
3
17
|
## 0.13.30
|
|
4
18
|
|
|
5
19
|
### 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.31",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"uuid": "^11.1.0",
|
|
34
34
|
"zod": "^3.25.76",
|
|
35
35
|
"zod-to-json-schema": "^3.24.6",
|
|
36
|
-
"@mastra/core": "0.21.
|
|
36
|
+
"@mastra/core": "0.21.1",
|
|
37
37
|
"@mastra/mcp": "^0.13.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"tsx": "^4.19.4",
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
51
|
"vitest": "^3.2.4",
|
|
52
|
-
"@internal/lint": "0.0.
|
|
53
|
-
"@mastra/core": "0.21.
|
|
52
|
+
"@internal/lint": "0.0.50",
|
|
53
|
+
"@mastra/core": "0.21.1"
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://mastra.ai",
|
|
56
56
|
"repository": {
|