@mastra/mcp-docs-server 1.0.0-beta.14 → 1.0.0-beta.16
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 +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +85 -85
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +258 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +338 -338
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +168 -168
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +259 -259
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +259 -259
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +279 -279
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +108 -108
- package/.docs/organized/changelogs/%40mastra%2Freact.md +77 -77
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +180 -180
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +235 -235
- package/.docs/organized/changelogs/create-mastra.md +11 -11
- package/.docs/organized/changelogs/mastra.md +40 -40
- package/.docs/organized/code-examples/agent-v6.md +70 -11
- package/.docs/organized/code-examples/client-side-tools.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +8 -3
- package/.docs/raw/deployment/overview.mdx +3 -4
- package/.docs/raw/deployment/workflow-runners.mdx +14 -0
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/guides/deployment/inngest.mdx +198 -140
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +11 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +68 -0
- package/.docs/raw/mastra-cloud/deployment.mdx +39 -0
- package/.docs/raw/mastra-cloud/observability.mdx +9 -15
- package/.docs/raw/mastra-cloud/overview.mdx +14 -44
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/reference/client-js/workflows.mdx +15 -0
- package/.docs/raw/reference/logging/pino-logger.mdx +1 -1
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +39 -18
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +4 -2
- package/.docs/raw/reference/storage/composite.mdx +223 -0
- package/.docs/raw/reference/storage/lance.mdx +3 -2
- package/.docs/raw/reference/storage/libsql.mdx +5 -2
- package/.docs/raw/reference/storage/mongodb.mdx +4 -2
- package/.docs/raw/reference/storage/mssql.mdx +4 -2
- package/.docs/raw/reference/storage/postgresql.mdx +4 -2
- package/.docs/raw/reference/tools/mcp-server.mdx +9 -0
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +51 -3
- package/.docs/raw/reference/workflows/run.mdx +8 -2
- package/.docs/raw/voice/overview.mdx +1 -1
- package/.docs/raw/workflows/overview.mdx +1 -1
- package/.docs/raw/workflows/snapshots.mdx +2 -1
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
- package/.docs/raw/mastra-cloud/dashboard.mdx +0 -96
- package/.docs/raw/mastra-cloud/setting-up.mdx +0 -106
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -362
|
@@ -3,17 +3,17 @@ title: "Inngest | Deployment"
|
|
|
3
3
|
description: "Deploy Mastra workflows with Inngest"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Inngest
|
|
6
|
+
# Inngest workflow
|
|
7
7
|
|
|
8
8
|
[Inngest](https://www.inngest.com/docs) is a developer platform for building and running background workflows, without managing infrastructure.
|
|
9
9
|
|
|
10
10
|
For a complete example with advanced flow control features, see the [Inngest workflow example](https://github.com/mastra-ai/mastra/tree/main/examples/inngest).
|
|
11
11
|
|
|
12
|
-
## How Inngest
|
|
12
|
+
## How Inngest works with Mastra
|
|
13
13
|
|
|
14
|
-
Inngest and Mastra integrate by aligning their workflow models: Inngest organizes logic into functions composed of steps, and Mastra workflows defined using `createWorkflow` and `createStep` map directly onto this paradigm. Each Mastra workflow becomes an Inngest function with a unique identifier, and each step within the workflow maps to an Inngest step.
|
|
14
|
+
Inngest and Mastra integrate by aligning their workflow models: Inngest organizes logic into functions composed of steps, and Mastra workflows defined using `createWorkflow()` and `createStep()` map directly onto this paradigm. Each Mastra workflow becomes an Inngest function with a unique identifier, and each step within the workflow maps to an Inngest step.
|
|
15
15
|
|
|
16
|
-
The `serve` function bridges the two systems by registering Mastra workflows as Inngest functions and setting up the necessary event handlers for execution and monitoring.
|
|
16
|
+
The `serve()` function bridges the two systems by registering Mastra workflows as Inngest functions and setting up the necessary event handlers for execution and monitoring.
|
|
17
17
|
|
|
18
18
|
When an event triggers a workflow, Inngest executes it step by step, memoizing each step's result. This means if a workflow is retried or resumed, completed steps are skipped, ensuring efficient and reliable execution. Control flow primitives in Mastra, such as loops, conditionals, and nested workflows are seamlessly translated into the same Inngest's function/step model, preserving advanced workflow features like composition, branching, and suspension.
|
|
19
19
|
|
|
@@ -21,19 +21,19 @@ Real-time monitoring, suspend/resume, and step-level observability are enabled v
|
|
|
21
21
|
|
|
22
22
|
## Setup
|
|
23
23
|
|
|
24
|
-
Install the required
|
|
24
|
+
Install the required packages:
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
|
-
npm install @mastra/inngest@beta
|
|
27
|
+
npm install @mastra/inngest@beta inngest @inngest/realtime
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
## Building an Inngest
|
|
30
|
+
## Building an Inngest workflow
|
|
31
31
|
|
|
32
32
|
This guide walks through creating a workflow with Inngest and Mastra, demonstrating a counter application that increments a value until it reaches 10.
|
|
33
33
|
|
|
34
|
-
### Inngest
|
|
34
|
+
### Inngest initialization
|
|
35
35
|
|
|
36
|
-
Initialize the Inngest integration to obtain Mastra-compatible workflow helpers. The createWorkflow and createStep functions are used to create workflow and step objects that are compatible with Mastra and inngest.
|
|
36
|
+
Initialize the Inngest integration to obtain Mastra-compatible workflow helpers. The `createWorkflow()` and `createStep()` functions are used to create workflow and step objects that are compatible with Mastra and inngest.
|
|
37
37
|
|
|
38
38
|
In development:
|
|
39
39
|
|
|
@@ -61,7 +61,7 @@ export const inngest = new Inngest({
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
### Creating
|
|
64
|
+
### Creating steps
|
|
65
65
|
|
|
66
66
|
Define the individual steps that will compose your workflow:
|
|
67
67
|
|
|
@@ -88,9 +88,9 @@ const incrementStep = createStep({
|
|
|
88
88
|
});
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
### Creating the
|
|
91
|
+
### Creating the workflow
|
|
92
92
|
|
|
93
|
-
Compose the steps into a workflow using the `dountil` loop pattern. The createWorkflow function creates a function on
|
|
93
|
+
Compose the steps into a workflow using the `dountil` loop pattern. The `createWorkflow()` function creates a function on Inngest server that is invocable.
|
|
94
94
|
|
|
95
95
|
```ts title="src/mastra/workflows/index.ts"
|
|
96
96
|
// workflow that is registered as a function on inngest server
|
|
@@ -109,95 +109,53 @@ workflow.commit();
|
|
|
109
109
|
export { workflow as incrementWorkflow };
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
### Configuring the Mastra
|
|
112
|
+
### Configuring the Mastra instance
|
|
113
113
|
|
|
114
114
|
Register the workflow with Mastra and configure the Inngest API endpoint:
|
|
115
115
|
|
|
116
116
|
```ts title="src/mastra/index.ts"
|
|
117
117
|
import { Mastra } from "@mastra/core";
|
|
118
|
-
import { serve
|
|
118
|
+
import { serve } from "@mastra/inngest";
|
|
119
119
|
import { incrementWorkflow } from "./workflows";
|
|
120
120
|
import { inngest } from "./inngest";
|
|
121
121
|
import { PinoLogger } from "@mastra/loggers";
|
|
122
122
|
|
|
123
|
-
// Configure Mastra with the workflow and Inngest API endpoint
|
|
124
123
|
export const mastra = new Mastra({
|
|
125
|
-
workflows: {
|
|
126
|
-
incrementWorkflow,
|
|
127
|
-
},
|
|
124
|
+
workflows: { incrementWorkflow },
|
|
128
125
|
server: {
|
|
129
|
-
// The server configuration is required to allow local docker container can connect to the mastra server
|
|
130
126
|
host: "0.0.0.0",
|
|
131
127
|
apiRoutes: [
|
|
132
|
-
// This API route is used to register the Mastra workflow (inngest function) on the inngest server
|
|
133
128
|
{
|
|
134
129
|
path: "/api/inngest",
|
|
135
130
|
method: "ALL",
|
|
136
|
-
createHandler: async ({ mastra }) =>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// 2. Setting up event handlers that:
|
|
140
|
-
// - Generate unique run IDs for each workflow execution
|
|
141
|
-
// - Create an InngestExecutionEngine to manage step execution
|
|
142
|
-
// - Handle workflow state persistence and real-time updates
|
|
143
|
-
// 3. Establishing a publish-subscribe system for real-time monitoring
|
|
144
|
-
// through the workflow:${workflowId}:${runId} channel
|
|
145
|
-
//
|
|
146
|
-
// Optional: You can also pass additional Inngest functions to serve alongside workflows:
|
|
147
|
-
// createHandler: async ({ mastra }) => inngestServe({
|
|
148
|
-
// mastra,
|
|
149
|
-
// inngest,
|
|
150
|
-
// functions: [customFunction1, customFunction2] // User-defined Inngest functions
|
|
151
|
-
// }),
|
|
131
|
+
createHandler: async ({ mastra }) => {
|
|
132
|
+
return serve({ mastra, inngest });
|
|
133
|
+
},
|
|
152
134
|
},
|
|
153
135
|
],
|
|
154
136
|
},
|
|
155
|
-
logger: new PinoLogger({
|
|
156
|
-
name: "Mastra",
|
|
157
|
-
level: "info",
|
|
158
|
-
}),
|
|
137
|
+
logger: new PinoLogger({ name: "Mastra", level: "info" }),
|
|
159
138
|
});
|
|
160
139
|
```
|
|
161
140
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
:::info[Prerequisites]
|
|
141
|
+
## Running workflows
|
|
165
142
|
|
|
166
|
-
|
|
167
|
-
- Mastra project set up
|
|
168
|
-
- Dependencies installed (`npm install`)
|
|
143
|
+
### Running locally
|
|
169
144
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
1. Run `npx mastra dev` to start the Mastra server on local to serve the server on port 4111.
|
|
173
|
-
2. Start the Inngest Dev Server (via Docker)
|
|
174
|
-
In a new terminal, run:
|
|
145
|
+
1. Run `npx mastra dev` to start the Mastra server locally on port 4111
|
|
146
|
+
2. Start the Inngest Dev Server. In a new terminal, run:
|
|
175
147
|
|
|
176
148
|
```sh
|
|
177
|
-
|
|
178
|
-
inngest/inngest \
|
|
179
|
-
inngest dev -u http://host.docker.internal:4111/api/inngest
|
|
149
|
+
npx inngest-cli@latest dev -u http://localhost:4111/api/inngest
|
|
180
150
|
```
|
|
181
151
|
|
|
182
152
|
:::note
|
|
183
|
-
|
|
184
|
-
The URL after `-u` tells the Inngest dev server where to find your Mastra `/api/inngest` endpoint.
|
|
185
|
-
|
|
153
|
+
The URL after `-u` tells the Inngest dev server where to find your Mastra `/api/inngest` endpoint
|
|
186
154
|
:::
|
|
187
155
|
|
|
188
|
-
3. Open the Inngest Dashboard
|
|
156
|
+
3. Open the Inngest Dashboard at [http://localhost:8288](http://localhost:8288) and go to the **Apps** section in the sidebar to verify your Mastra workflow is registered
|
|
189
157
|
|
|
190
|
-
|
|
191
|
-
- Go to the **Apps** section in the sidebar.
|
|
192
|
-
- You should see your Mastra workflow registered.
|
|
193
|
-
|
|
194
|
-

|
|
195
|
-
|
|
196
|
-
4. Invoke the Workflow
|
|
197
|
-
|
|
198
|
-
- Go to the **Functions** section in the sidebar.
|
|
199
|
-
- Select your Mastra workflow.
|
|
200
|
-
- Click **Invoke** and use the following input:
|
|
158
|
+
4. Invoke the workflow by going to **Functions**, selecting your workflow, and clicking **Invoke** with the following input:
|
|
201
159
|
|
|
202
160
|
```json
|
|
203
161
|
{
|
|
@@ -209,26 +167,24 @@ export const mastra = new Mastra({
|
|
|
209
167
|
}
|
|
210
168
|
```
|
|
211
169
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
5. **Monitor the Workflow Execution**
|
|
215
|
-
|
|
216
|
-
- Go to the **Runs** tab in the sidebar.
|
|
217
|
-
- Click on the latest run to see step-by-step execution progress.
|
|
218
|
-
|
|
219
|
-

|
|
170
|
+
5. Monitor the workflow execution in the **Runs** tab to see step-by-step execution progress
|
|
220
171
|
|
|
221
|
-
### Running
|
|
172
|
+
### Running in production
|
|
222
173
|
|
|
223
|
-
|
|
174
|
+
Before you begin, make sure you have:
|
|
224
175
|
|
|
225
176
|
- Vercel account and Vercel CLI installed (`npm i -g vercel`)
|
|
226
177
|
- Inngest account
|
|
227
|
-
- Vercel token
|
|
178
|
+
- Vercel token
|
|
228
179
|
|
|
229
|
-
:::
|
|
230
180
|
|
|
231
|
-
1.
|
|
181
|
+
1. Set your Vercel token in your environment:
|
|
182
|
+
|
|
183
|
+
```sh title=".env"
|
|
184
|
+
export VERCEL_TOKEN=your_vercel_token
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
2. Add `VercelDeployer` to Mastra instance
|
|
232
188
|
|
|
233
189
|
```ts title="src/mastra/index.ts"
|
|
234
190
|
import { VercelDeployer } from "@mastra/deployer-vercel";
|
|
@@ -239,53 +195,29 @@ export const mastra = new Mastra({
|
|
|
239
195
|
projectName: "your_project_name",
|
|
240
196
|
// you can get your vercel token from the vercel dashboard by clicking on the user icon in the top right corner
|
|
241
197
|
// and then clicking on "Account Settings" and then clicking on "Tokens" on the left sidebar.
|
|
242
|
-
token:
|
|
198
|
+
token: process.env.VERCEL_TOKEN,
|
|
243
199
|
}),
|
|
244
200
|
});
|
|
245
201
|
```
|
|
246
202
|
|
|
247
|
-
:::note
|
|
248
|
-
|
|
249
|
-
Set your Vercel token in your environment:
|
|
250
|
-
|
|
251
|
-
```sh
|
|
252
|
-
export VERCEL_TOKEN=your_vercel_token
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
:::
|
|
256
203
|
|
|
257
|
-
|
|
204
|
+
3. Build the mastra instance
|
|
258
205
|
|
|
259
206
|
```sh
|
|
260
207
|
npx mastra build
|
|
261
208
|
```
|
|
262
209
|
|
|
263
|
-
|
|
210
|
+
4. Deploy to Vercel
|
|
264
211
|
|
|
265
212
|
```sh
|
|
266
213
|
cd .mastra/output
|
|
214
|
+
vercel login
|
|
267
215
|
vercel --prod
|
|
268
216
|
```
|
|
269
217
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
If you haven't already, log in to Vercel CLI with `vercel login`.
|
|
273
|
-
|
|
274
|
-
:::
|
|
275
|
-
|
|
276
|
-
4. Sync with Inngest Dashboard
|
|
277
|
-
|
|
278
|
-
- Go to the [Inngest dashboard](https://app.inngest.com/env/production/apps).
|
|
279
|
-
- Click **Sync new app with Vercel** and follow the instructions.
|
|
280
|
-
- You should see your Mastra workflow registered as an app.
|
|
218
|
+
5. Sync with the [Inngest dashboard](https://app.inngest.com/env/production/apps) by clicking **Sync new app with Vercel** and following the instructions
|
|
281
219
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
5. Invoke the Workflow
|
|
285
|
-
|
|
286
|
-
- In the **Functions** section, select `workflow.increment-workflow`.
|
|
287
|
-
- Click **All actions** (top right) > **Invoke**.
|
|
288
|
-
- Provide the following input:
|
|
220
|
+
6. Invoke the workflow by going to **Functions**, selecting `workflow.increment-workflow`, clicking **All actions** > **Invoke**, and providing the following input:
|
|
289
221
|
|
|
290
222
|
```json
|
|
291
223
|
{
|
|
@@ -297,25 +229,18 @@ export const mastra = new Mastra({
|
|
|
297
229
|
}
|
|
298
230
|
```
|
|
299
231
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
6. Monitor Execution
|
|
232
|
+
7. Monitor execution in the **Runs** tab to see step-by-step progress
|
|
303
233
|
|
|
304
|
-
|
|
305
|
-
- Click the latest run to see step-by-step execution progress.
|
|
234
|
+
## Adding custom Inngest functions
|
|
306
235
|
|
|
307
|
-
|
|
236
|
+
You can serve additional Inngest functions alongside your Mastra workflows by using the optional `functions` parameter in `serve()`.
|
|
308
237
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
You can serve additional Inngest functions alongside your Mastra workflows by using the optional `functions` parameter in `inngestServe`.
|
|
312
|
-
|
|
313
|
-
### Creating Custom Functions
|
|
238
|
+
### Creating custom functions
|
|
314
239
|
|
|
315
240
|
First, create your custom Inngest functions:
|
|
316
241
|
|
|
317
242
|
```ts title="src/inngest/custom-functions.ts"
|
|
318
|
-
import { inngest } from "
|
|
243
|
+
import { inngest } from "../inngest";
|
|
319
244
|
|
|
320
245
|
// Define custom Inngest functions
|
|
321
246
|
export const customEmailFunction = inngest.createFunction(
|
|
@@ -339,48 +264,181 @@ export const customWebhookFunction = inngest.createFunction(
|
|
|
339
264
|
);
|
|
340
265
|
```
|
|
341
266
|
|
|
342
|
-
### Serving
|
|
267
|
+
### Serving custom functions with workflows
|
|
343
268
|
|
|
344
|
-
Update your Mastra configuration to include the custom functions:
|
|
269
|
+
Update your Mastra configuration to import and include the custom functions. The highlighted lines show the additions:
|
|
345
270
|
|
|
346
|
-
```ts title="src/mastra/index.ts"
|
|
271
|
+
```ts title="src/mastra/index.ts" {5-8,23}
|
|
347
272
|
import { Mastra } from "@mastra/core";
|
|
348
|
-
import { serve
|
|
273
|
+
import { serve } from "@mastra/inngest";
|
|
349
274
|
import { incrementWorkflow } from "./workflows";
|
|
350
275
|
import { inngest } from "./inngest";
|
|
351
276
|
import {
|
|
352
277
|
customEmailFunction,
|
|
353
278
|
customWebhookFunction,
|
|
354
279
|
} from "./inngest/custom-functions";
|
|
280
|
+
import { PinoLogger } from "@mastra/loggers";
|
|
355
281
|
|
|
356
282
|
export const mastra = new Mastra({
|
|
357
|
-
workflows: {
|
|
358
|
-
incrementWorkflow,
|
|
359
|
-
},
|
|
283
|
+
workflows: { incrementWorkflow },
|
|
360
284
|
server: {
|
|
361
285
|
host: "0.0.0.0",
|
|
362
286
|
apiRoutes: [
|
|
363
287
|
{
|
|
364
288
|
path: "/api/inngest",
|
|
365
289
|
method: "ALL",
|
|
366
|
-
createHandler: async ({ mastra }) =>
|
|
367
|
-
|
|
290
|
+
createHandler: async ({ mastra }) => {
|
|
291
|
+
return serve({
|
|
368
292
|
mastra,
|
|
369
293
|
inngest,
|
|
370
|
-
functions: [customEmailFunction, customWebhookFunction],
|
|
371
|
-
})
|
|
294
|
+
functions: [customEmailFunction, customWebhookFunction],
|
|
295
|
+
});
|
|
296
|
+
},
|
|
372
297
|
},
|
|
373
298
|
],
|
|
374
299
|
},
|
|
300
|
+
logger: new PinoLogger({ name: "Mastra", level: "info" }),
|
|
375
301
|
});
|
|
376
302
|
```
|
|
377
303
|
|
|
378
|
-
### Function
|
|
304
|
+
### Function registration
|
|
379
305
|
|
|
380
306
|
When you include custom functions:
|
|
381
307
|
|
|
382
|
-
1.
|
|
383
|
-
2.
|
|
384
|
-
3.
|
|
308
|
+
1. Mastra workflows are automatically converted to Inngest functions with IDs like `workflow.${workflowId}`
|
|
309
|
+
2. Custom functions retain their specified IDs (e.g., `send-welcome-email`, `process-webhook`)
|
|
310
|
+
3. All functions are served together on the same `/api/inngest` endpoint
|
|
311
|
+
|
|
312
|
+
This allows you to combine Mastra's workflow orchestration with your existing Inngest functions.
|
|
313
|
+
|
|
314
|
+
## Flow control
|
|
315
|
+
|
|
316
|
+
Inngest workflows support flow control features including concurrency limits, rate limiting, throttling, debouncing, and priority queuing. These options are configured in the `createWorkflow()` call and help manage workflow execution at scale.
|
|
317
|
+
|
|
318
|
+
### Concurrency
|
|
319
|
+
|
|
320
|
+
Control how many workflow instances can run simultaneously:
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
const workflow = createWorkflow({
|
|
324
|
+
id: "user-processing-workflow",
|
|
325
|
+
inputSchema: z.object({ userId: z.string() }),
|
|
326
|
+
outputSchema: z.object({ result: z.string() }),
|
|
327
|
+
steps: [processUserStep],
|
|
328
|
+
// Limit to 10 concurrent executions, scoped by user ID
|
|
329
|
+
concurrency: {
|
|
330
|
+
limit: 10,
|
|
331
|
+
key: "event.data.userId",
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Rate limiting
|
|
337
|
+
|
|
338
|
+
Limit the number of workflow executions within a time period:
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
const workflow = createWorkflow({
|
|
342
|
+
id: "api-sync-workflow",
|
|
343
|
+
inputSchema: z.object({ endpoint: z.string() }),
|
|
344
|
+
outputSchema: z.object({ status: z.string() }),
|
|
345
|
+
steps: [apiSyncStep],
|
|
346
|
+
// Maximum 1000 executions per hour
|
|
347
|
+
rateLimit: {
|
|
348
|
+
period: "1h",
|
|
349
|
+
limit: 1000,
|
|
350
|
+
},
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Throttling
|
|
355
|
+
|
|
356
|
+
Ensure minimum time between workflow executions:
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
const workflow = createWorkflow({
|
|
360
|
+
id: "email-notification-workflow",
|
|
361
|
+
inputSchema: z.object({ organizationId: z.string(), message: z.string() }),
|
|
362
|
+
outputSchema: z.object({ sent: z.boolean() }),
|
|
363
|
+
steps: [sendEmailStep],
|
|
364
|
+
// Only one execution per 10 seconds per organization
|
|
365
|
+
throttle: {
|
|
366
|
+
period: "10s",
|
|
367
|
+
limit: 1,
|
|
368
|
+
key: "event.data.organizationId",
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Debouncing
|
|
374
|
+
|
|
375
|
+
Delay execution until no new events arrive within a time window:
|
|
376
|
+
|
|
377
|
+
```ts
|
|
378
|
+
const workflow = createWorkflow({
|
|
379
|
+
id: "search-index-workflow",
|
|
380
|
+
inputSchema: z.object({ documentId: z.string() }),
|
|
381
|
+
outputSchema: z.object({ indexed: z.boolean() }),
|
|
382
|
+
steps: [indexDocumentStep],
|
|
383
|
+
// Wait 5 seconds of no updates before indexing
|
|
384
|
+
debounce: {
|
|
385
|
+
period: "5s",
|
|
386
|
+
key: "event.data.documentId",
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Priority
|
|
392
|
+
|
|
393
|
+
Set execution priority for workflows:
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
const workflow = createWorkflow({
|
|
397
|
+
id: "order-processing-workflow",
|
|
398
|
+
inputSchema: z.object({
|
|
399
|
+
orderId: z.string(),
|
|
400
|
+
priority: z.number().optional(),
|
|
401
|
+
}),
|
|
402
|
+
outputSchema: z.object({ processed: z.boolean() }),
|
|
403
|
+
steps: [processOrderStep],
|
|
404
|
+
// Higher priority orders execute first
|
|
405
|
+
priority: {
|
|
406
|
+
run: "event.data.priority ?? 50",
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Combining flow control options
|
|
412
|
+
|
|
413
|
+
Multiple flow control options can be combined in a single workflow:
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
const workflow = createWorkflow({
|
|
417
|
+
id: "comprehensive-workflow",
|
|
418
|
+
inputSchema: z.object({
|
|
419
|
+
userId: z.string(),
|
|
420
|
+
organizationId: z.string(),
|
|
421
|
+
priority: z.number().optional(),
|
|
422
|
+
}),
|
|
423
|
+
outputSchema: z.object({ result: z.string() }),
|
|
424
|
+
steps: [comprehensiveStep],
|
|
425
|
+
concurrency: {
|
|
426
|
+
limit: 5,
|
|
427
|
+
key: "event.data.userId",
|
|
428
|
+
},
|
|
429
|
+
rateLimit: {
|
|
430
|
+
period: "1m",
|
|
431
|
+
limit: 100,
|
|
432
|
+
},
|
|
433
|
+
throttle: {
|
|
434
|
+
period: "10s",
|
|
435
|
+
limit: 1,
|
|
436
|
+
key: "event.data.organizationId",
|
|
437
|
+
},
|
|
438
|
+
priority: {
|
|
439
|
+
run: "event.data.priority ?? 0",
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
```
|
|
385
443
|
|
|
386
|
-
|
|
444
|
+
All flow control options are optional. If not specified, workflows run with Inngest's default behavior. For more information, see the [Inngest flow control documentation](https://www.inngest.com/docs/guides/flow-control).
|
|
@@ -252,18 +252,26 @@ To migrate, use `MastraDBMessage` for storage or AI SDK v5 message formats direc
|
|
|
252
252
|
|
|
253
253
|
The `processors` config option in the Memory constructor has been deprecated and now throws an error. Processors should be configured at the Agent level instead. This change provides clearer configuration boundaries and better encapsulation.
|
|
254
254
|
|
|
255
|
-
To migrate, move processor configuration from Memory to Agent
|
|
255
|
+
To migrate, move processor configuration from Memory to Agent using `inputProcessors` and/or `outputProcessors`.
|
|
256
256
|
|
|
257
257
|
```diff
|
|
258
|
+
+ import { TokenLimiter } from '@mastra/core/processors';
|
|
259
|
+
+
|
|
258
260
|
const memory = new Memory({
|
|
259
261
|
storage,
|
|
260
262
|
vector,
|
|
261
263
|
embedder,
|
|
262
264
|
- processors: [/* ... */],
|
|
263
265
|
});
|
|
264
|
-
|
|
266
|
+
|
|
265
267
|
const agent = new Agent({
|
|
266
268
|
memory,
|
|
267
|
-
+
|
|
269
|
+
+ inputProcessors: [
|
|
270
|
+
+ new TokenLimiter({ limit: 4000 }), // Limits historical messages to fit context window
|
|
271
|
+
+ ],
|
|
268
272
|
});
|
|
269
273
|
```
|
|
274
|
+
|
|
275
|
+
Additionally, the `@mastra/memory/processors` import path has been removed. Import processors from `@mastra/core/processors` instead. See the [processors migration guide](/guides/v1/migrations/upgrade-to-v1/processors#memory-processor-exports-moved-to-core) for details.
|
|
276
|
+
|
|
277
|
+
For more information on using processors with agents, see the [Processors docs](/docs/v1/agents/processors). For a complete example with memory, see the [TokenLimiter reference](/reference/v1/processors/token-limiter-processor#extended-usage-example).
|
|
@@ -60,3 +60,14 @@ If you have used `InputProcessor`, replace it with `Processor` which implements
|
|
|
60
60
|
- import { InputProcessor, ModerationProcessor } from '@mastra/core/agent/input-processors/processors';
|
|
61
61
|
+ import { Processor, ModerationProcessor } from '@mastra/core/processors';
|
|
62
62
|
```
|
|
63
|
+
|
|
64
|
+
### Memory processor exports moved to core
|
|
65
|
+
|
|
66
|
+
The `@mastra/memory/processors` export has been removed. All processors are now exported from `@mastra/core/processors`. This change consolidates all processor exports in a single location.
|
|
67
|
+
|
|
68
|
+
To migrate, update your import paths from `@mastra/memory/processors` to `@mastra/core/processors`.
|
|
69
|
+
|
|
70
|
+
```diff
|
|
71
|
+
- import { TokenLimiter, ToolCallFilter } from '@mastra/memory/processors';
|
|
72
|
+
+ import { TokenLimiter, ToolCallFilter } from '@mastra/core/processors';
|
|
73
|
+
```
|
|
@@ -7,6 +7,33 @@ description: "Learn how to migrate storage-related changes when upgrading to v1.
|
|
|
7
7
|
|
|
8
8
|
Storage APIs have been standardized with consistent pagination and naming patterns across all methods.
|
|
9
9
|
|
|
10
|
+
## Added
|
|
11
|
+
|
|
12
|
+
### Storage composition in MastraStorage
|
|
13
|
+
|
|
14
|
+
`MastraStorage` can now compose storage domains from different adapters. Use it when you need different databases for different purposes - for example, PostgreSQL for memory and workflows, but a specialized database for observability.
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { MastraStorage } from "@mastra/core/storage";
|
|
18
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
19
|
+
import { MemoryLibSQL } from "@mastra/libsql";
|
|
20
|
+
import { Mastra } from "@mastra/core";
|
|
21
|
+
|
|
22
|
+
// Compose domains from different stores
|
|
23
|
+
const mastra = new Mastra({
|
|
24
|
+
storage: new MastraStorage({
|
|
25
|
+
id: "composite",
|
|
26
|
+
domains: {
|
|
27
|
+
memory: new MemoryLibSQL({ url: "file:./local.db" }),
|
|
28
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
29
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See the [Storage Composition reference](/reference/v1/storage/composite) for more details.
|
|
36
|
+
|
|
10
37
|
## Changed
|
|
11
38
|
|
|
12
39
|
### Required `id` property for storage instances
|
|
@@ -80,6 +107,47 @@ npx @mastra/codemod@beta v1/storage-get-messages-paginated .
|
|
|
80
107
|
|
|
81
108
|
:::
|
|
82
109
|
|
|
110
|
+
### Domain-specific storage access via `getStore()`
|
|
111
|
+
|
|
112
|
+
Storage operations are now accessed through domain-specific stores instead of directly on the storage instance.
|
|
113
|
+
|
|
114
|
+
Domains include:
|
|
115
|
+
- **`memory`** - Threads, messages, and resources
|
|
116
|
+
- **`workflows`** - Workflow snapshots
|
|
117
|
+
- **`scores`** - Evaluation scores
|
|
118
|
+
- **`observability`** - Traces and spans
|
|
119
|
+
- **`agents`** - Stored agent data
|
|
120
|
+
|
|
121
|
+
To migrate, call `getStore()` with the domain name, then call methods on the returned store.
|
|
122
|
+
|
|
123
|
+
```diff
|
|
124
|
+
const storage = mastra.getStorage();
|
|
125
|
+
|
|
126
|
+
// Memory operations (threads, messages, resources)
|
|
127
|
+
- const thread = await storage.getThread({ threadId: '123' });
|
|
128
|
+
- await storage.saveThread({ thread });
|
|
129
|
+
+ const memoryStore = await storage.getStore('memory');
|
|
130
|
+
+ const thread = await memoryStore?.getThreadById({ threadId: '123' });
|
|
131
|
+
+ await memoryStore?.saveThread({ thread });
|
|
132
|
+
|
|
133
|
+
// Workflow operations (snapshots)
|
|
134
|
+
- const snapshot = await storage.loadWorkflowSnapshot({ runId, workflowName });
|
|
135
|
+
- await storage.persistWorkflowSnapshot({ runId, workflowName, snapshot });
|
|
136
|
+
+ const workflowStore = await storage.getStore('workflows');
|
|
137
|
+
+ const snapshot = await workflowStore?.loadWorkflowSnapshot({ runId, workflowName });
|
|
138
|
+
+ await workflowStore?.persistWorkflowSnapshot({ runId, workflowName, snapshot });
|
|
139
|
+
|
|
140
|
+
// Observability operations (traces, spans)
|
|
141
|
+
- const traces = await storage.listTraces({ page: 0, perPage: 20 });
|
|
142
|
+
+ const observabilityStore = await storage.getStore('observability');
|
|
143
|
+
+ const traces = await observabilityStore?.listTraces({ page: 0, perPage: 20 });
|
|
144
|
+
|
|
145
|
+
// Score operations (evaluations)
|
|
146
|
+
- const scores = await storage.listScoresByScorerId({ scorerId: 'helpfulness' });
|
|
147
|
+
+ const scoresStore = await storage.getStore('scores');
|
|
148
|
+
+ const scores = await scoresStore?.listScoresByScorerId({ scorerId: 'helpfulness' });
|
|
149
|
+
```
|
|
150
|
+
|
|
83
151
|
### `getThreadsByResourceId` to `listThreadsByResourceId`
|
|
84
152
|
|
|
85
153
|
The `getThreadsByResourceId()` method has been renamed to `listThreadsByResourceId()`. This change aligns with the convention that `list*` methods return collections.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Deployment | Mastra Cloud"
|
|
3
|
+
description: Deploy your Mastra application to production
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deployment
|
|
7
|
+
|
|
8
|
+
Deploy your Mastra application to production and expose your agents, tools, and workflows as REST API endpoints.
|
|
9
|
+
|
|
10
|
+
:::info
|
|
11
|
+
Mastra Cloud is currently in beta, but many teams are already using it to deploy their agents. It's the easiest way to run Mastra agents in a managed environment.
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
## Enable deployments
|
|
15
|
+
|
|
16
|
+
After [setting up your project](/docs/v1/mastra-cloud/setup), click **Deployment** in the sidebar and select **Enable Deployments**.
|
|
17
|
+
|
|
18
|
+
Once enabled, your project automatically builds and deploys. Future pushes to your main branch trigger automatic redeployments.
|
|
19
|
+
|
|
20
|
+
## Dashboard
|
|
21
|
+
|
|
22
|
+
The **Overview** page shows your project's domain URL, status, latest deployment, and connected agents and workflows.
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
Click the **Deployments** menu item to view build logs. Open **Settings** to configure environment variables, branch, storage, and endpoint URLs.
|
|
27
|
+
|
|
28
|
+
:::note
|
|
29
|
+
Changes to settings require a new deployment to take effect
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
## Using your deployment
|
|
33
|
+
|
|
34
|
+
After deployment, interact with your agents using the [Mastra Client](/docs/v1/server/mastra-client) or call the REST API endpoints directly.
|
|
35
|
+
|
|
36
|
+
## Next steps
|
|
37
|
+
|
|
38
|
+
- [Studio](/docs/v1/mastra-cloud/studio) - Test your agents in the cloud
|
|
39
|
+
- [Observability](/docs/v1/mastra-cloud/observability) - Monitor traces and logs
|