@mastra/mcp-docs-server 0.13.16 → 0.13.17-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/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- 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 +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +19 -19
- 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 +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +19 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +10 -10
- 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 +9 -0
- 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 +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +19 -19
- 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 +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
- package/.docs/organized/changelogs/create-mastra.md +21 -21
- package/.docs/organized/changelogs/mastra.md +32 -32
- package/.docs/raw/agents/overview.mdx +29 -47
- package/.docs/raw/deployment/monorepo.mdx +107 -0
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +1 -0
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -0
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +5 -0
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +5 -0
- package/.docs/raw/reference/core/mastra-class.mdx +5 -3
- package/.docs/raw/reference/scorers/context-precision.mdx +130 -0
- package/.docs/raw/reference/scorers/context-relevance.mdx +222 -0
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +17 -1
- package/.docs/raw/server-db/local-dev-playground.mdx +19 -0
- package/.docs/raw/workflows/control-flow.mdx +0 -46
- package/.docs/raw/workflows/error-handling.mdx +213 -0
- package/package.json +5 -5
|
@@ -190,52 +190,6 @@ export const testWorkflow = createWorkflow({...})
|
|
|
190
190
|
.commit();
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
## Exiting early with `bail()`
|
|
194
|
-
|
|
195
|
-
Use `bail()` in a step to exit early with a successful result. This returns the provided payload as the step output and ends workflow execution.
|
|
196
|
-
|
|
197
|
-
```typescript {7} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
198
|
-
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
199
|
-
import { z } from "zod";
|
|
200
|
-
|
|
201
|
-
const step1 = createStep({
|
|
202
|
-
id: 'step1',
|
|
203
|
-
execute: async ({ bail }) => {
|
|
204
|
-
return bail({ result: 'bailed' });
|
|
205
|
-
},
|
|
206
|
-
inputSchema: z.object({ value: z.string() }),
|
|
207
|
-
outputSchema: z.object({ result: z.string() }),
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
export const testWorkflow = createWorkflow({...})
|
|
211
|
-
.then(step1)
|
|
212
|
-
.commit();
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Exiting early with `Error()`
|
|
216
|
-
|
|
217
|
-
Use `throw new Error()` in a step to exit with an error.
|
|
218
|
-
|
|
219
|
-
```typescript {7} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
220
|
-
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
221
|
-
import { z } from "zod";
|
|
222
|
-
|
|
223
|
-
const step1 = createStep({
|
|
224
|
-
id: 'step1',
|
|
225
|
-
execute: async () => {
|
|
226
|
-
throw new Error('bailed');
|
|
227
|
-
},
|
|
228
|
-
inputSchema: z.object({ value: z.string() }),
|
|
229
|
-
outputSchema: z.object({ result: z.string() }),
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
export const testWorkflow = createWorkflow({...})
|
|
233
|
-
.then(step1)
|
|
234
|
-
.commit();
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
This throws an error from the step and stops workflow execution, returning the error as the result.
|
|
238
|
-
|
|
239
193
|
## Example Run Instance
|
|
240
194
|
|
|
241
195
|
The following example demonstrates how to start a run with multiple inputs. Each input will pass through the `mapStep` sequentially.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Error Handling in Workflows | Workflows | Mastra Docs"
|
|
3
|
+
description: "Learn how to handle errors in Mastra workflows using step retries, conditional branching, and monitoring."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Error Handling
|
|
7
|
+
|
|
8
|
+
Mastra provides a built-in retry mechanism for workflows or steps that fail due to transient errors. This is particularly useful for steps that interact with external services or resources that might experience temporary unavailability.
|
|
9
|
+
|
|
10
|
+
## Workflow-level using `retryConfig`
|
|
11
|
+
|
|
12
|
+
You can configure retries at the workflow level, which applies to all steps in the workflow:
|
|
13
|
+
|
|
14
|
+
```typescript {8-11} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
15
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
|
|
18
|
+
const step1 = createStep({...});
|
|
19
|
+
|
|
20
|
+
export const testWorkflow = createWorkflow({
|
|
21
|
+
// ...
|
|
22
|
+
retryConfig: {
|
|
23
|
+
attempts: 5,
|
|
24
|
+
delay: 2000
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
.then(step1)
|
|
28
|
+
.commit();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Step-level using `retries`
|
|
32
|
+
|
|
33
|
+
You can configure retries for individual steps using the `retries` property. This overrides the workflow-level retry configuration for that specific step:
|
|
34
|
+
|
|
35
|
+
```typescript {17} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
36
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
|
|
39
|
+
const step1 = createStep({
|
|
40
|
+
// ...
|
|
41
|
+
execute: async () => {
|
|
42
|
+
const response = await // ...
|
|
43
|
+
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new Error('Error');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
value: ""
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
retries: 3
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Conditional branching
|
|
57
|
+
|
|
58
|
+
You can create alternative workflow paths based on the success or failure of previous steps using conditional logic:
|
|
59
|
+
|
|
60
|
+
```typescript {15,19,33-34} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
61
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
62
|
+
import { z } from "zod";
|
|
63
|
+
|
|
64
|
+
const step1 = createStep({
|
|
65
|
+
// ...
|
|
66
|
+
execute: async () => {
|
|
67
|
+
try {
|
|
68
|
+
const response = await // ...
|
|
69
|
+
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new Error('error');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
status: "ok"
|
|
76
|
+
};
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return {
|
|
79
|
+
status: "error"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const step2 = createStep({...});
|
|
86
|
+
const fallback = createStep({...});
|
|
87
|
+
|
|
88
|
+
export const testWorkflow = createWorkflow({
|
|
89
|
+
// ...
|
|
90
|
+
})
|
|
91
|
+
.then(step1)
|
|
92
|
+
.branch([
|
|
93
|
+
[async ({ inputData: { status } }) => status === "ok", step2],
|
|
94
|
+
[async ({ inputData: { status } }) => status === "error", fallback]
|
|
95
|
+
])
|
|
96
|
+
.commit();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Check previous step results
|
|
100
|
+
|
|
101
|
+
Use `getStepResult()` to inspect a previous step’s results.
|
|
102
|
+
|
|
103
|
+
```typescript {10} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
104
|
+
import { createStep } from "@mastra/core/workflows";
|
|
105
|
+
import { z } from "zod";
|
|
106
|
+
|
|
107
|
+
const step1 = createStep({...});
|
|
108
|
+
|
|
109
|
+
const step2 = createStep({
|
|
110
|
+
// ...
|
|
111
|
+
execute: async ({ getStepResult }) => {
|
|
112
|
+
|
|
113
|
+
const step1Result = getStepResult(step1);
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
value: ""
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Exiting early with `bail()`
|
|
123
|
+
|
|
124
|
+
Use `bail()` in a step to exit early with a successful result. This returns the provided payload as the step output and ends workflow execution.
|
|
125
|
+
|
|
126
|
+
```typescript {7} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
127
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
128
|
+
import { z } from "zod";
|
|
129
|
+
|
|
130
|
+
const step1 = createStep({
|
|
131
|
+
id: 'step1',
|
|
132
|
+
execute: async ({ bail }) => {
|
|
133
|
+
return bail({ result: 'bailed' });
|
|
134
|
+
},
|
|
135
|
+
inputSchema: z.object({ value: z.string() }),
|
|
136
|
+
outputSchema: z.object({ result: z.string() }),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const testWorkflow = createWorkflow({...})
|
|
140
|
+
.then(step1)
|
|
141
|
+
.commit();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Exiting early with `Error()`
|
|
145
|
+
|
|
146
|
+
Use `throw new Error()` in a step to exit with an error.
|
|
147
|
+
|
|
148
|
+
```typescript {7} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
|
|
149
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
150
|
+
import { z } from "zod";
|
|
151
|
+
|
|
152
|
+
const step1 = createStep({
|
|
153
|
+
id: 'step1',
|
|
154
|
+
execute: async () => {
|
|
155
|
+
throw new Error('error');
|
|
156
|
+
},
|
|
157
|
+
inputSchema: z.object({ value: z.string() }),
|
|
158
|
+
outputSchema: z.object({ result: z.string() }),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
export const testWorkflow = createWorkflow({...})
|
|
162
|
+
.then(step1)
|
|
163
|
+
.commit();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Monitor errors with `watch()`
|
|
167
|
+
|
|
168
|
+
You can monitor workflows for errors using the `watch` method:
|
|
169
|
+
|
|
170
|
+
```typescript {11} filename="src/test-workflow.ts" showLineNumbers copy
|
|
171
|
+
import { mastra } from "../src/mastra";
|
|
172
|
+
|
|
173
|
+
const workflow = mastra.getWorkflow("testWorkflow");
|
|
174
|
+
const run = await workflow.createRunAsync();
|
|
175
|
+
|
|
176
|
+
run.watch((event) => {
|
|
177
|
+
const {
|
|
178
|
+
payload: { currentStep }
|
|
179
|
+
} = event;
|
|
180
|
+
|
|
181
|
+
console.log(currentStep?.payload?.status);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Monitor errors with `stream()`
|
|
187
|
+
|
|
188
|
+
You can monitor workflows for errors using `stream`:
|
|
189
|
+
|
|
190
|
+
```typescript {11} filename="src/test-workflow.ts" showLineNumbers copy
|
|
191
|
+
import { mastra } from "../src/mastra";
|
|
192
|
+
|
|
193
|
+
const workflow = mastra.getWorkflow("testWorkflow");
|
|
194
|
+
|
|
195
|
+
const run = await workflow.createRunAsync();
|
|
196
|
+
|
|
197
|
+
const stream = await run.stream({
|
|
198
|
+
inputData: {
|
|
199
|
+
value: "initial data"
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
for await (const chunk of stream.stream) {
|
|
204
|
+
console.log(chunk.payload.output.stats);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Related
|
|
210
|
+
|
|
211
|
+
- [Control Flow](./control-flow.mdx)
|
|
212
|
+
- [Conditional Branching](./control-flow.mdx#conditional-logic-with-branch)
|
|
213
|
+
- [Running Workflows](../../examples/workflows/running-workflows.mdx)
|
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.17-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",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
33
|
"zod": "^3.25.67",
|
|
34
34
|
"zod-to-json-schema": "^3.24.5",
|
|
35
|
-
"@mastra/core": "0.15.
|
|
36
|
-
"@mastra/mcp": "^0.11.
|
|
35
|
+
"@mastra/core": "0.15.3-alpha.0",
|
|
36
|
+
"@mastra/mcp": "^0.11.3-alpha.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@hono/node-server": "^1.17.1",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"tsx": "^4.19.4",
|
|
49
49
|
"typescript": "^5.8.3",
|
|
50
50
|
"vitest": "^3.2.4",
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
51
|
+
"@mastra/core": "0.15.3-alpha.0",
|
|
52
|
+
"@internal/lint": "0.0.34"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"prepare-docs": "cross-env PREPARE=true node dist/prepare-docs/prepare.js",
|