@mastra/mcp-docs-server 0.13.4-alpha.0 → 0.13.5-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/%40mastra%2Fagui.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +42 -42
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +13 -13
- package/.docs/organized/changelogs/create-mastra.md +33 -33
- package/.docs/organized/changelogs/mastra.md +79 -79
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +9 -9
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/memory-per-resource-example.md +1 -1
- package/.docs/organized/code-examples/memory-with-pg.md +1 -1
- package/.docs/organized/code-examples/memory-with-upstash.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +4 -4
- package/.docs/raw/client-js/overview.mdx +16 -0
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +279 -0
- package/.docs/raw/deployment/serverless-platforms/index.mdx +0 -1
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +97 -0
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +34 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +10 -3
- package/.docs/raw/memory/overview.mdx +2 -1
- package/.docs/raw/reference/agents/generate.mdx +3 -2
- package/.docs/raw/reference/agents/stream.mdx +3 -2
- package/.docs/raw/reference/cli/dev.mdx +12 -0
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -4
- package/.docs/raw/reference/memory/Memory.mdx +12 -6
- package/.docs/raw/reference/workflows/create-run.mdx +4 -4
- package/.docs/raw/reference/workflows/sendEvent.mdx +49 -0
- package/.docs/raw/workflows/overview.mdx +1 -1
- package/.docs/raw/workflows/pausing-execution.mdx +74 -37
- package/package.json +5 -5
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# mastra
|
|
2
2
|
|
|
3
|
+
## 0.10.11-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ec77f83: Expose --inspect flag for mastra dev to start debugger
|
|
8
|
+
- 565cc0c: fix redirection when clicking on the playground breadcrumbs
|
|
9
|
+
- 4219597: add JSON input close to form input
|
|
10
|
+
- 2873c7f: dependencies updates:
|
|
11
|
+
- Updated dependency [`dotenv@^16.6.1` ↗︎](https://www.npmjs.com/package/dotenv/v/16.6.1) (from `^16.5.0`, in `dependencies`)
|
|
12
|
+
- Updated dependencies [2873c7f]
|
|
13
|
+
- Updated dependencies [1c1c6a1]
|
|
14
|
+
- Updated dependencies [2873c7f]
|
|
15
|
+
- Updated dependencies [1c1c6a1]
|
|
16
|
+
- Updated dependencies [d9b26b5]
|
|
17
|
+
- Updated dependencies [f5ec3a4]
|
|
18
|
+
- Updated dependencies [ab3bbff]
|
|
19
|
+
- Updated dependencies [565cc0c]
|
|
20
|
+
- Updated dependencies [18ca936]
|
|
21
|
+
- @mastra/core@0.10.11-alpha.2
|
|
22
|
+
- @mastra/deployer@0.10.11-alpha.2
|
|
23
|
+
- @mastra/mcp@0.10.6-alpha.0
|
|
24
|
+
|
|
25
|
+
## 0.10.11-alpha.1
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- a7a836a: Highlight send event button
|
|
30
|
+
- Updated dependencies [7f6e403]
|
|
31
|
+
- @mastra/core@0.10.11-alpha.1
|
|
32
|
+
- @mastra/deployer@0.10.11-alpha.1
|
|
33
|
+
|
|
34
|
+
## 0.10.11-alpha.0
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- af9e40e: Map log level number to string value
|
|
39
|
+
- a9f51e4: Fix plaground get tools not including x-mastra-dev-header"
|
|
40
|
+
- 3322d00: Fix tools watcher in dev
|
|
41
|
+
- b790fd1: Use SerializedStepFlowEntry in playground
|
|
42
|
+
- Updated dependencies [bc40cdd]
|
|
43
|
+
- Updated dependencies [f8ce2cc]
|
|
44
|
+
- Updated dependencies [8c846b6]
|
|
45
|
+
- Updated dependencies [b790fd1]
|
|
46
|
+
- Updated dependencies [d7ed04d]
|
|
47
|
+
- Updated dependencies [f36e4f1]
|
|
48
|
+
- @mastra/deployer@0.10.11-alpha.0
|
|
49
|
+
- @mastra/core@0.10.11-alpha.0
|
|
50
|
+
|
|
51
|
+
## 0.10.10
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 6997af1: add send event to server, deployer, client-js and playground-ui
|
|
56
|
+
- 4d3fbdf: Return tool error message rather than throw when a tool error happens for agent and tool playground page.
|
|
57
|
+
- Updated dependencies [6e13b80]
|
|
58
|
+
- Updated dependencies [25bf999]
|
|
59
|
+
- Updated dependencies [6997af1]
|
|
60
|
+
- Updated dependencies [4d3fbdf]
|
|
61
|
+
- @mastra/deployer@0.10.10
|
|
62
|
+
- @mastra/loggers@0.10.3
|
|
63
|
+
- @mastra/core@0.10.10
|
|
64
|
+
|
|
65
|
+
## 0.10.10-alpha.2
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [25bf999]
|
|
70
|
+
- @mastra/loggers@0.10.3-alpha.0
|
|
71
|
+
|
|
72
|
+
## 0.10.10-alpha.1
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- 6997af1: add send event to server, deployer, client-js and playground-ui
|
|
77
|
+
- Updated dependencies [6997af1]
|
|
78
|
+
- @mastra/deployer@0.10.10-alpha.1
|
|
79
|
+
- @mastra/core@0.10.10-alpha.1
|
|
80
|
+
|
|
3
81
|
## 0.10.10-alpha.0
|
|
4
82
|
|
|
5
83
|
### Patch Changes
|
|
@@ -220,83 +298,5 @@
|
|
|
220
298
|
|
|
221
299
|
## 0.10.7-alpha.1
|
|
222
300
|
|
|
223
|
-
### Patch Changes
|
|
224
|
-
|
|
225
|
-
- 21ffb97: Make dynamic form handle schema better
|
|
226
|
-
- Updated dependencies [d1baedb]
|
|
227
|
-
- Updated dependencies [4d21bf2]
|
|
228
|
-
- Updated dependencies [2097952]
|
|
229
|
-
- Updated dependencies [4fb0cc2]
|
|
230
|
-
- Updated dependencies [d2a7a31]
|
|
231
|
-
- Updated dependencies [0e17048]
|
|
232
|
-
- @mastra/core@0.10.7-alpha.1
|
|
233
|
-
- @mastra/mcp@0.10.5-alpha.0
|
|
234
|
-
- @mastra/deployer@0.10.7-alpha.1
|
|
235
|
-
|
|
236
|
-
## 0.10.7-alpha.0
|
|
237
|
-
|
|
238
|
-
### Patch Changes
|
|
239
|
-
|
|
240
|
-
- 9102d89: Fix final output not showing on playground for previously suspended steps
|
|
241
|
-
- Updated dependencies [d8f2d19]
|
|
242
|
-
- Updated dependencies [9d52b17]
|
|
243
|
-
- Updated dependencies [8ba1b51]
|
|
244
|
-
- @mastra/core@0.10.7-alpha.0
|
|
245
|
-
- @mastra/deployer@0.10.7-alpha.0
|
|
246
|
-
|
|
247
|
-
## 0.10.6
|
|
248
|
-
|
|
249
|
-
### Patch Changes
|
|
250
301
|
|
|
251
|
-
|
|
252
|
-
- 084f6aa: Add logs to circular dependency to warn people when starting server might break
|
|
253
|
-
- b29c802: Remove open browser
|
|
254
|
-
- 5f2aa3e: Move workflow hooks to playground
|
|
255
|
-
- 4051477: dependencies updates:
|
|
256
|
-
- Updated dependency [`@clack/prompts@^0.11.0` ↗︎](https://www.npmjs.com/package/@clack/prompts/v/0.11.0) (from `^0.8.2`, in `dependencies`)
|
|
257
|
-
- Updated dependency [`@opentelemetry/instrumentation@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/instrumentation/v/0.202.0) (from `^0.57.2`, in `dependencies`)
|
|
258
|
-
- Updated dependency [`posthog-node@4.18.0` ↗︎](https://www.npmjs.com/package/posthog-node/v/4.18.0) (from `4.16.0`, in `dependencies`)
|
|
259
|
-
- Updated dependency [`yocto-spinner@^0.2.3` ↗︎](https://www.npmjs.com/package/yocto-spinner/v/0.2.3) (from `^0.1.2`, in `dependencies`)
|
|
260
|
-
- Added dependency [`open@^10.1.2` ↗︎](https://www.npmjs.com/package/open/v/10.1.2) (to `dependencies`)
|
|
261
|
-
- b40f365: dependencies updates:
|
|
262
|
-
- Updated dependency [`@clack/prompts@^0.11.0` ↗︎](https://www.npmjs.com/package/@clack/prompts/v/0.11.0) (from `^0.8.2`, in `dependencies`)
|
|
263
|
-
- Updated dependency [`@opentelemetry/instrumentation@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/instrumentation/v/0.202.0) (from `^0.57.2`, in `dependencies`)
|
|
264
|
-
- Updated dependency [`posthog-node@4.18.0` ↗︎](https://www.npmjs.com/package/posthog-node/v/4.18.0) (from `4.16.0`, in `dependencies`)
|
|
265
|
-
- Updated dependency [`yocto-spinner@^0.2.3` ↗︎](https://www.npmjs.com/package/yocto-spinner/v/0.2.3) (from `^0.1.2`, in `dependencies`)
|
|
266
|
-
- 63f6b7d: dependencies updates:
|
|
267
|
-
- Updated dependency [`execa@^9.6.0` ↗︎](https://www.npmjs.com/package/execa/v/9.6.0) (from `^9.5.2`, in `dependencies`)
|
|
268
|
-
- Updated dependency [`json-schema-to-zod@^2.6.1` ↗︎](https://www.npmjs.com/package/json-schema-to-zod/v/2.6.1) (from `^2.6.0`, in `dependencies`)
|
|
269
|
-
- Updated dependency [`shell-quote@^1.8.3` ↗︎](https://www.npmjs.com/package/shell-quote/v/1.8.3) (from `^1.8.2`, in `dependencies`)
|
|
270
|
-
- Updated dependency [`strip-json-comments@^5.0.2` ↗︎](https://www.npmjs.com/package/strip-json-comments/v/5.0.2) (from `^5.0.1`, in `dependencies`)
|
|
271
|
-
- Updated dependency [`zod@^3.25.57` ↗︎](https://www.npmjs.com/package/zod/v/3.25.57) (from `^3.25.56`, in `dependencies`)
|
|
272
|
-
- 143b4e4: Fix globbing of tools to only capture js/ts files
|
|
273
|
-
- 44ba52d: Add proper error message when installation of mastra fails
|
|
274
|
-
- 311132e: move useWorkflow to playground instead of playground-ui
|
|
275
|
-
- 3270d9d: Fix runtime context being undefined
|
|
276
|
-
- 906f992: CLI error log
|
|
277
|
-
- 53d3c37: Get workflows from an agent if not found from Mastra instance #5083
|
|
278
|
-
- fc677d7: For final result for a workflow
|
|
279
|
-
- 47e7029: Add open browser functionality when running mastra dev
|
|
280
|
-
- Updated dependencies [63f6b7d]
|
|
281
|
-
- Updated dependencies [4051477]
|
|
282
|
-
- Updated dependencies [2d12edd]
|
|
283
|
-
- Updated dependencies [63f6b7d]
|
|
284
|
-
- Updated dependencies [c28ed65]
|
|
285
|
-
- Updated dependencies [63f6b7d]
|
|
286
|
-
- Updated dependencies [12a95fc]
|
|
287
|
-
- Updated dependencies [79b9909]
|
|
288
|
-
- Updated dependencies [4b0f8a6]
|
|
289
|
-
- Updated dependencies [51264a5]
|
|
290
|
-
- Updated dependencies [8e6f677]
|
|
291
|
-
- Updated dependencies [d70c420]
|
|
292
|
-
- Updated dependencies [ee9af57]
|
|
293
|
-
- Updated dependencies [ec7f824]
|
|
294
|
-
- Updated dependencies [36f1c36]
|
|
295
|
-
- Updated dependencies [084f6aa]
|
|
296
|
-
- Updated dependencies [2a16996]
|
|
297
|
-
- Updated dependencies [10d352e]
|
|
298
|
-
- Updated dependencies [9589624]
|
|
299
|
-
- Updated dependencies [bd1674f]
|
|
300
|
-
- Updated dependencies [69f76f7]
|
|
301
|
-
|
|
302
|
-
... 4141 more lines hidden. See full changelog in package directory.
|
|
302
|
+
... 4219 more lines hidden. See full changelog in package directory.
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"@mastra/memory": "latest",
|
|
11
11
|
"@mastra/pg": "latest",
|
|
12
12
|
"@next/env": "^15.2.2",
|
|
13
|
-
"@radix-ui/react-alert-dialog": "^1.1.
|
|
14
|
-
"@radix-ui/react-dialog": "^1.1.
|
|
15
|
-
"@radix-ui/react-dropdown-menu": "^2.1.
|
|
13
|
+
"@radix-ui/react-alert-dialog": "^1.1.14",
|
|
14
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
15
|
+
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
16
16
|
"@radix-ui/react-icons": "^1.3.2",
|
|
17
|
-
"@radix-ui/react-label": "^2.1.
|
|
18
|
-
"@radix-ui/react-select": "^2.
|
|
19
|
-
"@radix-ui/react-separator": "^1.1.
|
|
20
|
-
"@radix-ui/react-slot": "^1.
|
|
21
|
-
"@radix-ui/react-tooltip": "^1.
|
|
22
|
-
"@radix-ui/react-visually-hidden": "^1.
|
|
17
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
18
|
+
"@radix-ui/react-select": "^2.2.5",
|
|
19
|
+
"@radix-ui/react-separator": "^1.1.7",
|
|
20
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
21
|
+
"@radix-ui/react-tooltip": "^1.2.7",
|
|
22
|
+
"@radix-ui/react-visually-hidden": "^1.2.3",
|
|
23
23
|
"@typescript-eslint/parser": "^8.31.0",
|
|
24
24
|
"@vercel/analytics": "^1.5.0",
|
|
25
25
|
"@vercel/blob": "^1.0.0",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"@mastra/github": "latest",
|
|
10
10
|
"@mastra/loggers": "latest",
|
|
11
11
|
"@mastra/rag": "latest",
|
|
12
|
-
"@radix-ui/react-accordion": "^1.2.
|
|
13
|
-
"@radix-ui/react-dialog": "^1.1.
|
|
14
|
-
"@radix-ui/react-select": "^2.
|
|
15
|
-
"@radix-ui/react-slot": "^1.
|
|
12
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
13
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
14
|
+
"@radix-ui/react-select": "^2.2.5",
|
|
15
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
16
16
|
"class-variance-authority": "^0.7.1",
|
|
17
17
|
"clsx": "^2.1.1",
|
|
18
18
|
"lucide-react": "^0.454.0",
|
|
@@ -78,6 +78,22 @@ const client = new MastraClient({
|
|
|
78
78
|
});
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
## AbortSignal
|
|
82
|
+
|
|
83
|
+
The Mastra Client SDK supports request cancellation using the standard Web API `AbortSignal`. Pass an `AbortSignal` to the client constructor to enable cancellation for all requests:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const controller = new AbortController();
|
|
87
|
+
|
|
88
|
+
const client = new MastraClient({
|
|
89
|
+
baseUrl: "http://localhost:4111",
|
|
90
|
+
abortSignal: controller.signal,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Cancel all requests from this client
|
|
94
|
+
controller.abort();
|
|
95
|
+
```
|
|
96
|
+
|
|
81
97
|
## Example
|
|
82
98
|
|
|
83
99
|
Once your MastraClient is initialized you can start making client calls via the type-safe
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "AWS Lambda"
|
|
3
|
+
description: "Deploy your Mastra applications to AWS Lambda using Docker containers and the AWS Lambda Web Adapter."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Callout, Steps } from "nextra/components";
|
|
7
|
+
|
|
8
|
+
## AWS Lambda
|
|
9
|
+
|
|
10
|
+
Deploy your Mastra applications to AWS Lambda using Docker containers and the AWS Lambda Web Adapter.
|
|
11
|
+
This approach allows you to run your Mastra server as a containerized Lambda function with automatic scaling.
|
|
12
|
+
|
|
13
|
+
<Callout>
|
|
14
|
+
This guide assumes your Mastra application has been created using the default
|
|
15
|
+
`npx create-mastra@latest` command.
|
|
16
|
+
For more information on how to create a new Mastra application,
|
|
17
|
+
refer to our [getting started guide](/docs/getting-started/installation)
|
|
18
|
+
</Callout>
|
|
19
|
+
|
|
20
|
+
### Prerequisites
|
|
21
|
+
|
|
22
|
+
Before deploying to AWS Lambda, ensure you have:
|
|
23
|
+
|
|
24
|
+
- [AWS CLI](https://aws.amazon.com/cli/) installed and configured
|
|
25
|
+
- [Docker](https://www.docker.com/) installed and running
|
|
26
|
+
- An AWS account with appropriate permissions for Lambda, ECR, and IAM
|
|
27
|
+
- Your Mastra application configured with appropriate memory storage
|
|
28
|
+
|
|
29
|
+
### Memory Configuration
|
|
30
|
+
|
|
31
|
+
<Callout>
|
|
32
|
+
AWS Lambda uses an ephemeral file system,
|
|
33
|
+
meaning that any files written to the file system are short-lived and may be lost.
|
|
34
|
+
Avoid using a Mastra storage provider that uses the file system,
|
|
35
|
+
such as `LibSQLStore` with a file URL.
|
|
36
|
+
</Callout>
|
|
37
|
+
|
|
38
|
+
Lambda functions have limitations with file system storage. Configure your Mastra application to use either in-memory or external storage providers:
|
|
39
|
+
|
|
40
|
+
#### Option 1: In-Memory (Simplest)
|
|
41
|
+
|
|
42
|
+
```typescript filename="src/mastra/index.ts" copy showLineNumbers
|
|
43
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
44
|
+
|
|
45
|
+
const storage = new LibSQLStore({
|
|
46
|
+
url: ":memory:", // in-memory storage
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Option 2: External Storage Providers
|
|
51
|
+
|
|
52
|
+
For persistent memory across Lambda invocations, use external storage providers like `LibSQLStore` with Turso or other storage providers like `PostgreStore`:
|
|
53
|
+
|
|
54
|
+
```typescript filename="src/mastra/index.ts" copy showLineNumbers
|
|
55
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
56
|
+
|
|
57
|
+
const storage = new LibSQLStore({
|
|
58
|
+
url: "libsql://your-database.turso.io", // External Turso database
|
|
59
|
+
authToken: process.env.TURSO_AUTH_TOKEN,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
For more memory configuration options, see the [Memory documentation](/docs/memory/overview).
|
|
64
|
+
|
|
65
|
+
### Creating a Dockerfile
|
|
66
|
+
|
|
67
|
+
<Steps>
|
|
68
|
+
|
|
69
|
+
#### Create a Dockerfile in your project root
|
|
70
|
+
|
|
71
|
+
Create a `Dockerfile` in your Mastra project root directory:
|
|
72
|
+
|
|
73
|
+
```dockerfile filename="Dockerfile" copy showLineNumbers
|
|
74
|
+
FROM node:22-alpine
|
|
75
|
+
|
|
76
|
+
WORKDIR /app
|
|
77
|
+
COPY package*.json ./
|
|
78
|
+
RUN npm ci
|
|
79
|
+
COPY src ./src
|
|
80
|
+
RUN npx mastra build
|
|
81
|
+
RUN apk add --no-cache gcompat
|
|
82
|
+
|
|
83
|
+
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.9.0 /lambda-adapter /opt/extensions/lambda-adapter
|
|
84
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
85
|
+
adduser -S mastra -u 1001 && \
|
|
86
|
+
chown -R mastra:nodejs /app
|
|
87
|
+
|
|
88
|
+
USER mastra
|
|
89
|
+
|
|
90
|
+
ENV PORT=8080
|
|
91
|
+
ENV NODE_ENV=production
|
|
92
|
+
ENV READINESS_CHECK_PATH="/api"
|
|
93
|
+
|
|
94
|
+
EXPOSE 8080
|
|
95
|
+
|
|
96
|
+
CMD ["node", "--import=./.mastra/output/instrumentation.mjs", ".mastra/output/index.mjs"]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
</Steps>
|
|
100
|
+
|
|
101
|
+
### Building and Deploying
|
|
102
|
+
|
|
103
|
+
<Steps>
|
|
104
|
+
|
|
105
|
+
#### Set up environment variables
|
|
106
|
+
|
|
107
|
+
Set up your environment variables for the deployment process:
|
|
108
|
+
|
|
109
|
+
```bash copy
|
|
110
|
+
export PROJECT_NAME="your-mastra-app"
|
|
111
|
+
export AWS_REGION="us-east-1"
|
|
112
|
+
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Build the Docker image
|
|
116
|
+
|
|
117
|
+
Build your Docker image locally:
|
|
118
|
+
|
|
119
|
+
```bash copy
|
|
120
|
+
docker build -t "$PROJECT_NAME" .
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Create an ECR repository
|
|
124
|
+
|
|
125
|
+
Create an Amazon ECR repository to store your Docker image:
|
|
126
|
+
|
|
127
|
+
```bash copy
|
|
128
|
+
aws ecr create-repository --repository-name "$PROJECT_NAME" --region "$AWS_REGION"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Authenticate Docker with ECR
|
|
132
|
+
|
|
133
|
+
Log in to Amazon ECR:
|
|
134
|
+
|
|
135
|
+
```bash copy
|
|
136
|
+
aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Tag and push the image
|
|
140
|
+
|
|
141
|
+
Tag your image with the ECR repository URI and push it:
|
|
142
|
+
|
|
143
|
+
```bash copy
|
|
144
|
+
docker tag "$PROJECT_NAME":latest "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$PROJECT_NAME":latest
|
|
145
|
+
docker push "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$PROJECT_NAME":latest
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Create the Lambda function
|
|
149
|
+
|
|
150
|
+
Create a Lambda function using the AWS Console:
|
|
151
|
+
|
|
152
|
+
1. Navigate to the [AWS Lambda Console](https://console.aws.amazon.com/lambda/)
|
|
153
|
+
2. Click **Create function**
|
|
154
|
+
3. Select **Container image**
|
|
155
|
+
4. Configure the function:
|
|
156
|
+
- **Function name**: Your function name (e.g., `mastra-app`)
|
|
157
|
+
- **Container image URI**: Click **Browse images** and select your ECR repository, then choose the `latest` tag
|
|
158
|
+
- **Architecture**: Select the architecture that matches your Docker build (typically `x86_64`)
|
|
159
|
+
|
|
160
|
+
#### Configure Function URL
|
|
161
|
+
|
|
162
|
+
Enable Function URL for external access:
|
|
163
|
+
|
|
164
|
+
1. In the Lambda function configuration, go to **Configuration** > **Function URL**
|
|
165
|
+
2. Click **Create function URL**
|
|
166
|
+
3. Set **Auth type** to **NONE** (for public access)
|
|
167
|
+
4. Configure **CORS** settings:
|
|
168
|
+
- **Allow-Origin**: `*` (restrict to your domain in production)
|
|
169
|
+
- **Allow-Headers**: `content-type`
|
|
170
|
+
- **Allow-Methods**: `*` (audit and restrict in production)
|
|
171
|
+
5. Click **Save**
|
|
172
|
+
|
|
173
|
+
#### Configure environment variables
|
|
174
|
+
|
|
175
|
+
Add your environment variables in the Lambda function configuration:
|
|
176
|
+
|
|
177
|
+
1. Go to **Configuration** > **Environment variables**
|
|
178
|
+
2. Add the required variables for your Mastra application:
|
|
179
|
+
- `OPENAI_API_KEY`: Your OpenAI API key (if using OpenAI)
|
|
180
|
+
- `ANTHROPIC_API_KEY`: Your Anthropic API key (if using Anthropic)
|
|
181
|
+
- `TURSO_AUTH_TOKEN`: Your Turso auth token (if using LibSQL with Turso)
|
|
182
|
+
- Other provider-specific API keys as needed
|
|
183
|
+
|
|
184
|
+
#### Adjust function settings
|
|
185
|
+
|
|
186
|
+
Configure the function's memory and timeout settings:
|
|
187
|
+
|
|
188
|
+
1. Go to **Configuration** > **General configuration**
|
|
189
|
+
2. Set the following recommended values:
|
|
190
|
+
- **Memory**: 512 MB (adjust based on your application needs)
|
|
191
|
+
- **Timeout**: 30 seconds (adjust based on your application needs)
|
|
192
|
+
- **Ephemeral storage**: 512 MB (optional, for temporary files)
|
|
193
|
+
|
|
194
|
+
</Steps>
|
|
195
|
+
|
|
196
|
+
### Testing your deployment
|
|
197
|
+
|
|
198
|
+
Once deployed, test your Lambda function:
|
|
199
|
+
|
|
200
|
+
1. Copy the **Function URL** from the Lambda console
|
|
201
|
+
2. Visit the URL in your browser to see your Mastra's server home screen
|
|
202
|
+
3. Test your agents and workflows using the generated API endpoints
|
|
203
|
+
|
|
204
|
+
For more information about available API endpoints, see the [Server documentation](/docs/deployment/server).
|
|
205
|
+
|
|
206
|
+
### Connecting your client
|
|
207
|
+
|
|
208
|
+
Update your client application to use the Lambda function URL:
|
|
209
|
+
|
|
210
|
+
```typescript filename="src/client.ts" copy showLineNumbers
|
|
211
|
+
import { MastraClient } from "@mastra/client-js";
|
|
212
|
+
|
|
213
|
+
const mastraClient = new MastraClient({
|
|
214
|
+
baseUrl: "https://your-function-url.lambda-url.us-east-1.on.aws",
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Troubleshooting
|
|
219
|
+
|
|
220
|
+
#### Function timeout errors
|
|
221
|
+
|
|
222
|
+
If your Lambda function times out:
|
|
223
|
+
|
|
224
|
+
- Increase the timeout value in **Configuration** > **General configuration**
|
|
225
|
+
- Optimize your Mastra application for faster cold starts
|
|
226
|
+
- Consider using provisioned concurrency for consistent performance
|
|
227
|
+
|
|
228
|
+
#### Memory issues
|
|
229
|
+
|
|
230
|
+
If you encounter memory-related errors:
|
|
231
|
+
|
|
232
|
+
- Increase the memory allocation in **Configuration** > **General configuration**
|
|
233
|
+
- Monitor memory usage in CloudWatch Logs
|
|
234
|
+
- Optimize your application's memory usage
|
|
235
|
+
|
|
236
|
+
#### CORS issues
|
|
237
|
+
|
|
238
|
+
If you encounter CORS errors when accessing endpoints but not the home page:
|
|
239
|
+
|
|
240
|
+
- Verify CORS headers are properly set in your Mastra server configuration
|
|
241
|
+
- Check the Lambda Function URL CORS configuration
|
|
242
|
+
- Ensure your client is making requests to the correct URL
|
|
243
|
+
|
|
244
|
+
#### Container image issues
|
|
245
|
+
|
|
246
|
+
If the Lambda function fails to start:
|
|
247
|
+
|
|
248
|
+
- Verify the Docker image builds successfully locally
|
|
249
|
+
- Check that the `CMD` instruction in your Dockerfile is correct
|
|
250
|
+
- Review CloudWatch Logs for container startup errors
|
|
251
|
+
- Ensure the Lambda Web Adapter is properly installed in the container
|
|
252
|
+
|
|
253
|
+
### Production considerations
|
|
254
|
+
|
|
255
|
+
For production deployments:
|
|
256
|
+
|
|
257
|
+
#### Security
|
|
258
|
+
|
|
259
|
+
- Restrict CORS origins to your trusted domains
|
|
260
|
+
- Use AWS IAM roles for secure access to other AWS services
|
|
261
|
+
- Store sensitive environment variables in AWS Secrets Manager or Parameter Store
|
|
262
|
+
|
|
263
|
+
#### Monitoring
|
|
264
|
+
|
|
265
|
+
- Enable CloudWatch monitoring for your Lambda function
|
|
266
|
+
- Set up CloudWatch alarms for errors and performance metrics
|
|
267
|
+
- Use AWS X-Ray for distributed tracing
|
|
268
|
+
|
|
269
|
+
#### Scaling
|
|
270
|
+
|
|
271
|
+
- Configure provisioned concurrency for predictable performance
|
|
272
|
+
- Monitor concurrent executions and adjust limits as needed
|
|
273
|
+
- Consider using Application Load Balancer for more complex routing needs
|
|
274
|
+
|
|
275
|
+
## Next steps
|
|
276
|
+
|
|
277
|
+
- [Mastra Client SDK](/docs/client-js/overview)
|
|
278
|
+
- [AWS Lambda documentation](https://docs.aws.amazon.com/lambda/)
|
|
279
|
+
- [AWS Lambda Web Adapter](https://github.com/awslabs/aws-lambda-web-adapter)
|
|
@@ -30,7 +30,6 @@ Before you begin, ensure you have:
|
|
|
30
30
|
|
|
31
31
|
Specifically, ensure you've removed it from both `src/mastra/index.ts` and `src/mastra/agents/weather-agent.ts`:
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
```diff filename="src/mastra/index.ts" showLineNumbers
|
|
35
34
|
export const mastra = new Mastra({
|
|
36
35
|
// ...
|
|
@@ -189,6 +189,103 @@ export default function Page() {
|
|
|
189
189
|
}
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
+
### With additional data / RuntimeContext
|
|
193
|
+
|
|
194
|
+
You can send additional data via the UI hooks that can be leveraged in Mastra as RuntimeContext using the `sendExtraMessageFields` option.
|
|
195
|
+
|
|
196
|
+
#### Frontend: Using sendExtraMessageFields
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { useChat } from '@ai-sdk/react';
|
|
200
|
+
|
|
201
|
+
export function ChatComponent() {
|
|
202
|
+
const { messages, input, handleInputChange, handleSubmit } = useChat({
|
|
203
|
+
api: '/api/chat',
|
|
204
|
+
sendExtraMessageFields: true, // Enable sending extra fields
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const handleFormSubmit = (e: React.FormEvent) => {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
handleSubmit(e,{
|
|
210
|
+
// Add context data to the message
|
|
211
|
+
data: {
|
|
212
|
+
userId: 'user123',
|
|
213
|
+
preferences: { language: 'en', temperature: 'celsius' },
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<form onSubmit={handleFormSubmit}>
|
|
220
|
+
<input value={input} onChange={handleInputChange} />
|
|
221
|
+
</form>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### Backend: Handling in API Route
|
|
227
|
+
|
|
228
|
+
```typescript filename="app/api/chat/route.ts" copy
|
|
229
|
+
import { mastra } from "@/src/mastra";
|
|
230
|
+
import { RuntimeContext } from "@mastra/core/runtime-context";
|
|
231
|
+
|
|
232
|
+
export async function POST(req: Request) {
|
|
233
|
+
const { messages, data } = await req.json();
|
|
234
|
+
const myAgent = mastra.getAgent("weatherAgent");
|
|
235
|
+
|
|
236
|
+
const runtimeContext = new RuntimeContext();
|
|
237
|
+
|
|
238
|
+
if (data) {
|
|
239
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
240
|
+
runtimeContext.set(key, value);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const stream = await myAgent.stream(messages, { runtimeContext });
|
|
245
|
+
return stream.toDataStreamResponse();
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Alternative: Server Middleware
|
|
250
|
+
|
|
251
|
+
You can also handle this at the server middleware level:
|
|
252
|
+
|
|
253
|
+
```typescript filename="src/mastra/index.ts" copy
|
|
254
|
+
import { Mastra } from "@mastra/core";
|
|
255
|
+
|
|
256
|
+
export const mastra = new Mastra({
|
|
257
|
+
agents: { weatherAgent },
|
|
258
|
+
server: {
|
|
259
|
+
middleware: [
|
|
260
|
+
async (c, next) => {
|
|
261
|
+
const runtimeContext = c.get("runtimeContext");
|
|
262
|
+
|
|
263
|
+
if (c.req.method === 'POST') {
|
|
264
|
+
try {
|
|
265
|
+
// Clone the request since reading the body can only be done once
|
|
266
|
+
const clonedReq = c.req.raw.clone();
|
|
267
|
+
const body = await clonedReq.json();
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
if (body?.data) {
|
|
271
|
+
Object.entries(body.data).forEach(([key, value]) => {
|
|
272
|
+
runtimeContext.set(key, value);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
} catch {
|
|
276
|
+
// Continue without additional data
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
await next();
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
You can then access this data in your tools via the `runtimeContext` parameter. See the [Runtime Context documentation](/docs/agents/runtime-variables) for more details.
|
|
288
|
+
|
|
192
289
|
## Tool Calling
|
|
193
290
|
|
|
194
291
|
### AI SDK Tool Format
|