@mastra/mcp-docs-server 0.13.2-alpha.1 → 0.13.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +14 -14
- 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 +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +20 -20
- 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 +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Flance.md +13 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +13 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +14 -14
- package/.docs/organized/changelogs/mastra.md +22 -22
- package/.docs/organized/code-examples/agent.md +182 -5
- package/.docs/organized/code-examples/assistant-ui.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +2 -2
- package/.docs/organized/code-examples/openapi-spec-writer.md +1 -1
- package/.docs/raw/agents/using-tools-and-mcp.mdx +3 -2
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +111 -0
- package/.docs/raw/deployment/cloud-providers/index.mdx +15 -0
- package/.docs/raw/memory/working-memory.mdx +56 -0
- package/.docs/raw/networks-vnext/complex-task-execution.mdx +137 -0
- package/.docs/raw/networks-vnext/overview.mdx +85 -0
- package/.docs/raw/networks-vnext/single-task-execution.mdx +131 -0
- package/.docs/raw/reference/client-js/agents.mdx +41 -0
- package/.docs/raw/reference/deployer/netlify.mdx +22 -68
- package/.docs/raw/reference/deployer/vercel.mdx +7 -77
- package/.docs/raw/reference/tools/mcp-client.mdx +244 -0
- package/.docs/raw/reference/tools/mcp-server.mdx +186 -0
- package/.docs/raw/reference/workflows/create-run.mdx +1 -1
- package/.docs/raw/reference/workflows/resume.mdx +1 -1
- package/.docs/raw/reference/workflows/start.mdx +1 -1
- package/.docs/raw/reference/workflows/stream.mdx +1 -1
- package/.docs/raw/reference/workflows/watch.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +6 -2
- package/.docs/raw/workflows/control-flow.mdx +42 -1
- package/.docs/raw/workflows/overview.mdx +73 -5
- package/.docs/raw/workflows/pausing-execution.mdx +1 -1
- package/.docs/raw/workflows/suspend-and-resume.mdx +68 -23
- package/.docs/raw/workflows/using-with-agents-and-tools.mdx +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Handling Complex LLM Operations | Networks | Mastra"
|
|
3
|
+
description: "Networks in Mastra help you execute individual or multiple Mastra primitives in a non-deterministic way using a single API."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Mastra vNext Agent Network
|
|
7
|
+
|
|
8
|
+
The vNext Agent Network module introduces a flexible, composable and non-deterministic way to orchestrate multiple specialized agents and workflows, enabling complex, reasoning and task completion.
|
|
9
|
+
|
|
10
|
+
There are two main problem areas that this system is designed to solve:
|
|
11
|
+
|
|
12
|
+
- Scenarios where a single agent is insufficient, and tasks require collaboration, routing, or sequential/parallel execution across multiple agents and workflows.
|
|
13
|
+
- Scenarios where the task is not fully defined and is initiated with unstructured input. The AgentNetwork can figure out which primitive to call and turn unstructured input into a structured task.
|
|
14
|
+
|
|
15
|
+
## Differences from Workflows
|
|
16
|
+
|
|
17
|
+
- Workflows are linear or branched sequences of steps. This creates a deterministic flow of execution.
|
|
18
|
+
- Agent Networks add a layer of non-deterministic LLM-based orchestration, allowing dynamic, multi-agent collaboration and routing. This creates a non-deterministic flow of execution.
|
|
19
|
+
|
|
20
|
+
## Differences from current experimental implementation
|
|
21
|
+
|
|
22
|
+
- The current implementation of AgentNetwork relies on tool calls to call other agents in the network. The vNext implementation is using Mastra workflows under the hood to break down the execution to individual tasks.
|
|
23
|
+
- New methods, `.generate()` for a one-off "playbook"-like execution of a single primitive in the network, more suitable for a chat-based interface where you iterate on a solution. The `.loop()` method is still available for more complex tasks and operates much like the current implementation.
|
|
24
|
+
|
|
25
|
+
## Important details
|
|
26
|
+
|
|
27
|
+
- Providing memory to the AgentNetwork is _not_ optional when using the `loop` method, as it is required to store the task history. Memory is the core primitive used for any decisions on which primitives to run, as well as determine task completion.
|
|
28
|
+
- Any available primitives (agents, workflows) are used based on their descriptions. The better the description, the better the routing agent will be able to select the right primitive. For workflows, the input schema is also used to determine which inputs to use when calling the workflow. More descriptive naming yields better results.
|
|
29
|
+
- When primitives with overlapping capabilities are available, the routing agent will use the most specific primitive. For example, if both an agent and a workflow can do research, it will use the input schema of the worklfow to determine
|
|
30
|
+
|
|
31
|
+
## Registering the network in Mastra
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const mastra = new Mastra({
|
|
35
|
+
vnext_networks: {
|
|
36
|
+
'test-network': network,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// using the network
|
|
41
|
+
const network = mastra.vnext_getNetwork('test-network');
|
|
42
|
+
|
|
43
|
+
if (!network) {
|
|
44
|
+
throw new Error('Network not found');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(await network.generate('What are the biggest cities in France?', { runtimeContext }));
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Using @mastra/client-js
|
|
51
|
+
|
|
52
|
+
You can use the `@mastra/client-js` package to run the network from the client side.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { MastraClient } from '@mastra/client-js';
|
|
56
|
+
|
|
57
|
+
const client = new MastraClient();
|
|
58
|
+
|
|
59
|
+
const network = client.getVNextNetwork('test-network');
|
|
60
|
+
|
|
61
|
+
console.log(await network.generate('What are the biggest cities in France?', { runtimeContext }));
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can also stream the response
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const stream = await network.stream('What are the biggest cities in France?', { runtimeContext });
|
|
68
|
+
|
|
69
|
+
for await (const chunk of stream) {
|
|
70
|
+
console.log(chunk);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
And for loops
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
console.log(
|
|
78
|
+
// specifying the task, note that there is a mention here about using an agent for synthesis. This is because the routing agent can actually do some synthesis on results on its own, so this will force it to use agent2 instead
|
|
79
|
+
await network.loop(
|
|
80
|
+
'What are the biggest cities in France? Give me 3. How are they like? Find cities, then do thorough research on each city, and give me a final full report synthesizing all that information. Make sure to use an agent for synthesis.',
|
|
81
|
+
{ runtimeContext },
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
## Unstructured input to structured task
|
|
2
|
+
|
|
3
|
+
As an example, we have an AgentNetwork with 3 primitives at its disposal:
|
|
4
|
+
|
|
5
|
+
- `agent1`: A general research agent that can do research on a given topic.
|
|
6
|
+
- `agent2`: A general writing agent that can write a full report based on the researched material.
|
|
7
|
+
- `workflow1`: A workflow that can research a given city and write a full report based on the researched material (using both agent1 and agent2).
|
|
8
|
+
|
|
9
|
+
The AgentNetwork is able to route the task to the most appropriate primitive based on the task and the context.
|
|
10
|
+
To ask the AgentNetwork to act on unstructured (text) input, we can use the `generate` method.
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { NewAgentNetwork } from '@mastra/core/network/vNext';
|
|
14
|
+
import { Agent } from '@mastra/core/agent';
|
|
15
|
+
import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
16
|
+
import { Memory } from '@mastra/memory';
|
|
17
|
+
import { openai } from '@ai-sdk/openai';
|
|
18
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
21
|
+
|
|
22
|
+
const memory = new Memory({
|
|
23
|
+
storage: new LibSQLStore({
|
|
24
|
+
url: 'file:../mastra.db', // Or your database URL
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const agent1 = new Agent({
|
|
29
|
+
name: 'agent1',
|
|
30
|
+
instructions:
|
|
31
|
+
'This agent is used to do research, but not create full responses. Answer in bullet points only and be concise.',
|
|
32
|
+
description:
|
|
33
|
+
'This agent is used to do research, but not create full responses. Answer in bullet points only and be concise.',
|
|
34
|
+
model: openai('gpt-4o'),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const agent2 = new Agent({
|
|
38
|
+
name: 'agent2',
|
|
39
|
+
description: 'This agent is used to do text synthesis on researched material. It writes articles in full paragraphs.',
|
|
40
|
+
instructions:
|
|
41
|
+
'This agent is used to do text synthesis on researched material. Write a full report based on the researched material. Do not use bullet points. Write full paragraphs. There should not be a single bullet point in the final report. You write articles.',
|
|
42
|
+
model: openai('gpt-4o'),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const agentStep1 = createStep({
|
|
46
|
+
id: 'agent-step',
|
|
47
|
+
description: 'This step is used to do research and text synthesis.',
|
|
48
|
+
inputSchema: z.object({
|
|
49
|
+
city: z.string().describe('The city to research'),
|
|
50
|
+
}),
|
|
51
|
+
outputSchema: z.object({
|
|
52
|
+
text: z.string(),
|
|
53
|
+
}),
|
|
54
|
+
execute: async ({ inputData }) => {
|
|
55
|
+
const resp = await agent1.generate(inputData.city, {
|
|
56
|
+
output: z.object({
|
|
57
|
+
text: z.string(),
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return { text: resp.object.text };
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const agentStep2 = createStep({
|
|
66
|
+
id: 'agent-step-two',
|
|
67
|
+
description: 'This step is used to do research and text synthesis.',
|
|
68
|
+
inputSchema: z.object({
|
|
69
|
+
text: z.string().describe('The city to research'),
|
|
70
|
+
}),
|
|
71
|
+
outputSchema: z.object({
|
|
72
|
+
text: z.string(),
|
|
73
|
+
}),
|
|
74
|
+
execute: async ({ inputData }) => {
|
|
75
|
+
const resp = await agent2.generate(inputData.text, {
|
|
76
|
+
output: z.object({
|
|
77
|
+
text: z.string(),
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return { text: resp.object.text };
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const workflow1 = createWorkflow({
|
|
86
|
+
id: 'workflow1',
|
|
87
|
+
description: 'This workflow is perfect for researching a specific city.',
|
|
88
|
+
steps: [],
|
|
89
|
+
inputSchema: z.object({
|
|
90
|
+
city: z.string(),
|
|
91
|
+
}),
|
|
92
|
+
outputSchema: z.object({
|
|
93
|
+
text: z.string(),
|
|
94
|
+
}),
|
|
95
|
+
})
|
|
96
|
+
.then(agentStep1)
|
|
97
|
+
.then(agentStep2)
|
|
98
|
+
.commit();
|
|
99
|
+
|
|
100
|
+
const network = new NewAgentNetwork({
|
|
101
|
+
id: 'test-network',
|
|
102
|
+
name: 'Test Network',
|
|
103
|
+
instructions:
|
|
104
|
+
'You can research cities. You can also synthesize research material. You can also write a full report based on the researched material.',
|
|
105
|
+
model: openai('gpt-4o'),
|
|
106
|
+
agents: {
|
|
107
|
+
agent1,
|
|
108
|
+
agent2,
|
|
109
|
+
},
|
|
110
|
+
workflows: {
|
|
111
|
+
workflow1,
|
|
112
|
+
},
|
|
113
|
+
memory: memory,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const runtimeContext = new RuntimeContext();
|
|
117
|
+
|
|
118
|
+
// This will call agent1, as the workflow is meant to be used with individual cities. The best primitive according to the routing agent is thus agent1 which is a general research primitive.
|
|
119
|
+
console.log(await network.generate('What are the biggest cities in France? How are they like?', { runtimeContext }));
|
|
120
|
+
// This will call workflow1, as it is the most suitable primitive according to the routing agent when researching individual cities.
|
|
121
|
+
console.log(await network.generate('Tell me more about Paris', { runtimeContext }));
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The AgentNetwork will call the most appropriate primitive based on the task and the context. In the case of researching specific cities, it can figure out how to turn unstructured input into structured workflow inputs based on the workflow's input schema and description. It also knows, that for any other research topic, `agent1` is likely the most appropriate primitive.
|
|
125
|
+
|
|
126
|
+
### How It Works
|
|
127
|
+
|
|
128
|
+
- The underlying engine is a Mastra workflow.
|
|
129
|
+
- As a first step, the network uses a **routing agent** to decide which agent or workflow should handle each step.
|
|
130
|
+
- The routing agent will generate a prompt and or structured input for the selected primitive.
|
|
131
|
+
- The next step in the workflow is a `.branch()` that will select the right primitive, calling either an agent step or a workflow step with the input generated by the routing agent.
|
|
@@ -98,6 +98,47 @@ while (true) {
|
|
|
98
98
|
}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
### Client tools
|
|
102
|
+
|
|
103
|
+
Client-side tools allow you to execute custom functions on the client side when the agent requests them.
|
|
104
|
+
|
|
105
|
+
#### Basic Usage
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { createTool } from '@mastra/core/tools';
|
|
109
|
+
import { z } from 'zod';
|
|
110
|
+
|
|
111
|
+
const colorChangeTool = createTool({
|
|
112
|
+
id: 'changeColor',
|
|
113
|
+
description: 'Changes the background color',
|
|
114
|
+
inputSchema: z.object({
|
|
115
|
+
color: z.string(),
|
|
116
|
+
}),
|
|
117
|
+
execute: async ({ context }) => {
|
|
118
|
+
document.body.style.backgroundColor = context.color;
|
|
119
|
+
return { success: true };
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// Use with generate
|
|
125
|
+
const response = await agent.generate({
|
|
126
|
+
messages: 'Change the background to blue',
|
|
127
|
+
clientTools: {colorChangeTool},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Use with stream
|
|
131
|
+
const response = await agent.stream({
|
|
132
|
+
messages: 'Change the background to green',
|
|
133
|
+
clientTools: {colorChangeTool},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
response.processDataStream({
|
|
137
|
+
onTextPart: (text) => console.log(text),
|
|
138
|
+
onToolCallPart: (toolCall) => console.log('Tool called:', toolCall.toolName),
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
101
142
|
### Get Agent Tool
|
|
102
143
|
|
|
103
144
|
Retrieve information about a specific tool available to the agent:
|
|
@@ -21,50 +21,10 @@ import { NetlifyDeployer } from "@mastra/deployer-netlify";
|
|
|
21
21
|
|
|
22
22
|
const mastra = new Mastra({
|
|
23
23
|
// ...
|
|
24
|
-
deployer: new NetlifyDeployer(
|
|
25
|
-
scope: "your-team-slug",
|
|
26
|
-
projectName: "your-project-name",
|
|
27
|
-
token: "your-netlify-token",
|
|
28
|
-
})
|
|
24
|
+
deployer: new NetlifyDeployer()
|
|
29
25
|
});
|
|
30
26
|
```
|
|
31
27
|
|
|
32
|
-
## Parameters
|
|
33
|
-
|
|
34
|
-
### Constructor Parameters
|
|
35
|
-
|
|
36
|
-
<PropertiesTable
|
|
37
|
-
content={[
|
|
38
|
-
{
|
|
39
|
-
name: "scope",
|
|
40
|
-
type: "string",
|
|
41
|
-
description: "Your Netlify team slug or ID.",
|
|
42
|
-
isOptional: false,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "projectName",
|
|
46
|
-
type: "string",
|
|
47
|
-
description:
|
|
48
|
-
"Name of your Netlify site (will be created if it doesn't exist).",
|
|
49
|
-
isOptional: false,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "token",
|
|
53
|
-
type: "string",
|
|
54
|
-
description: "Your Netlify authentication token.",
|
|
55
|
-
isOptional: false,
|
|
56
|
-
},
|
|
57
|
-
]}
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
### Environment Variables
|
|
61
|
-
|
|
62
|
-
The NetlifyDeployer handles environment variables from multiple sources:
|
|
63
|
-
|
|
64
|
-
1. **Environment Files**: Variables from `.env.production` and `.env` files.
|
|
65
|
-
2. **Configuration**: Variables passed through the Mastra configuration.
|
|
66
|
-
3. **Netlify Dashboard**: Variables can also be managed through Netlify's web interface.
|
|
67
|
-
|
|
68
28
|
## Lint Mastra Project
|
|
69
29
|
|
|
70
30
|
Lint your Mastra project to make sure it's fine to build
|
|
@@ -84,28 +44,29 @@ npx mastra build
|
|
|
84
44
|
The build process generates the following output structure in the `.mastra/output` directory:
|
|
85
45
|
|
|
86
46
|
```
|
|
87
|
-
.
|
|
88
|
-
├──
|
|
89
|
-
|
|
90
|
-
│
|
|
91
|
-
│
|
|
92
|
-
|
|
47
|
+
.netlify/
|
|
48
|
+
├── v1/
|
|
49
|
+
└── functions/
|
|
50
|
+
│ └── api/
|
|
51
|
+
│ └── index.mjs # Application entry point
|
|
52
|
+
│ config.json # Netlify configuration
|
|
93
53
|
```
|
|
94
54
|
|
|
95
55
|
### Netlify Configuration
|
|
96
56
|
|
|
97
|
-
The NetlifyDeployer automatically generates a `
|
|
98
|
-
|
|
99
|
-
```toml
|
|
100
|
-
[functions]
|
|
101
|
-
node_bundler = "esbuild"
|
|
102
|
-
directory = "netlify/functions"
|
|
57
|
+
The NetlifyDeployer automatically generates a `config.json` configuration file in `.netlify/v1` with the following settings:
|
|
103
58
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"redirects": [
|
|
62
|
+
{
|
|
63
|
+
"force": true,
|
|
64
|
+
"from": "/*",
|
|
65
|
+
"to": "/.netlify/functions/api/:splat",
|
|
66
|
+
"status": 200
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
109
70
|
```
|
|
110
71
|
|
|
111
72
|
## Deployment Options
|
|
@@ -115,9 +76,8 @@ After building, you can deploy your Mastra application `.mastra/output` to Netli
|
|
|
115
76
|
1. **Netlify CLI**: Deploy directly using Netlify's official CLI tool
|
|
116
77
|
|
|
117
78
|
- Install the CLI: `npm install -g netlify-cli`
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
- For production deployment add `--prod` flag: `netlify deploy --prod --dir . --functions ./netlify/functions`
|
|
79
|
+
- Deploy with functions directory specified: `netlify deploy`
|
|
80
|
+
- For production deployment add `--prod` flag: `netlify deploy --prod`
|
|
121
81
|
|
|
122
82
|
2. **Netlify Dashboard**: Connect your Git repository or drag-and-drop the build output through the Netlify dashboard
|
|
123
83
|
|
|
@@ -126,19 +86,13 @@ After building, you can deploy your Mastra application `.mastra/output` to Netli
|
|
|
126
86
|
```bash
|
|
127
87
|
# Build command
|
|
128
88
|
npm run build
|
|
129
|
-
|
|
130
|
-
# Publish directory
|
|
131
|
-
.mastra/output
|
|
132
|
-
|
|
133
|
-
# Functions directory
|
|
134
|
-
.mastra/output/netlify/functions
|
|
135
89
|
```
|
|
136
90
|
|
|
137
91
|
|
|
138
92
|
|
|
139
93
|
3. **Netlify Dev**: Run your Mastra application locally with Netlify's development environment
|
|
140
94
|
|
|
141
|
-
> You can also run `netlify dev` in your
|
|
95
|
+
> You can also run `netlify dev` in your project root to test your Mastra application locally.
|
|
142
96
|
|
|
143
97
|
## Platform Documentation
|
|
144
98
|
|
|
@@ -21,52 +21,10 @@ import { VercelDeployer } from "@mastra/deployer-vercel";
|
|
|
21
21
|
|
|
22
22
|
const mastra = new Mastra({
|
|
23
23
|
// ...
|
|
24
|
-
deployer: new VercelDeployer(
|
|
25
|
-
teamSlug: "your-team-slug",
|
|
26
|
-
projectName: "your-project-name",
|
|
27
|
-
token: "your-vercel-token",
|
|
28
|
-
})
|
|
24
|
+
deployer: new VercelDeployer()
|
|
29
25
|
});
|
|
30
26
|
```
|
|
31
27
|
|
|
32
|
-
## Parameters
|
|
33
|
-
|
|
34
|
-
### Constructor Parameters
|
|
35
|
-
|
|
36
|
-
<PropertiesTable
|
|
37
|
-
content={[
|
|
38
|
-
{
|
|
39
|
-
name: "teamSlug",
|
|
40
|
-
type: "string",
|
|
41
|
-
description: "Your Vercel team slug",
|
|
42
|
-
isOptional: false,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "projectName",
|
|
46
|
-
type: "string",
|
|
47
|
-
description:
|
|
48
|
-
"Name of your Vercel project (will be created if it doesn't exist).",
|
|
49
|
-
isOptional: false,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "token",
|
|
53
|
-
type: "string",
|
|
54
|
-
description: "Your Vercel authentication token.",
|
|
55
|
-
isOptional: false,
|
|
56
|
-
},
|
|
57
|
-
]}
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
### Environment Variables
|
|
61
|
-
|
|
62
|
-
The VercelDeployer handles environment variables from multiple sources:
|
|
63
|
-
|
|
64
|
-
1. **Environment Files**: Variables from `.env.production` and `.env` files.
|
|
65
|
-
2. **Configuration**: Variables passed through the Mastra configuration.
|
|
66
|
-
3. **Vercel Dashboard**: Variables can also be managed through Vercel's web interface.
|
|
67
|
-
|
|
68
|
-
The deployer automatically synchronizes environment variables between your local development environment and Vercel's environment variable system, ensuring consistency across all deployment environments (production, preview, and development).
|
|
69
|
-
|
|
70
28
|
## Lint Mastra Project
|
|
71
29
|
|
|
72
30
|
Lint your Mastra project to make sure it's fine to build
|
|
@@ -83,54 +41,26 @@ To build your Mastra project for Vercel deployment:
|
|
|
83
41
|
npx mastra build
|
|
84
42
|
```
|
|
85
43
|
|
|
86
|
-
The build process generates the following output structure in the `.
|
|
44
|
+
The build process generates the following output structure in the `.vercel/output` directory:
|
|
87
45
|
|
|
88
46
|
```
|
|
89
|
-
.
|
|
90
|
-
├── vercel.json # Vercel configuration
|
|
47
|
+
.vercel/output/functions/index.func
|
|
91
48
|
└── index.mjs # Application entry point
|
|
92
49
|
```
|
|
93
50
|
|
|
94
|
-
### Vercel Configuration
|
|
95
|
-
|
|
96
|
-
The VercelDeployer automatically generates a `vercel.json` configuration file in `.mastra/output` with the following settings:
|
|
97
|
-
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"version": 2,
|
|
101
|
-
"installCommand": "npm install --omit=dev",
|
|
102
|
-
"builds": [
|
|
103
|
-
{
|
|
104
|
-
"src": "index.mjs",
|
|
105
|
-
"use": "@vercel/node",
|
|
106
|
-
"config": {
|
|
107
|
-
"includeFiles": ["**"]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
"routes": [
|
|
112
|
-
{
|
|
113
|
-
"src": "/(.*)",
|
|
114
|
-
"dest": "index.mjs"
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
51
|
## Deployment Options
|
|
121
52
|
|
|
122
|
-
After building, you can deploy your Mastra application
|
|
53
|
+
After building, you can deploy your Mastra application to Vercel using any of these methods:
|
|
123
54
|
|
|
124
55
|
1. **Vercel CLI**: Deploy directly using Vercel's official CLI tool
|
|
125
56
|
|
|
126
57
|
- Install the CLI: `npm install -g vercel`
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
- For production deployment: `vercel --prod`
|
|
58
|
+
- Deploy to preview environment: `vercel --prebuilt`
|
|
59
|
+
- For production deployment: `vercel --prod --prebuilt`
|
|
130
60
|
|
|
131
61
|
2. **Vercel Dashboard**: Connect your Git repository or drag-and-drop the build output through the Vercel dashboard
|
|
132
62
|
|
|
133
|
-
> You can also run `vercel dev` in your
|
|
63
|
+
> You can also run `vercel dev` in your project directory to test your Mastra application locally. (Make sure you configured your dev command to `mastra dev`)
|
|
134
64
|
|
|
135
65
|
## Platform Documentation
|
|
136
66
|
|