@mastra/mcp-docs-server 0.13.11 → 0.13.12-alpha.1
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 +19 -19
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +42 -42
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Flance.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Frag.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +8 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +14 -0
- package/.docs/organized/changelogs/create-mastra.md +26 -26
- package/.docs/organized/changelogs/mastra.md +63 -63
- package/.docs/organized/code-examples/agent.md +292 -275
- package/.docs/raw/agents/input-processors.mdx +25 -19
- package/.docs/raw/agents/output-processors.mdx +376 -0
- package/.docs/raw/agents/overview.mdx +165 -188
- package/.docs/raw/agents/streaming.mdx +11 -5
- package/.docs/raw/community/contributing-templates.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +9 -9
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +27 -33
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +12 -12
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +17 -17
- package/.docs/raw/getting-started/templates.mdx +1 -1
- package/.docs/raw/rag/vector-databases.mdx +9 -1
- package/.docs/raw/reference/agents/agent.mdx +9 -3
- package/.docs/raw/reference/agents/generate.mdx +80 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultVNextStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/streamVNext.mdx +88 -5
- package/.docs/raw/reference/cli/scorers.mdx +160 -0
- package/.docs/raw/reference/rag/chroma.mdx +158 -17
- package/.docs/raw/reference/templates.mdx +3 -3
- package/.docs/raw/reference/tools/create-tool.mdx +2 -2
- package/.docs/raw/reference/tools/mcp-client.mdx +9 -9
- package/.docs/raw/reference/tools/mcp-server.mdx +5 -5
- package/.docs/raw/reference/workflows/branch.mdx +1 -1
- package/.docs/raw/reference/workflows/create-run.mdx +4 -4
- package/.docs/raw/reference/workflows/execute.mdx +2 -2
- package/.docs/raw/reference/workflows/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +58 -0
- package/.docs/raw/reference/workflows/{resume.mdx → run-methods/resume.mdx} +7 -5
- package/.docs/raw/reference/workflows/{start.mdx → run-methods/start.mdx} +5 -5
- package/.docs/raw/reference/workflows/{stream.mdx → run-methods/stream.mdx} +6 -3
- package/.docs/raw/reference/workflows/{streamVNext.mdx → run-methods/streamVNext.mdx} +14 -9
- package/.docs/raw/reference/workflows/{watch.mdx → run-methods/watch.mdx} +12 -12
- package/.docs/raw/reference/workflows/run.mdx +104 -0
- package/.docs/raw/reference/workflows/step.mdx +0 -1
- package/.docs/raw/reference/workflows/workflow.mdx +3 -2
- package/.docs/raw/{reference/workflows → server-db}/snapshots.mdx +2 -2
- package/.docs/raw/voice/overview.mdx +81 -2
- package/.docs/raw/voice/speech-to-speech.mdx +45 -0
- package/.docs/raw/workflows/overview.mdx +11 -4
- package/.docs/raw/workflows-legacy/overview.mdx +8 -8
- package/package.json +4 -4
|
@@ -5,7 +5,7 @@ description: "Deploy your Mastra applications to AWS Lambda using Docker contain
|
|
|
5
5
|
|
|
6
6
|
import { Callout, Steps } from "nextra/components";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# AWS Lambda
|
|
9
9
|
|
|
10
10
|
Deploy your Mastra applications to AWS Lambda using Docker containers and the AWS Lambda Web Adapter.
|
|
11
11
|
This approach allows you to run your Mastra server as a containerized Lambda function with automatic scaling.
|
|
@@ -17,7 +17,7 @@ This approach allows you to run your Mastra server as a containerized Lambda fun
|
|
|
17
17
|
refer to our [getting started guide](/docs/getting-started/installation)
|
|
18
18
|
</Callout>
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
## Prerequisites
|
|
21
21
|
|
|
22
22
|
Before deploying to AWS Lambda, ensure you have:
|
|
23
23
|
|
|
@@ -26,7 +26,7 @@ Before deploying to AWS Lambda, ensure you have:
|
|
|
26
26
|
- An AWS account with appropriate permissions for Lambda, ECR, and IAM
|
|
27
27
|
- Your Mastra application configured with appropriate memory storage
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
## Memory Configuration
|
|
30
30
|
|
|
31
31
|
<Callout>
|
|
32
32
|
AWS Lambda uses an ephemeral file system,
|
|
@@ -37,7 +37,7 @@ Before deploying to AWS Lambda, ensure you have:
|
|
|
37
37
|
|
|
38
38
|
Lambda functions have limitations with file system storage. Configure your Mastra application to use either in-memory or external storage providers:
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### Option 1: In-Memory (Simplest)
|
|
41
41
|
|
|
42
42
|
```typescript filename="src/mastra/index.ts" copy showLineNumbers
|
|
43
43
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -47,7 +47,7 @@ const storage = new LibSQLStore({
|
|
|
47
47
|
});
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
### Option 2: External Storage Providers
|
|
51
51
|
|
|
52
52
|
For persistent memory across Lambda invocations, use external storage providers like `LibSQLStore` with Turso or other storage providers like `PostgreStore`:
|
|
53
53
|
|
|
@@ -62,11 +62,7 @@ const storage = new LibSQLStore({
|
|
|
62
62
|
|
|
63
63
|
For more memory configuration options, see the [Memory documentation](/docs/memory/overview).
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<Steps>
|
|
68
|
-
|
|
69
|
-
#### Create a Dockerfile in your project root
|
|
65
|
+
## Creating a Dockerfile
|
|
70
66
|
|
|
71
67
|
Create a `Dockerfile` in your Mastra project root directory:
|
|
72
68
|
|
|
@@ -96,13 +92,11 @@ EXPOSE 8080
|
|
|
96
92
|
CMD ["node", "--import=./.mastra/output/instrumentation.mjs", ".mastra/output/index.mjs"]
|
|
97
93
|
```
|
|
98
94
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
### Building and Deploying
|
|
95
|
+
## Building and Deploying
|
|
102
96
|
|
|
103
97
|
<Steps>
|
|
104
98
|
|
|
105
|
-
|
|
99
|
+
### Set up environment variables
|
|
106
100
|
|
|
107
101
|
Set up your environment variables for the deployment process:
|
|
108
102
|
|
|
@@ -112,7 +106,7 @@ export AWS_REGION="us-east-1"
|
|
|
112
106
|
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
113
107
|
```
|
|
114
108
|
|
|
115
|
-
|
|
109
|
+
### Build the Docker image
|
|
116
110
|
|
|
117
111
|
Build your Docker image locally:
|
|
118
112
|
|
|
@@ -120,7 +114,7 @@ Build your Docker image locally:
|
|
|
120
114
|
docker build -t "$PROJECT_NAME" .
|
|
121
115
|
```
|
|
122
116
|
|
|
123
|
-
|
|
117
|
+
### Create an ECR repository
|
|
124
118
|
|
|
125
119
|
Create an Amazon ECR repository to store your Docker image:
|
|
126
120
|
|
|
@@ -128,7 +122,7 @@ Create an Amazon ECR repository to store your Docker image:
|
|
|
128
122
|
aws ecr create-repository --repository-name "$PROJECT_NAME" --region "$AWS_REGION"
|
|
129
123
|
```
|
|
130
124
|
|
|
131
|
-
|
|
125
|
+
### Authenticate Docker with ECR
|
|
132
126
|
|
|
133
127
|
Log in to Amazon ECR:
|
|
134
128
|
|
|
@@ -136,7 +130,7 @@ Log in to Amazon ECR:
|
|
|
136
130
|
aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com"
|
|
137
131
|
```
|
|
138
132
|
|
|
139
|
-
|
|
133
|
+
### Tag and push the image
|
|
140
134
|
|
|
141
135
|
Tag your image with the ECR repository URI and push it:
|
|
142
136
|
|
|
@@ -145,7 +139,7 @@ docker tag "$PROJECT_NAME":latest "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws
|
|
|
145
139
|
docker push "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$PROJECT_NAME":latest
|
|
146
140
|
```
|
|
147
141
|
|
|
148
|
-
|
|
142
|
+
### Create the Lambda function
|
|
149
143
|
|
|
150
144
|
Create a Lambda function using the AWS Console:
|
|
151
145
|
|
|
@@ -157,7 +151,7 @@ Create a Lambda function using the AWS Console:
|
|
|
157
151
|
- **Container image URI**: Click **Browse images** and select your ECR repository, then choose the `latest` tag
|
|
158
152
|
- **Architecture**: Select the architecture that matches your Docker build (typically `x86_64`)
|
|
159
153
|
|
|
160
|
-
|
|
154
|
+
### Configure Function URL
|
|
161
155
|
|
|
162
156
|
Enable Function URL for external access:
|
|
163
157
|
|
|
@@ -170,7 +164,7 @@ Enable Function URL for external access:
|
|
|
170
164
|
- **Allow-Methods**: `*` (audit and restrict in production)
|
|
171
165
|
5. Click **Save**
|
|
172
166
|
|
|
173
|
-
|
|
167
|
+
### Configure environment variables
|
|
174
168
|
|
|
175
169
|
Add your environment variables in the Lambda function configuration:
|
|
176
170
|
|
|
@@ -181,7 +175,7 @@ Add your environment variables in the Lambda function configuration:
|
|
|
181
175
|
- `TURSO_AUTH_TOKEN`: Your Turso auth token (if using LibSQL with Turso)
|
|
182
176
|
- Other provider-specific API keys as needed
|
|
183
177
|
|
|
184
|
-
|
|
178
|
+
### Adjust function settings
|
|
185
179
|
|
|
186
180
|
Configure the function's memory and timeout settings:
|
|
187
181
|
|
|
@@ -193,7 +187,7 @@ Configure the function's memory and timeout settings:
|
|
|
193
187
|
|
|
194
188
|
</Steps>
|
|
195
189
|
|
|
196
|
-
|
|
190
|
+
## Testing your deployment
|
|
197
191
|
|
|
198
192
|
Once deployed, test your Lambda function:
|
|
199
193
|
|
|
@@ -203,7 +197,7 @@ Once deployed, test your Lambda function:
|
|
|
203
197
|
|
|
204
198
|
For more information about available API endpoints, see the [Server documentation](/docs/deployment/server).
|
|
205
199
|
|
|
206
|
-
|
|
200
|
+
## Connecting your client
|
|
207
201
|
|
|
208
202
|
Update your client application to use the Lambda function URL:
|
|
209
203
|
|
|
@@ -215,9 +209,9 @@ const mastraClient = new MastraClient({
|
|
|
215
209
|
});
|
|
216
210
|
```
|
|
217
211
|
|
|
218
|
-
|
|
212
|
+
## Troubleshooting
|
|
219
213
|
|
|
220
|
-
|
|
214
|
+
### Function timeout errors
|
|
221
215
|
|
|
222
216
|
If your Lambda function times out:
|
|
223
217
|
|
|
@@ -225,7 +219,7 @@ If your Lambda function times out:
|
|
|
225
219
|
- Optimize your Mastra application for faster cold starts
|
|
226
220
|
- Consider using provisioned concurrency for consistent performance
|
|
227
221
|
|
|
228
|
-
|
|
222
|
+
### Memory issues
|
|
229
223
|
|
|
230
224
|
If you encounter memory-related errors:
|
|
231
225
|
|
|
@@ -233,7 +227,7 @@ If you encounter memory-related errors:
|
|
|
233
227
|
- Monitor memory usage in CloudWatch Logs
|
|
234
228
|
- Optimize your application's memory usage
|
|
235
229
|
|
|
236
|
-
|
|
230
|
+
### CORS issues
|
|
237
231
|
|
|
238
232
|
If you encounter CORS errors when accessing endpoints but not the home page:
|
|
239
233
|
|
|
@@ -241,7 +235,7 @@ If you encounter CORS errors when accessing endpoints but not the home page:
|
|
|
241
235
|
- Check the Lambda Function URL CORS configuration
|
|
242
236
|
- Ensure your client is making requests to the correct URL
|
|
243
237
|
|
|
244
|
-
|
|
238
|
+
### Container image issues
|
|
245
239
|
|
|
246
240
|
If the Lambda function fails to start:
|
|
247
241
|
|
|
@@ -250,23 +244,23 @@ If the Lambda function fails to start:
|
|
|
250
244
|
- Review CloudWatch Logs for container startup errors
|
|
251
245
|
- Ensure the Lambda Web Adapter is properly installed in the container
|
|
252
246
|
|
|
253
|
-
|
|
247
|
+
## Production considerations
|
|
254
248
|
|
|
255
249
|
For production deployments:
|
|
256
250
|
|
|
257
|
-
|
|
251
|
+
### Security
|
|
258
252
|
|
|
259
253
|
- Restrict CORS origins to your trusted domains
|
|
260
254
|
- Use AWS IAM roles for secure access to other AWS services
|
|
261
255
|
- Store sensitive environment variables in AWS Secrets Manager or Parameter Store
|
|
262
256
|
|
|
263
|
-
|
|
257
|
+
### Monitoring
|
|
264
258
|
|
|
265
259
|
- Enable CloudWatch monitoring for your Lambda function
|
|
266
260
|
- Set up CloudWatch alarms for errors and performance metrics
|
|
267
261
|
- Use AWS X-Ray for distributed tracing
|
|
268
262
|
|
|
269
|
-
|
|
263
|
+
### Scaling
|
|
270
264
|
|
|
271
265
|
- Configure provisioned concurrency for predictable performance
|
|
272
266
|
- Monitor concurrent executions and adjust limits as needed
|
|
@@ -5,7 +5,7 @@ description: "Deploy your Mastra applications to Azure App Services."
|
|
|
5
5
|
|
|
6
6
|
import { Callout, Steps } from "nextra/components";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# Azure App Services
|
|
9
9
|
|
|
10
10
|
Deploy your Mastra applications to Azure App Services.
|
|
11
11
|
|
|
@@ -16,24 +16,24 @@ Deploy your Mastra applications to Azure App Services.
|
|
|
16
16
|
refer to our [getting started guide](/docs/getting-started/installation)
|
|
17
17
|
</Callout>
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Prerequisites
|
|
20
20
|
|
|
21
21
|
- An [Azure account](https://azure.microsoft.com/) with an active subscription
|
|
22
22
|
- A [GitHub repository](https://github.com/) containing your Mastra application
|
|
23
23
|
- Your Mastra application should be created using `npx create-mastra@latest`
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## Deployment Steps
|
|
26
26
|
|
|
27
27
|
<Steps>
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### Create a new App Service
|
|
30
30
|
|
|
31
31
|
- Log in to the [Azure Portal](https://portal.azure.com)
|
|
32
32
|
- Navigate to **[App Services](https://docs.microsoft.com/en-us/azure/app-service/)** or search for it in the top search bar
|
|
33
33
|
- Click **Create** to create a new App Service
|
|
34
34
|
- In the drop-down, select **Web App**
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
### Configure App Service settings
|
|
37
37
|
|
|
38
38
|
- **Subscription**: Select your Azure subscription
|
|
39
39
|
- **Resource Group**: Create a new resource group or select an existing one
|
|
@@ -46,12 +46,12 @@ Deploy your Mastra applications to Azure App Services.
|
|
|
46
46
|
- Click **Review + Create**
|
|
47
47
|
- Wait for validation to complete, then click **Create**
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
### Wait for deployment
|
|
50
50
|
|
|
51
51
|
- Wait for the deployment to complete
|
|
52
52
|
- Once finished, click **Go to resource** under the next steps section
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
### Configure environment variables
|
|
55
55
|
|
|
56
56
|
Before setting up deployment, configure your environment variables:
|
|
57
57
|
|
|
@@ -62,7 +62,7 @@ Before setting up deployment, configure your environment variables:
|
|
|
62
62
|
- Any other configuration values your Mastra application requires
|
|
63
63
|
- Click **Apply** to save the changes
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
### Set up GitHub deployment
|
|
66
66
|
|
|
67
67
|
- Navigate to **Deployment Center** in the left sidebar
|
|
68
68
|
- Select **GitHub** as your source
|
|
@@ -72,7 +72,7 @@ Before setting up deployment, configure your environment variables:
|
|
|
72
72
|
- Azure will generate a GitHub workflow file and you can preview it before proceeding
|
|
73
73
|
- Click **Save** (the save button is located at the top of the page)
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
### Modify the GitHub workflow
|
|
76
76
|
|
|
77
77
|
<Callout type="warning">
|
|
78
78
|
The default workflow generated by Azure will fail for Mastra applications and needs to be modified.
|
|
@@ -94,13 +94,13 @@ Pull the latest changes to your local repository and modify the generated workfl
|
|
|
94
94
|
|
|
95
95
|
This ensures only the build outputs from `.mastra/output` are included in the deployment package.
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
### Deploy your changes
|
|
98
98
|
|
|
99
99
|
- Commit and push your workflow modifications
|
|
100
100
|
- The build will be automatically triggered in the **Deployment Center** in your Azure dashboard
|
|
101
101
|
- Monitor the deployment progress until it completes successfully
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
### Access your application
|
|
104
104
|
|
|
105
105
|
- Once the build is successful, wait a few moments for the application to start
|
|
106
106
|
- Access your deployed application using the default URL provided in the **Overview** tab in the Azure portal
|
|
@@ -108,7 +108,7 @@ Pull the latest changes to your local repository and modify the generated workfl
|
|
|
108
108
|
|
|
109
109
|
</Steps>
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
## Connect to your Mastra server
|
|
112
112
|
|
|
113
113
|
You can now connect to your Mastra server from your client application using a `MastraClient` from the `@mastra/client-js` package.
|
|
114
114
|
|
|
@@ -5,7 +5,7 @@ description: "Deploy your Mastra applications to Digital Ocean."
|
|
|
5
5
|
|
|
6
6
|
import { Callout, Steps, Tabs } from "nextra/components";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# Digital Ocean
|
|
9
9
|
|
|
10
10
|
Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
|
|
11
11
|
|
|
@@ -20,31 +20,31 @@ Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
|
|
|
20
20
|
|
|
21
21
|
<Tabs.Tab>
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## App Platform
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### Prerequisites [#app-platform-prerequisites]
|
|
26
26
|
|
|
27
27
|
- A Git repository containing your Mastra application. This can be a [GitHub](https://github.com/) repository, [GitLab](https://gitlab.com/) repository, or any other compatible source provider.
|
|
28
28
|
- A [Digital Ocean account](https://www.digitalocean.com/)
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
### Deployment Steps
|
|
31
31
|
|
|
32
32
|
<Steps>
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
### Create a new App
|
|
35
35
|
|
|
36
36
|
- Log in to your [Digital Ocean dashboard](https://cloud.digitalocean.com/).
|
|
37
37
|
- Navigate to the [App Platform](https://docs.digitalocean.com/products/app-platform/) service.
|
|
38
38
|
- Select your source provider and create a new app.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### Configure Deployment Source
|
|
41
41
|
|
|
42
42
|
- Connect and select your repository. You may also choose a container image or a sample app.
|
|
43
43
|
- Select the branch you want to deploy from.
|
|
44
44
|
- Configure the source directory if necessary. If your Mastra application uses the default directory structure, no action is required here.
|
|
45
45
|
- Head to the next step.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### Configure Resource Settings and Environment Variables
|
|
48
48
|
|
|
49
49
|
- A Node.js build should be detected automatically.
|
|
50
50
|
- Add any required environment variables for your Mastra application. This includes API keys, database URLs, and other configuration values.
|
|
@@ -52,7 +52,7 @@ Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
|
|
|
52
52
|
- Other things you may optionally configure include, the region of your resource, the unique app name, and what project the resource belongs to.
|
|
53
53
|
- Once you're done, you may create the app after reviewing your configuration and pricing estimates.
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
### Deployment
|
|
56
56
|
|
|
57
57
|
- Your app will be built and deployed automatically.
|
|
58
58
|
- Digital Ocean will provide you with a URL to access your deployed application.
|
|
@@ -72,11 +72,11 @@ such as `LibSQLStore` with a file URL.
|
|
|
72
72
|
|
|
73
73
|
<Tabs.Tab>
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
## Droplets
|
|
76
76
|
|
|
77
77
|
Deploy your Mastra application to Digital Ocean's Droplets.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
### Prerequisites [#droplets-prerequisites]
|
|
80
80
|
|
|
81
81
|
- A [Digital Ocean account](https://www.digitalocean.com/)
|
|
82
82
|
- A [Droplet](https://docs.digitalocean.com/products/droplets/) running Ubuntu 24+
|
|
@@ -85,11 +85,11 @@ Deploy your Mastra application to Digital Ocean's Droplets.
|
|
|
85
85
|
- SSL certificate configured (e.g., using [Let's Encrypt](https://letsencrypt.org/))
|
|
86
86
|
- Node.js 18+ installed on your droplet
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
### Deployment Steps
|
|
89
89
|
|
|
90
90
|
<Steps>
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
### Clone your Mastra application
|
|
93
93
|
|
|
94
94
|
Connect to your Droplet and clone your repository:
|
|
95
95
|
|
|
@@ -117,13 +117,13 @@ Navigate to the repository directory:
|
|
|
117
117
|
cd "<your-repository>"
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
### Install dependencies
|
|
121
121
|
|
|
122
122
|
```bash copy
|
|
123
123
|
npm install
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
### Set up environment variables
|
|
127
127
|
|
|
128
128
|
Create a `.env` file and add your environment variables:
|
|
129
129
|
|
|
@@ -138,13 +138,13 @@ OPENAI_API_KEY=<your-openai-api-key>
|
|
|
138
138
|
# Add other required environment variables
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
### Build the application
|
|
142
142
|
|
|
143
143
|
```bash copy
|
|
144
144
|
npm run build
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
### Run the application
|
|
148
148
|
|
|
149
149
|
```bash copy
|
|
150
150
|
node --import=./.mastra/output/instrumentation.mjs --env-file=".env" .mastra/output/index.mjs
|
|
@@ -160,7 +160,7 @@ Your Mastra application will run on port 4111 by default. Ensure your reverse pr
|
|
|
160
160
|
|
|
161
161
|
</Tabs>
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
## Connect to your Mastra server
|
|
164
164
|
|
|
165
165
|
You can now connect to your Mastra server from your client application using a `MastraClient` from the `@mastra/client-js` package.
|
|
166
166
|
|
|
@@ -83,7 +83,7 @@ After installation:
|
|
|
83
83
|
|
|
84
84
|
## Available Templates
|
|
85
85
|
|
|
86
|
-
Browse available templates in the [templates directory](https://
|
|
86
|
+
Browse available templates in the [templates directory](https://mastra.ai/templates).
|
|
87
87
|
|
|
88
88
|
## Next Steps
|
|
89
89
|
|
|
@@ -114,7 +114,15 @@ await store.upsert({
|
|
|
114
114
|
```ts filename="vector-store.ts" showLineNumbers copy
|
|
115
115
|
import { ChromaVector } from '@mastra/chroma'
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
// Running Chroma locally
|
|
118
|
+
// const store = new ChromaVector()
|
|
119
|
+
|
|
120
|
+
// Running on Chroma Cloud
|
|
121
|
+
const store = new ChromaVector({
|
|
122
|
+
apiKey: process.env.CHROMA_API_KEY,
|
|
123
|
+
tenant: process.env.CHROMA_TENANT,
|
|
124
|
+
database: process.env.CHROMA_DATABASE
|
|
125
|
+
})
|
|
118
126
|
|
|
119
127
|
await store.createIndex({
|
|
120
128
|
indexName: "myCollection",
|
|
@@ -13,7 +13,7 @@ The `Agent` class is the foundation for creating AI agents in Mastra. It provide
|
|
|
13
13
|
import { openai } from "@ai-sdk/openai";
|
|
14
14
|
import { Agent } from "@mastra/core/agent";
|
|
15
15
|
|
|
16
|
-
const agent = new Agent({
|
|
16
|
+
export const agent = new Agent({
|
|
17
17
|
name: "test-agent",
|
|
18
18
|
instructions: 'message for agent',
|
|
19
19
|
model: openai("gpt-4o")
|
|
@@ -116,9 +116,15 @@ const agent = new Agent({
|
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
name: "inputProcessors",
|
|
119
|
-
type: "
|
|
119
|
+
type: "Processor[] | ({ runtimeContext: RuntimeContext }) => Processor[] | Promise<Processor[]>",
|
|
120
120
|
isOptional: true,
|
|
121
|
-
description: "Input processors that can modify or validate messages before they are processed by the agent.",
|
|
121
|
+
description: "Input processors that can modify or validate messages before they are processed by the agent. Must implement the `processInput` function.",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "outputProcessors",
|
|
125
|
+
type: "Processor[] | ({ runtimeContext: RuntimeContext }) => Processor[] | Promise<Processor[]>",
|
|
126
|
+
isOptional: true,
|
|
127
|
+
description: "Output processors that can modify or validate messages from the agent, before it is sent to the client. Must implement either (or both) of the `processOutputResult` and `processOutputStream` functions.",
|
|
122
128
|
},
|
|
123
129
|
]}
|
|
124
130
|
/>
|
|
@@ -48,12 +48,72 @@ await agent.generate("message for agent");
|
|
|
48
48
|
isOptional: true,
|
|
49
49
|
description: "Additional context messages to provide to the agent.",
|
|
50
50
|
},
|
|
51
|
+
{
|
|
52
|
+
name: "structuredOutput",
|
|
53
|
+
type: "StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>",
|
|
54
|
+
isOptional: true,
|
|
55
|
+
description: "Enables structured output generation with better developer experience. Automatically creates and uses a StructuredOutputProcessor internally.",
|
|
56
|
+
properties: [
|
|
57
|
+
{
|
|
58
|
+
parameters: [{
|
|
59
|
+
name: "schema",
|
|
60
|
+
type: "z.ZodSchema<S>",
|
|
61
|
+
isOptional: false,
|
|
62
|
+
description: "Zod schema to validate the output against."
|
|
63
|
+
}]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
parameters: [{
|
|
67
|
+
name: "model",
|
|
68
|
+
type: "MastraLanguageModel",
|
|
69
|
+
isOptional: false,
|
|
70
|
+
description: "Model to use for the internal structuring agent."
|
|
71
|
+
}]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
parameters: [{
|
|
75
|
+
name: "errorStrategy",
|
|
76
|
+
type: "'strict' | 'warn' | 'fallback'",
|
|
77
|
+
isOptional: true,
|
|
78
|
+
description: "Strategy when parsing or validation fails. Defaults to 'strict'."
|
|
79
|
+
}]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
parameters: [{
|
|
83
|
+
name: "fallbackValue",
|
|
84
|
+
type: "<S extends ZodTypeAny>",
|
|
85
|
+
isOptional: true,
|
|
86
|
+
description: "Fallback value when errorStrategy is 'fallback'."
|
|
87
|
+
}]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
parameters: [{
|
|
91
|
+
name: "instructions",
|
|
92
|
+
type: "string",
|
|
93
|
+
isOptional: true,
|
|
94
|
+
description: "Custom instructions for the structuring agent."
|
|
95
|
+
}]
|
|
96
|
+
},
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "outputProcessors",
|
|
101
|
+
type: "Processor[]",
|
|
102
|
+
isOptional: true,
|
|
103
|
+
description: "Overrides the output processors set on the agent. Output processors that can modify or validate messages from the agent before they are returned to the user. Must implement either (or both) of the `processOutputResult` and `processOutputStream` functions.",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "inputProcessors",
|
|
107
|
+
type: "Processor[]",
|
|
108
|
+
isOptional: true,
|
|
109
|
+
description: "Overrides the input processors set on the agent. Input processors that can modify or validate messages before they are processed by the agent. Must implement the `processInput` function.",
|
|
110
|
+
},
|
|
51
111
|
{
|
|
52
112
|
name: "experimental_output",
|
|
53
113
|
type: "Zod schema | JsonSchema7",
|
|
54
114
|
isOptional: true,
|
|
55
115
|
description:
|
|
56
|
-
"Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.",
|
|
116
|
+
"Note, the preferred route is to use the `structuredOutput` property. Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.",
|
|
57
117
|
},
|
|
58
118
|
{
|
|
59
119
|
name: "instructions",
|
|
@@ -344,7 +404,7 @@ await agent.generate("message for agent");
|
|
|
344
404
|
name: "object",
|
|
345
405
|
type: "object",
|
|
346
406
|
isOptional: true,
|
|
347
|
-
description: "The generated structured response. Present when a schema is provided via `output` or `experimental_output`.",
|
|
407
|
+
description: "The generated structured response. Present when a schema is provided via `output`, `structuredOutput`, or `experimental_output`.",
|
|
348
408
|
},
|
|
349
409
|
{
|
|
350
410
|
name: "toolCalls",
|
|
@@ -376,6 +436,9 @@ await agent.generate("message for agent");
|
|
|
376
436
|
## Extended usage example
|
|
377
437
|
|
|
378
438
|
```typescript showLineNumbers copy
|
|
439
|
+
import { z } from "zod";
|
|
440
|
+
import { ModerationProcessor, TokenLimiterProcessor } from "@mastra/core/processors";
|
|
441
|
+
|
|
379
442
|
await agent.generate(
|
|
380
443
|
[
|
|
381
444
|
{ role: "user", content: "message for agent" },
|
|
@@ -406,7 +469,21 @@ await agent.generate(
|
|
|
406
469
|
openai: {
|
|
407
470
|
reasoningEffort: "high"
|
|
408
471
|
}
|
|
409
|
-
}
|
|
472
|
+
},
|
|
473
|
+
// Structured output with better DX
|
|
474
|
+
structuredOutput: {
|
|
475
|
+
schema: z.object({
|
|
476
|
+
sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
477
|
+
confidence: z.number(),
|
|
478
|
+
}),
|
|
479
|
+
model: openai("gpt-4o-mini"),
|
|
480
|
+
errorStrategy: 'warn',
|
|
481
|
+
},
|
|
482
|
+
// Output processors for response validation
|
|
483
|
+
outputProcessors: [
|
|
484
|
+
new ModerationProcessor({ model: openai("gpt-4.1-nano") }),
|
|
485
|
+
new TokenLimiterProcessor({ maxTokens: 1000 }),
|
|
486
|
+
],
|
|
410
487
|
}
|
|
411
488
|
);
|
|
412
489
|
```
|
|
@@ -5,7 +5,7 @@ description: "Documentation for the `Agent.getDefaultGenerateOptions()` method i
|
|
|
5
5
|
|
|
6
6
|
# Agent.getDefaultGenerateOptions()
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Agents can be configured with default generation options for controlling model behavior, output formatting and tool and workflow calls. The `.getDefaultGenerateOptions()` method retrieves these defaults, resolving them if they are functions. These options apply to all `generate()`calls unless overridden and are useful for inspecting an agent’s unknown defaults.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: "Documentation for the `Agent.getDefaultStreamOptions()` method in
|
|
|
5
5
|
|
|
6
6
|
# Agent.getDefaultStreamOptions()
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Agents can be configured with default streaming options for memory usage, output format, and iteration steps. The `.getDefaultStreamOptions()` method returns these defaults, resolving them if they are functions. These options apply to all `stream()` calls unless overridden and are useful for inspecting an agent’s unknown defaults.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: "Documentation for the `Agent.getDefaultVNextStreamOptions()` metho
|
|
|
5
5
|
|
|
6
6
|
# Agent.getDefaultVNextStreamOptions()
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Agents can be configured with default streaming options for memory usage, output format, and iteration steps. The `.getDefaultVNextStreamOptions()` method returns these defaults, resolving them if they are functions. These options apply to all `streamVNext()` calls unless overridden and are useful for inspecting an agent’s unknown defaults.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
@@ -33,7 +33,7 @@ await agent.getLLM();
|
|
|
33
33
|
content={[
|
|
34
34
|
{
|
|
35
35
|
name: "llm",
|
|
36
|
-
type: "
|
|
36
|
+
type: "MastraLLMV1 | Promise<MastraLLMV1>",
|
|
37
37
|
description: "The language model instance configured for the agent, either as a direct instance or a promise that resolves to the LLM.",
|
|
38
38
|
},
|
|
39
39
|
]}
|