@mastra/mcp-docs-server 0.13.5-alpha.0 → 0.13.6
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 +76 -76
- package/.docs/organized/changelogs/%40mastra%2Fagui.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +211 -211
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +75 -75
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +91 -91
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +185 -185
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +237 -237
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +143 -143
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +143 -143
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +84 -84
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +75 -75
- package/.docs/organized/changelogs/%40mastra%2Flance.md +55 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +38 -38
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +119 -119
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +69 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +119 -119
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +244 -244
- package/.docs/organized/changelogs/%40mastra%2Frag.md +73 -73
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +24 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +211 -211
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +76 -76
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +44 -44
- package/.docs/organized/changelogs/create-mastra.md +126 -126
- package/.docs/organized/changelogs/mastra.md +256 -256
- package/.docs/organized/code-examples/agent.md +6 -0
- package/.docs/organized/code-examples/agui.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +201 -0
- package/.docs/organized/code-examples/assistant-ui.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +2 -2
- package/.docs/organized/code-examples/client-side-tools.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
- package/.docs/organized/code-examples/openapi-spec-writer.md +2 -2
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +181 -0
- package/.docs/raw/agents/agent-memory.mdx +126 -0
- package/.docs/raw/agents/dynamic-agents.mdx +34 -2
- package/.docs/raw/agents/overview.mdx +21 -33
- package/.docs/raw/community/licensing.mdx +27 -19
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +60 -26
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +44 -9
- package/.docs/raw/deployment/server-deployment.mdx +56 -0
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +9 -30
- package/.docs/raw/deployment/serverless-platforms/index.mdx +13 -13
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +291 -216
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +0 -34
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +162 -181
- package/.docs/raw/frameworks/servers/express.mdx +1 -1
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +2 -2
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -1
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +1 -1
- package/.docs/raw/getting-started/installation.mdx +10 -7
- package/.docs/raw/getting-started/model-capability.mdx +1 -1
- package/.docs/raw/memory/overview.mdx +8 -0
- package/.docs/raw/memory/semantic-recall.mdx +6 -0
- package/.docs/raw/observability/tracing.mdx +30 -0
- package/.docs/raw/rag/retrieval.mdx +24 -5
- package/.docs/raw/reference/agents/agent.mdx +2 -2
- package/.docs/raw/reference/cli/create-mastra.mdx +7 -0
- package/.docs/raw/reference/cli/dev.mdx +4 -3
- package/.docs/raw/reference/client-js/agents.mdx +8 -0
- package/.docs/raw/reference/memory/query.mdx +35 -14
- package/.docs/raw/reference/observability/providers/keywordsai.mdx +73 -0
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +213 -0
- package/.docs/raw/reference/storage/mssql.mdx +108 -0
- package/.docs/raw/server-db/custom-api-routes.mdx +67 -0
- package/.docs/raw/server-db/production-server.mdx +66 -0
- package/.docs/raw/tools-mcp/mcp-overview.mdx +28 -7
- package/.docs/raw/workflows/control-flow.mdx +91 -93
- package/.docs/raw/workflows/input-data-mapping.mdx +31 -43
- package/.docs/raw/workflows/overview.mdx +22 -12
- package/.docs/raw/workflows/pausing-execution.mdx +49 -4
- package/.docs/raw/workflows/suspend-and-resume.mdx +17 -16
- package/.docs/raw/workflows/using-with-agents-and-tools.mdx +16 -13
- package/.docs/raw/workflows-legacy/overview.mdx +11 -0
- package/LICENSE.md +11 -42
- package/package.json +7 -9
- package/.docs/raw/deployment/custom-api-routes.mdx +0 -55
- package/.docs/raw/deployment/server.mdx +0 -116
- package/.docs/raw/frameworks/ai-sdk-v5.mdx +0 -91
- /package/.docs/raw/{local-dev/mastra-dev.mdx → server-db/local-dev-playground.mdx} +0 -0
- /package/.docs/raw/{client-js/overview.mdx → server-db/mastra-client.mdx} +0 -0
- /package/.docs/raw/{deployment → server-db}/middleware.mdx +0 -0
- /package/.docs/raw/{storage/overview.mdx → server-db/storage.mdx} +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
2
|
+
title: "Agent Overview | Agent Documentation | Mastra"
|
|
3
3
|
description: Overview of agents in Mastra, detailing their capabilities and how they interact with tools, workflows, and external systems.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Using Agents
|
|
7
7
|
|
|
8
|
-
Agents
|
|
8
|
+
**Agents** are one of the core Mastra primitives. Agents use a language model to decide on a sequence of actions. They can call functions (known as _tools_). You can compose them with *workflows* (the other main Mastra primitive), either by giving an agent a workflow as a tool, or by running an agent from within a workflow.
|
|
9
9
|
|
|
10
|
-
Agents
|
|
10
|
+
Agents can run autonomously in a loop, run once, or take turns with a user. You can give short-term, long-term, and working memory of their user interactions. They can stream text or return structured output (ie, JSON). They can access third-party APIs, query knowledge bases, and so on.
|
|
11
|
+
|
|
12
|
+
Additionally, agents support dynamic configuration, allowing you to change their instructions, model, tools, and memory based on runtime context like user preferences, subscription tiers, or environment settings.
|
|
11
13
|
|
|
12
14
|
## 1. Creating an Agent
|
|
13
15
|
|
|
@@ -36,6 +38,8 @@ Also, make sure you have the `@mastra/core` package installed:
|
|
|
36
38
|
npm install @mastra/core@latest
|
|
37
39
|
```
|
|
38
40
|
|
|
41
|
+
All agent properties (instructions, model, tools, memory) can be configured dynamically using runtime context. See the [Dynamic Agents guide](./dynamic-agents.mdx) for examples of how to adapt agent behavior based on user context, subscription tiers, or other runtime variables.
|
|
42
|
+
|
|
39
43
|
### Registering the Agent
|
|
40
44
|
|
|
41
45
|
Register your agent with Mastra to enable logging and access to configured tools and integrations:
|
|
@@ -185,11 +189,13 @@ console.log("Structured Output:", response.object);
|
|
|
185
189
|
|
|
186
190
|
This allows you to have strong typing and validation for the structured data returned by the agent.
|
|
187
191
|
|
|
188
|
-
## 4. Multi-step
|
|
192
|
+
## 4. Multi-step tool use
|
|
193
|
+
|
|
194
|
+
Agents can be enhanced with tools - functions that extend their capabilities beyond text generation. Tools allow agents to perform calculations, access external systems, and process data. Agents not only decide whether to call tools they're given, they determine the parameters that should be given to that tool.
|
|
189
195
|
|
|
190
|
-
|
|
196
|
+
For a detailed guide to creating and configuring tools, see the [Adding Tools documentation](/docs/agents/using-tools-and-mcp), but below are the important things to know.
|
|
191
197
|
|
|
192
|
-
### Using maxSteps
|
|
198
|
+
### Using `maxSteps`
|
|
193
199
|
|
|
194
200
|
The `maxSteps` parameter controls the maximum number of sequential LLM calls an agent can make, particularly important when using tool calls. By default, it is set to 1 to prevent infinite loops in case of misconfigured tools. You can increase this limit based on your use case:
|
|
195
201
|
|
|
@@ -217,7 +223,7 @@ const response = await myAgent.generate(
|
|
|
217
223
|
{
|
|
218
224
|
role: "user",
|
|
219
225
|
content:
|
|
220
|
-
"If a taxi driver earns $
|
|
226
|
+
"If a taxi driver earns $41 per hour and works 12 hours a day, how much do they earn in one day?",
|
|
221
227
|
},
|
|
222
228
|
],
|
|
223
229
|
{
|
|
@@ -226,9 +232,10 @@ const response = await myAgent.generate(
|
|
|
226
232
|
);
|
|
227
233
|
```
|
|
228
234
|
|
|
229
|
-
###
|
|
235
|
+
### Streaming progress with `onStepFinish`
|
|
230
236
|
|
|
231
237
|
You can monitor the progress of multi-step operations using the `onStepFinish` callback. This is useful for debugging or providing progress updates to users.
|
|
238
|
+
|
|
232
239
|
`onStepFinish` is only available when streaming or generating text without structured output.
|
|
233
240
|
|
|
234
241
|
```ts showLineNumbers filename="src/mastra/agents/index.ts" copy
|
|
@@ -243,7 +250,7 @@ const response = await myAgent.generate(
|
|
|
243
250
|
);
|
|
244
251
|
```
|
|
245
252
|
|
|
246
|
-
###
|
|
253
|
+
### Detecting completion with `onFinish`
|
|
247
254
|
|
|
248
255
|
The `onFinish` callback is available when streaming responses and provides detailed information about the completed interaction. It is called after the LLM has finished generating its response and all tool executions have completed.
|
|
249
256
|
This callback receives the final response text, execution steps, token usage statistics, and other metadata that can be useful for monitoring and logging:
|
|
@@ -270,34 +277,15 @@ const stream = await myAgent.stream(
|
|
|
270
277
|
);
|
|
271
278
|
```
|
|
272
279
|
|
|
273
|
-
## 5.
|
|
274
|
-
|
|
275
|
-
Mastra provides a CLI command `mastra dev` to run your agents behind an API. By default, this looks for exported agents in files in the `src/mastra/agents` directory.
|
|
280
|
+
## 5. Testing agents locally
|
|
276
281
|
|
|
277
|
-
|
|
282
|
+
Mastra provides a CLI command `mastra dev` to run your agents behind an API. By default, this looks for exported agents in files in the `src/mastra/agents` directory. It generates endpoints for testing your agent (eg `http://localhost:4111/api/agents/myAgent/generate`) and provides a visual playground where you can chat with an agent and view traces.
|
|
278
283
|
|
|
279
|
-
|
|
280
|
-
mastra dev
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
This will start the server and make your agent available at `http://localhost:4111/api/agents/myAgent/generate`.
|
|
284
|
-
|
|
285
|
-
### Interacting with the Agent
|
|
286
|
-
|
|
287
|
-
You can interact with the agent using `curl` from the command line:
|
|
288
|
-
|
|
289
|
-
```bash
|
|
290
|
-
curl -X POST http://localhost:4111/api/agents/myAgent/generate \
|
|
291
|
-
-H "Content-Type: application/json" \
|
|
292
|
-
-d '{
|
|
293
|
-
"messages": [
|
|
294
|
-
{ "role": "user", "content": "Hello, how can you assist me today?" }
|
|
295
|
-
]
|
|
296
|
-
}'
|
|
297
|
-
```
|
|
284
|
+
For more details, see the [Local Dev Playground](/docs/server-db/local-dev-playground) docs.
|
|
298
285
|
|
|
299
286
|
## Next Steps
|
|
300
287
|
|
|
301
288
|
- Learn about Agent Memory in the [Agent Memory](./agent-memory.mdx) guide.
|
|
289
|
+
- Learn about Dynamic Agent configuration in the [Dynamic Agents](./dynamic-agents.mdx) guide.
|
|
302
290
|
- Learn about Agent Tools in the [Agent Tools and MCP](./using-tools-and-mcp.mdx) guide.
|
|
303
291
|
- See an example agent in the [Chef Michel](../../guides/guide/chef-michel.mdx) example.
|
|
@@ -5,36 +5,39 @@ description: "Mastra License"
|
|
|
5
5
|
|
|
6
6
|
# License
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Apache License 2.0
|
|
9
9
|
|
|
10
|
-
Mastra is licensed under the
|
|
10
|
+
Mastra is licensed under the Apache License 2.0, a permissive open-source license that provides users with broad rights to use, modify, and distribute the software.
|
|
11
11
|
|
|
12
|
-
### What is
|
|
12
|
+
### What is Apache License 2.0?
|
|
13
13
|
|
|
14
|
-
The
|
|
14
|
+
The Apache License 2.0 is a permissive open-source license that grants users extensive rights to use, modify, and distribute the software. It allows:
|
|
15
15
|
|
|
16
|
-
- Free use for
|
|
16
|
+
- Free use for any purpose, including commercial use
|
|
17
17
|
- Viewing, modifying, and redistributing the source code
|
|
18
18
|
- Creating and distributing derivative works
|
|
19
|
-
- Commercial use
|
|
19
|
+
- Commercial use without restrictions
|
|
20
|
+
- Patent protection from contributors
|
|
20
21
|
|
|
21
|
-
The
|
|
22
|
+
The Apache License 2.0 is one of the most permissive and business-friendly open-source licenses available.
|
|
22
23
|
|
|
23
|
-
### Why We Chose
|
|
24
|
+
### Why We Chose Apache License 2.0
|
|
24
25
|
|
|
25
|
-
We selected the
|
|
26
|
+
We selected the Apache License 2.0 for several important reasons:
|
|
26
27
|
|
|
27
|
-
1. **
|
|
28
|
+
1. **True Open Source**: It's a recognized open-source license that aligns with open-source principles and community expectations.
|
|
28
29
|
|
|
29
|
-
2. **
|
|
30
|
+
2. **Business Friendly**: It allows for unrestricted commercial use and distribution, making it ideal for businesses of all sizes.
|
|
30
31
|
|
|
31
|
-
3. **
|
|
32
|
+
3. **Patent Protection**: It includes explicit patent protection for users, providing additional legal security.
|
|
32
33
|
|
|
33
|
-
4. **
|
|
34
|
+
4. **Community Focus**: It encourages community contributions and collaboration without restrictions.
|
|
35
|
+
|
|
36
|
+
5. **Widely Adopted**: It's one of the most popular and well-understood open-source licenses in the industry.
|
|
34
37
|
|
|
35
38
|
### Building Your Business with Mastra
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
The Apache License 2.0 provides maximum flexibility for building businesses with Mastra:
|
|
38
41
|
|
|
39
42
|
#### Allowed Business Models
|
|
40
43
|
|
|
@@ -43,6 +46,8 @@ Despite the licensing restrictions, there are numerous ways to build successful
|
|
|
43
46
|
- **Developing Custom Solutions**: Build bespoke AI solutions for clients using Mastra
|
|
44
47
|
- **Creating Add-ons and Extensions**: Develop and sell complementary tools that extend Mastra's functionality
|
|
45
48
|
- **Training and Education**: Offer courses and educational materials about using Mastra effectively
|
|
49
|
+
- **Hosted Services**: Offer Mastra as a hosted or managed service
|
|
50
|
+
- **SaaS Platforms**: Build SaaS platforms powered by Mastra
|
|
46
51
|
|
|
47
52
|
#### Examples of Compliant Usage
|
|
48
53
|
|
|
@@ -50,14 +55,17 @@ Despite the licensing restrictions, there are numerous ways to build successful
|
|
|
50
55
|
- A consulting firm offers implementation and customization services for Mastra
|
|
51
56
|
- A developer creates specialized agents and tools with Mastra and licenses them to other businesses
|
|
52
57
|
- A startup builds a vertical-specific solution (e.g., healthcare AI assistant) powered by Mastra
|
|
58
|
+
- A company offers Mastra as a hosted service to their customers
|
|
59
|
+
- A SaaS platform integrates Mastra as their AI backend
|
|
53
60
|
|
|
54
|
-
####
|
|
61
|
+
#### Compliance Requirements
|
|
55
62
|
|
|
56
|
-
The
|
|
63
|
+
The Apache License 2.0 has minimal requirements:
|
|
57
64
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
65
|
+
- **Attribution**: Maintain copyright notices and license information (including NOTICE file)
|
|
66
|
+
- **State Changes**: If you modify the software, state that you have made changes
|
|
67
|
+
- **Include License**: Include a copy of the Apache License 2.0 when distributing
|
|
60
68
|
|
|
61
69
|
### Questions About Licensing?
|
|
62
70
|
|
|
63
|
-
If you have specific questions about how the
|
|
71
|
+
If you have specific questions about how the Apache License 2.0 applies to your use case, please [contact us](https://discord.gg/BTYqqHKUrf) on Discord for clarification. We're committed to supporting all legitimate use cases while maintaining the open-source nature of the project.
|
|
@@ -3,8 +3,7 @@ title: "Amazon EC2"
|
|
|
3
3
|
description: "Deploy your Mastra applications to Amazon EC2."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { Callout, Steps } from "nextra/components";
|
|
7
|
-
import ServerConfig from "@/components/content-blocks/server-config.mdx";
|
|
6
|
+
import { Callout, Steps, Tabs } from "nextra/components";
|
|
8
7
|
|
|
9
8
|
## Amazon EC2
|
|
10
9
|
|
|
@@ -17,50 +16,85 @@ Deploy your Mastra applications to Amazon EC2 (Elastic Cloud Compute).
|
|
|
17
16
|
refer to our [getting started guide](/docs/getting-started/installation)
|
|
18
17
|
</Callout>
|
|
19
18
|
|
|
20
|
-
###
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
- An AWS account with [EC2](https://aws.amazon.com/ec2/) access
|
|
22
|
+
- An EC2 instance running Ubuntu 24+ or Amazon Linux
|
|
23
|
+
- A domain name with an A record pointing to your instance
|
|
24
|
+
- A reverse proxy configured (e.g., using [nginx](https://nginx.org/))
|
|
25
|
+
- SSL certificate configured (e.g., using [Let's Encrypt](https://letsencrypt.org/))
|
|
26
|
+
- Node.js 18+ installed on your instance
|
|
27
|
+
|
|
28
|
+
### Deployment Steps
|
|
21
29
|
|
|
22
30
|
<Steps>
|
|
23
31
|
|
|
24
|
-
####
|
|
32
|
+
#### Clone your Mastra application
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
Connect to your EC2 instance and clone your repository:
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
<Tabs items={["Public Repository", "Private Repository"]}>
|
|
37
|
+
<Tabs.Tab>
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
```bash copy
|
|
40
|
+
git clone https://github.com/<your-username>/<your-repository>.git
|
|
41
|
+
```
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
</Tabs.Tab>
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
<Tabs.Tab>
|
|
46
|
+
|
|
47
|
+
```bash copy
|
|
48
|
+
git clone https://<your-username>:<your-personal-access-token>@github.com/<your-username>/<your-repository>.git
|
|
49
|
+
```
|
|
35
50
|
|
|
36
|
-
|
|
51
|
+
</Tabs.Tab>
|
|
52
|
+
</Tabs>
|
|
37
53
|
|
|
38
|
-
|
|
54
|
+
Navigate to the repository directory:
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
- **Key pair**: Select an existing key pair or create a new one for secure login
|
|
44
|
-
- **Network settings**: Ensure to **allow HTTPS and HTTP traffic from the internet** by checking the appropriate boxes
|
|
56
|
+
```bash copy
|
|
57
|
+
cd "<your-repository>"
|
|
58
|
+
```
|
|
45
59
|
|
|
46
|
-
####
|
|
60
|
+
#### Install dependencies
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
```bash copy
|
|
63
|
+
npm install
|
|
64
|
+
```
|
|
49
65
|
|
|
50
|
-
####
|
|
66
|
+
#### Set up environment variables
|
|
51
67
|
|
|
52
|
-
|
|
68
|
+
Create a `.env` file and add your environment variables:
|
|
53
69
|
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
```bash copy
|
|
71
|
+
touch .env
|
|
72
|
+
```
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
Edit the `.env` file and add your environment variables:
|
|
58
75
|
|
|
59
|
-
|
|
76
|
+
```bash copy
|
|
77
|
+
OPENAI_API_KEY=<your-openai-api-key>
|
|
78
|
+
# Add other required environment variables
|
|
79
|
+
```
|
|
60
80
|
|
|
61
|
-
|
|
81
|
+
#### Build the application
|
|
62
82
|
|
|
63
|
-
|
|
83
|
+
```bash copy
|
|
84
|
+
npm run build
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Run the application
|
|
88
|
+
|
|
89
|
+
```bash copy
|
|
90
|
+
node --import=./.mastra/output/instrumentation.mjs --env-file=".env" .mastra/output/index.mjs
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<Callout>
|
|
94
|
+
Your Mastra application will run on port 4111 by default. Ensure your reverse proxy is configured to forward requests to this port.
|
|
95
|
+
</Callout>
|
|
96
|
+
|
|
97
|
+
</Steps>
|
|
64
98
|
|
|
65
99
|
### Connect to your Mastra server
|
|
66
100
|
|
|
@@ -100,7 +100,7 @@ The guide assumes your droplet runs Ubuntu 24+.
|
|
|
100
100
|
|
|
101
101
|
You can now connect to your Mastra server from your client application using a `MastraClient` from the `@mastra/client-js` package.
|
|
102
102
|
|
|
103
|
-
Refer to the [`MastraClient` documentation](
|
|
103
|
+
Refer to the [`MastraClient` documentation](/docs/server-db/mastra-client) for more information.
|
|
104
104
|
|
|
105
105
|
```typescript copy showLineNumbers
|
|
106
106
|
import { MastraClient } from "@mastra/client-js";
|
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Cloud Providers"
|
|
3
3
|
description: "Deploy your Mastra applications to popular cloud providers."
|
|
4
|
-
asIndexPage: true
|
|
5
4
|
---
|
|
6
5
|
|
|
7
|
-
import { CardGrid, CardGridItem } from "@/components/cards/card-grid";
|
|
8
|
-
|
|
9
6
|
## Cloud Providers
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
Standalone Mastra applications can be deployed to popular cloud providers, see one of the following guides for more information:
|
|
9
|
+
|
|
10
|
+
- [Amazon EC2](/docs/deployment/cloud-providers/amazon-ec2)
|
|
11
|
+
- [AWS Lambda](/docs/deployment/cloud-providers/aws-lambda)
|
|
12
|
+
- [Digital Ocean](/docs/deployment/cloud-providers/digital-ocean)
|
|
13
|
+
- [Azure App Services](/docs/deployment/cloud-providers/azure-app-services)
|
|
14
|
+
|
|
15
|
+
For self-hosted Node.js server deployment, see the [Creating A Mastra Server](/docs/deployment/server) guide.
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
Before deploying to a cloud provider, ensure you have:
|
|
20
|
+
|
|
21
|
+
- A [Mastra application](/docs/getting-started/installation)
|
|
22
|
+
- Node.js `v20.0` or higher
|
|
23
|
+
- A GitHub repository for your application (required for most CI/CD setups)
|
|
24
|
+
- Domain name management access (for SSL and HTTPS)
|
|
25
|
+
- Basic familiarity with server setup (e.g. Nginx, environment variables)
|
|
26
|
+
|
|
27
|
+
## LibSQLStore
|
|
28
|
+
|
|
29
|
+
`LibSQLStore` writes to the local filesystem, which is not supported in cloud environments that use ephemeral file systems. If you're deploying to platforms like **AWS Lambda**, **Azure App Services**, or **Digital Ocean App Platform**, you **must remove** all usage of `LibSQLStore`.
|
|
30
|
+
|
|
31
|
+
Specifically, ensure you've removed it from both `src/mastra/index.ts` and `src/mastra/agents/weather-agent.ts`:
|
|
32
|
+
|
|
33
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers
|
|
34
|
+
export const mastra = new Mastra({
|
|
35
|
+
// ...
|
|
36
|
+
storage: new LibSQLStore({ // [!code --]
|
|
37
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db // [!code --]
|
|
38
|
+
url: ":memory:", // [!code --]
|
|
39
|
+
})//[!code --]
|
|
40
|
+
});
|
|
41
|
+
```
|
|
12
42
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
43
|
+
```typescript filename="src/mastra/agents/weather-agent.ts" showLineNumbers
|
|
44
|
+
export const weatherAgent = new Agent({
|
|
45
|
+
// ..
|
|
46
|
+
memory: new Memory({ // [!code --]
|
|
47
|
+
storage: new LibSQLStore({ // [!code --]
|
|
48
|
+
url: "file:../mastra.db" // path is relative to the .mastra/output directory // [!code --]
|
|
49
|
+
}) // [!code --]
|
|
50
|
+
})// [!code --]
|
|
51
|
+
});
|
|
52
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Deploy A Mastra Server"
|
|
3
|
+
description: "Deploy a Mastra server with middleware and other options"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deploy A Mastra Server
|
|
7
|
+
|
|
8
|
+
Mastra builds to a standard Node.js server, so you can deploy it to any platform that supports Node.js applications.
|
|
9
|
+
|
|
10
|
+
- Cloud VMs (AWS EC2, DigitalOcean Droplets, GCP Compute Engine)
|
|
11
|
+
- Container platforms (Docker, Kubernetes)
|
|
12
|
+
- Platform as a Service (Heroku, Railway)
|
|
13
|
+
- Self-hosted servers
|
|
14
|
+
|
|
15
|
+
See the [Cloud Providers](/docs/deployment/cloud-providers/) for more information.
|
|
16
|
+
|
|
17
|
+
### Building
|
|
18
|
+
|
|
19
|
+
Build the application:
|
|
20
|
+
|
|
21
|
+
```bash copy
|
|
22
|
+
# Build from current directory
|
|
23
|
+
mastra build
|
|
24
|
+
|
|
25
|
+
# Or specify a directory
|
|
26
|
+
mastra build --dir ./my-project
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The build process:
|
|
30
|
+
|
|
31
|
+
1. Locates entry file (`src/mastra/index.ts` or `src/mastra/index.js`)
|
|
32
|
+
2. Creates `.mastra` output directory
|
|
33
|
+
3. Bundles code using Rollup with tree shaking and source maps
|
|
34
|
+
4. Generates [Hono](https://hono.dev) HTTP server
|
|
35
|
+
|
|
36
|
+
See [`mastra build`](/reference/cli/build) for all options.
|
|
37
|
+
|
|
38
|
+
### Running the Server
|
|
39
|
+
|
|
40
|
+
Start the HTTP server:
|
|
41
|
+
|
|
42
|
+
```bash copy
|
|
43
|
+
node .mastra/output/index.mjs
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Enable Telemetry for build output
|
|
47
|
+
|
|
48
|
+
Load instrumentation for the build output like so:
|
|
49
|
+
|
|
50
|
+
```bash copy
|
|
51
|
+
node --import=./.mastra/output/instrumentation.mjs .mastra/output/index.mjs
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Serverless Deployment
|
|
55
|
+
|
|
56
|
+
Mastra also supports serverless deployment on Cloudflare Workers, Vercel, and Netlify. See [Serverless Platforms](/docs/deployment/serverless-platforms/) for more information.
|
|
@@ -24,6 +24,7 @@ import { CloudflareDeployer } from "@mastra/deployer-cloudflare";
|
|
|
24
24
|
export const mastra = new Mastra({
|
|
25
25
|
// ...
|
|
26
26
|
deployer: new CloudflareDeployer({
|
|
27
|
+
scope: "your-account-id",
|
|
27
28
|
projectName: "hello-mastra",
|
|
28
29
|
scope: "",
|
|
29
30
|
auth: {
|
|
@@ -36,44 +37,23 @@ export const mastra = new Mastra({
|
|
|
36
37
|
|
|
37
38
|
> See the [CloudflareDeployer](/reference/deployer/cloudflare) API reference for all available configuration options.
|
|
38
39
|
|
|
39
|
-
### Cloudflare API token
|
|
40
|
-
|
|
41
|
-
In your Cloudflare dashboard, navigate to **Profile** > **API Tokens**, then select **Edit Cloudflare Workers** and click **Use template** to create a token for the `CloudflareDeployer`.
|
|
42
|
-
|
|
43
|
-
> To learn how to create a Cloudflare API token, see [Create API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) in the Cloudflare docs.
|
|
44
|
-
|
|
45
|
-
## Continuous integration
|
|
46
|
-
In the Cloudflare dashboard, navigate to **Workers** > **Import a repository**. After importing your Mastra project's Git repository, create an application and configure the build settings with:
|
|
47
|
-
|
|
48
|
-
- **Build command**: `npm run build`
|
|
49
|
-
- **Deploy command**: `cd .mastra/output && npx wrangler deploy`
|
|
50
|
-
|
|
51
|
-
- **Build command**: `npm run build` (optional)
|
|
52
|
-
|
|
53
40
|
## Manual deployment
|
|
54
41
|
|
|
55
42
|
Manual deployments are also possible using the [Cloudflare Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/). With the Wrangler CLI installed run the following from your project root to deploy your application.
|
|
56
43
|
|
|
44
|
+
With the Wrangler CLI installed, login and authenticate with your Cloudflare logins:
|
|
45
|
+
|
|
57
46
|
```bash copy
|
|
58
|
-
|
|
47
|
+
npx wrangler login
|
|
59
48
|
```
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## Cloudflare secrets
|
|
64
|
-
|
|
65
|
-
To add secrets to your Cloudflare Workers application, use the Wrangler CLI. Secrets are environment variables that are encrypted and stored securely.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
For example, to add an API key:
|
|
50
|
+
Run the following to build and deploy your application to Cloudflare
|
|
69
51
|
|
|
70
52
|
```bash copy
|
|
71
|
-
|
|
53
|
+
npm run build && wrangler deploy --config .mastra/output/wrangler.json
|
|
72
54
|
```
|
|
73
55
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
> For more details on managing secrets, see [Environment Variables and Secrets](https://developers.cloudflare.com/workers/configuration/secrets/) in the Cloudflare documentation.
|
|
56
|
+
> You can also run `wrangler dev --config .mastra/output/wrangler.json` from your project root to test your Mastra application locally.
|
|
77
57
|
|
|
78
58
|
## Build output
|
|
79
59
|
|
|
@@ -99,13 +79,12 @@ The `CloudflareDeployer` automatically generates a `wrangler.json` configuration
|
|
|
99
79
|
"compatibility_flags": ["nodejs_compat", "nodejs_compat_populate_process_env"],
|
|
100
80
|
"observability": { "logs": { "enabled": true } },
|
|
101
81
|
"vars": {
|
|
102
|
-
"OPENAI_API_KEY": "
|
|
82
|
+
"OPENAI_API_KEY": "...",
|
|
103
83
|
"CLOUDFLARE_API_TOKEN": "..."
|
|
104
84
|
}
|
|
105
85
|
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
86
|
|
|
87
|
+
```
|
|
109
88
|
## Next steps
|
|
110
89
|
|
|
111
90
|
- [Mastra Client SDK](/docs/client-js/overview)
|
|
@@ -19,7 +19,7 @@ For self-hosted Node.js server deployment, see the [Creating A Mastra Server](/d
|
|
|
19
19
|
|
|
20
20
|
Before you begin, ensure you have:
|
|
21
21
|
|
|
22
|
-
-
|
|
22
|
+
- Node.js `v20.0` or higher
|
|
23
23
|
- If using a platform-specific deployer:
|
|
24
24
|
- An account with your chosen platform
|
|
25
25
|
- Required API keys or credentials
|
|
@@ -30,23 +30,23 @@ 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
|
-
```
|
|
33
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers
|
|
34
34
|
export const mastra = new Mastra({
|
|
35
35
|
// ...
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
storage: new LibSQLStore({ // [!code --]
|
|
37
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db // [!code --]
|
|
38
|
+
url: ":memory:", // [!code --]
|
|
39
|
+
})//[!code --]
|
|
40
40
|
});
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
```
|
|
43
|
+
```typescript filename="src/mastra/agents/weather-agent.ts" showLineNumbers
|
|
44
44
|
export const weatherAgent = new Agent({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// ..
|
|
46
|
+
memory: new Memory({ // [!code --]
|
|
47
|
+
storage: new LibSQLStore({ // [!code --]
|
|
48
|
+
url: "file:../mastra.db" // path is relative to the .mastra/output directory // [!code --]
|
|
49
|
+
}) // [!code --]
|
|
50
|
+
})// [!code --]
|
|
51
51
|
});
|
|
52
52
|
```
|