@mastra/mcp-docs-server 0.13.2-alpha.0 → 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%2Fagui.md +12 -0
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +32 -32
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +44 -44
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +42 -42
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Flance.md +25 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +24 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +38 -38
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Frag.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +32 -32
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +12 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +14 -14
- package/.docs/organized/changelogs/create-mastra.md +7 -7
- package/.docs/organized/changelogs/mastra.md +48 -48
- package/.docs/organized/code-examples/a2a.md +1 -1
- package/.docs/organized/code-examples/agent-network.md +125 -7
- package/.docs/organized/code-examples/agent.md +183 -6
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-sdk-useChat.md +6 -6
- package/.docs/organized/code-examples/assistant-ui.md +6 -6
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +6 -6
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +6 -6
- package/.docs/organized/code-examples/client-side-tools.md +6 -6
- package/.docs/organized/code-examples/crypto-chatbot.md +6 -6
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/mcp-configuration.md +2 -2
- package/.docs/organized/code-examples/mcp-registry-registry.md +1 -1
- package/.docs/organized/code-examples/memory-per-resource-example.md +236 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +6 -6
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/stock-price-tool.md +1 -1
- package/.docs/organized/code-examples/weather-agent.md +1 -1
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.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/frameworks/agentic-uis/copilotkit.mdx +53 -10
- package/.docs/raw/mastra-cloud/dashboard.mdx +100 -0
- package/.docs/raw/mastra-cloud/observability.mdx +24 -138
- package/.docs/raw/mastra-cloud/overview.mdx +50 -42
- package/.docs/raw/mastra-cloud/setting-up.mdx +51 -87
- package/.docs/raw/memory/overview.mdx +4 -0
- package/.docs/raw/memory/working-memory.mdx +144 -1
- 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/observability/nextjs-tracing.mdx +2 -2
- 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/storage/libsql.mdx +1 -0
- package/.docs/raw/reference/tools/mcp-client.mdx +244 -0
- package/.docs/raw/reference/tools/mcp-server.mdx +186 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -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/sleep.mdx +43 -0
- package/.docs/raw/reference/workflows/sleepUntil.mdx +43 -0
- package/.docs/raw/reference/workflows/start.mdx +1 -1
- package/.docs/raw/reference/workflows/stream.mdx +1 -1
- package/.docs/raw/reference/workflows/waitForEvent.mdx +49 -0
- package/.docs/raw/reference/workflows/watch.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +6 -2
- package/.docs/raw/storage/overview.mdx +50 -1
- package/.docs/raw/tools-mcp/mcp-overview.mdx +52 -0
- package/.docs/raw/workflows/control-flow.mdx +42 -1
- package/.docs/raw/workflows/inngest-workflow.mdx +1 -1
- package/.docs/raw/workflows/overview.mdx +73 -5
- package/.docs/raw/workflows/pausing-execution.mdx +60 -0
- 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 +6 -6
- package/.docs/raw/mastra-cloud/deploying.mdx +0 -142
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "memory-per-resource-example",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"private": true,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "tsx src/example.ts"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@ai-sdk/openai": "^0.0.68",
|
|
13
|
+
"@mastra/core": "latest",
|
|
14
|
+
"@mastra/memory": "latest",
|
|
15
|
+
"@mastra/libsql": "latest",
|
|
16
|
+
"chalk": "^5.3.0",
|
|
17
|
+
"dotenv": "^16.4.7",
|
|
18
|
+
"ora": "^8.1.1",
|
|
19
|
+
"tsx": "^4.19.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^20.19.0",
|
|
23
|
+
"typescript": "^5.8.3"
|
|
24
|
+
},
|
|
25
|
+
"pnpm": {
|
|
26
|
+
"overrides": {
|
|
27
|
+
"@mastra/core": "link:../../packages/core",
|
|
28
|
+
"@mastra/memory": "link:../../packages/memory",
|
|
29
|
+
"@mastra/libsql": "link:../../stores/libsql"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### example.ts
|
|
37
|
+
```typescript
|
|
38
|
+
import { maskStreamTags } from '@mastra/core/utils';
|
|
39
|
+
import chalk from 'chalk';
|
|
40
|
+
import { randomUUID } from 'crypto';
|
|
41
|
+
import ora from 'ora';
|
|
42
|
+
import Readline from 'readline';
|
|
43
|
+
|
|
44
|
+
import 'dotenv/config';
|
|
45
|
+
|
|
46
|
+
import { mastra } from './mastra';
|
|
47
|
+
|
|
48
|
+
const agent = mastra.getAgent('assistantAgent');
|
|
49
|
+
|
|
50
|
+
// 🆕 EXAMPLE: Per-Resource Working Memory
|
|
51
|
+
// This demonstrates how working memory persists across different conversation threads
|
|
52
|
+
// for the same user (resourceId), but is separate for different users.
|
|
53
|
+
|
|
54
|
+
console.log(chalk.bold.blue('\n🆕 Per-Resource Working Memory Example\n'));
|
|
55
|
+
console.log(chalk.gray('This example shows how working memory persists across conversation threads'));
|
|
56
|
+
console.log(chalk.gray('for the same user, but stays separate for different users.\n'));
|
|
57
|
+
|
|
58
|
+
// Simulate different users
|
|
59
|
+
const USERS = {
|
|
60
|
+
alice: 'user-alice-123',
|
|
61
|
+
bob: 'user-bob-456',
|
|
62
|
+
demo: 'demo-user-789',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Let user choose which user to simulate
|
|
66
|
+
console.log(chalk.yellow('Choose a user to simulate:'));
|
|
67
|
+
console.log(chalk.cyan('1. Alice (user-alice-123)'));
|
|
68
|
+
console.log(chalk.cyan('2. Bob (user-bob-456)'));
|
|
69
|
+
console.log(chalk.cyan('3. Demo User (demo-user-789)'));
|
|
70
|
+
console.log(chalk.gray('4. Or just press Enter to use a random user\n'));
|
|
71
|
+
|
|
72
|
+
const rl = Readline.createInterface({
|
|
73
|
+
input: process.stdin,
|
|
74
|
+
output: process.stdout,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const userChoice = await new Promise<string>(resolve => {
|
|
78
|
+
rl.question(chalk.yellow('Enter choice (1-4 or Enter): '), answer => {
|
|
79
|
+
resolve(answer.trim());
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
let resourceId: string;
|
|
84
|
+
let userName: string;
|
|
85
|
+
|
|
86
|
+
switch (userChoice) {
|
|
87
|
+
case '1':
|
|
88
|
+
resourceId = USERS.alice;
|
|
89
|
+
userName = 'Alice';
|
|
90
|
+
break;
|
|
91
|
+
case '2':
|
|
92
|
+
resourceId = USERS.bob;
|
|
93
|
+
userName = 'Bob';
|
|
94
|
+
break;
|
|
95
|
+
case '3':
|
|
96
|
+
resourceId = USERS.demo;
|
|
97
|
+
userName = 'Demo User';
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
resourceId = `user-${randomUUID()}`;
|
|
101
|
+
userName = 'Random User';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Always generate a new thread ID to demonstrate cross-thread persistence
|
|
105
|
+
const threadId = randomUUID();
|
|
106
|
+
|
|
107
|
+
console.log(chalk.green(`\n✅ Simulating: ${userName}`));
|
|
108
|
+
console.log(chalk.gray(`📧 Resource ID: ${resourceId}`));
|
|
109
|
+
console.log(chalk.gray(`🧵 Thread ID: ${threadId}`));
|
|
110
|
+
console.log(chalk.bold.yellow('\n💡 TIP: Run this example multiple times with the same user choice'));
|
|
111
|
+
console.log(chalk.bold.yellow(' to see how working memory persists across conversation threads!\n'));
|
|
112
|
+
|
|
113
|
+
async function logResponse(res: Awaited<ReturnType<typeof agent.stream>>) {
|
|
114
|
+
console.log(chalk.blue('\n🤖 Assistant:'));
|
|
115
|
+
|
|
116
|
+
const memorySpinner = ora('💾 Updating memory...');
|
|
117
|
+
|
|
118
|
+
// Mask working memory updates with a spinner
|
|
119
|
+
const maskedStream = maskStreamTags(res.textStream, 'working_memory', {
|
|
120
|
+
onStart: () => memorySpinner.start(),
|
|
121
|
+
onEnd: () => {
|
|
122
|
+
if (memorySpinner.isSpinning) {
|
|
123
|
+
memorySpinner.succeed(chalk.green('💾 Memory updated!'));
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
for await (const chunk of maskedStream) {
|
|
129
|
+
process.stdout.write(chunk);
|
|
130
|
+
}
|
|
131
|
+
console.log('\n');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function main() {
|
|
135
|
+
// Start the conversation
|
|
136
|
+
await logResponse(
|
|
137
|
+
await agent.stream(
|
|
138
|
+
[
|
|
139
|
+
{
|
|
140
|
+
role: 'system',
|
|
141
|
+
content: `New conversation thread started at ${new Date().toISOString()}.
|
|
142
|
+
This may be a returning user - check your working memory to see if you know them already.
|
|
143
|
+
If this is a new user, introduce yourself and learn about them.
|
|
144
|
+
If this is a returning user, greet them warmly and reference what you remember!`,
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
{ threadId, resourceId },
|
|
148
|
+
),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
// Interactive chat loop
|
|
152
|
+
while (true) {
|
|
153
|
+
const userInput: string = await new Promise(resolve => {
|
|
154
|
+
rl.question(chalk.yellow('\n💬 You: '), answer => {
|
|
155
|
+
resolve(answer);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (userInput.toLowerCase() === 'exit' || userInput.toLowerCase() === 'quit') {
|
|
160
|
+
console.log(chalk.gray('\n👋 Goodbye! Run the example again to see memory persistence!\n'));
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
await logResponse(await agent.stream(userInput, { threadId, resourceId }));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
rl.close();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
main().catch(console.error);
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### mastra/agents/index.ts
|
|
175
|
+
```typescript
|
|
176
|
+
import { openai } from '@ai-sdk/openai';
|
|
177
|
+
import { Agent } from '@mastra/core/agent';
|
|
178
|
+
import { Memory } from '@mastra/memory';
|
|
179
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
180
|
+
|
|
181
|
+
// Create LibSQL storage for persistent per-resource working memory
|
|
182
|
+
const storage = new LibSQLStore({
|
|
183
|
+
url: 'file:./memory-demo.db',
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
export const memory = new Memory({
|
|
187
|
+
storage,
|
|
188
|
+
options: {
|
|
189
|
+
lastMessages: 5,
|
|
190
|
+
workingMemory: {
|
|
191
|
+
enabled: true,
|
|
192
|
+
scope: 'resource', // 🆕 NEW: Per-resource working memory!
|
|
193
|
+
template: `# User Profile
|
|
194
|
+
- **Name**:
|
|
195
|
+
- **Location**:
|
|
196
|
+
- **Interests**:
|
|
197
|
+
- **Preferences**:
|
|
198
|
+
- **Goals**:
|
|
199
|
+
- **Important Notes**:
|
|
200
|
+
`,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
export const assistantAgent = new Agent({
|
|
206
|
+
name: 'Personal Assistant',
|
|
207
|
+
instructions: `You are a helpful personal assistant with persistent memory across ALL conversations.
|
|
208
|
+
|
|
209
|
+
🆕 IMPORTANT: You have resource-scoped working memory! This means:
|
|
210
|
+
- Everything you learn about this user persists across ALL conversation threads
|
|
211
|
+
- Even if they start a completely new conversation, you'll remember them
|
|
212
|
+
- You should build up a comprehensive profile of the user over time
|
|
213
|
+
|
|
214
|
+
Always use <working_memory> tags to update what you know about the user:
|
|
215
|
+
- Their name and personal details
|
|
216
|
+
- Their interests and preferences
|
|
217
|
+
- Their goals and what they're working on
|
|
218
|
+
- Any important context from previous conversations
|
|
219
|
+
|
|
220
|
+
When you first meet someone, ask for their name and learn about them. In subsequent conversations (even new threads), greet them by name and reference what you remember!`,
|
|
221
|
+
model: openai('gpt-4o-mini'),
|
|
222
|
+
memory,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### mastra/index.ts
|
|
228
|
+
```typescript
|
|
229
|
+
import { Mastra } from '@mastra/core';
|
|
230
|
+
import { assistantAgent } from './agents';
|
|
231
|
+
|
|
232
|
+
export const mastra = new Mastra({
|
|
233
|
+
agents: { assistantAgent },
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
```
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"clsx": "^2.1.1",
|
|
26
26
|
"lucide-react": "^0.454.0",
|
|
27
27
|
"next": "15.2.4",
|
|
28
|
-
"react": "^19.
|
|
29
|
-
"react-dom": "^19.
|
|
28
|
+
"react": "^19.1.0",
|
|
29
|
+
"react-dom": "^19.1.0",
|
|
30
30
|
"react-syntax-highlighter": "^15.6.1",
|
|
31
31
|
"sharp": "^0.33.5",
|
|
32
32
|
"tailwind-merge": "^2.6.0",
|
|
33
33
|
"tailwindcss-animate": "^1.0.7",
|
|
34
34
|
"vaul": "^1.1.2",
|
|
35
|
-
"zod": "^3.25.
|
|
35
|
+
"zod": "^3.25.67"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@libsql/client": "^0.15.4",
|
|
39
39
|
"@types/js-yaml": "^4.0.9",
|
|
40
40
|
"@types/node": "^20.17.57",
|
|
41
|
-
"@types/react": "^19.
|
|
42
|
-
"@types/react-dom": "^19.
|
|
41
|
+
"@types/react": "^19.1.8",
|
|
42
|
+
"@types/react-dom": "^19.1.6",
|
|
43
43
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
44
|
-
"eslint": "^
|
|
44
|
+
"eslint": "^9.29.0",
|
|
45
45
|
"eslint-config-next": "15.3.3",
|
|
46
46
|
"postcss": "^8.5.3",
|
|
47
47
|
"tailwindcss": "^3.4.17",
|
|
@@ -75,8 +75,6 @@ Once you have a server you want to use with your agent, import the Mastra `MCPCl
|
|
|
75
75
|
|
|
76
76
|
```typescript filename="src/mastra/mcp.ts" {1,7-16}
|
|
77
77
|
import { MCPClient } from "@mastra/mcp";
|
|
78
|
-
import { Agent } from "@mastra/core/agent";
|
|
79
|
-
import { openai } from "@ai-sdk/openai";
|
|
80
78
|
|
|
81
79
|
// Configure MCPClient to connect to your server(s)
|
|
82
80
|
export const mcp = new MCPClient({
|
|
@@ -96,7 +94,10 @@ export const mcp = new MCPClient({
|
|
|
96
94
|
Then connect your agent to the server tools:
|
|
97
95
|
|
|
98
96
|
```typescript filename="src/mastra/agents/mcpAgent.ts" {7}
|
|
97
|
+
import { Agent } from "@mastra/core/agent";
|
|
98
|
+
import { openai } from "@ai-sdk/openai";
|
|
99
99
|
import { mcp } from "../mcp";
|
|
100
|
+
|
|
100
101
|
// Create an agent and add tools from the MCP client
|
|
101
102
|
const agent = new Agent({
|
|
102
103
|
name: "Agent with MCP Tools",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Digital Ocean"
|
|
3
|
+
description: "Deploy your Mastra applications to Digital Ocean."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Callout, Steps, Tabs } from "nextra/components";
|
|
7
|
+
import ServerConfig from "@/components/content-blocks/server-config.mdx";
|
|
8
|
+
|
|
9
|
+
## Digital Ocean
|
|
10
|
+
|
|
11
|
+
Deploy your Mastra applications to Digital Ocean's App Platform and Droplets.
|
|
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](./../../getting-started/installation.mdx)
|
|
18
|
+
</Callout>
|
|
19
|
+
|
|
20
|
+
<Tabs items={["App Platform", "Droplets"]}>
|
|
21
|
+
|
|
22
|
+
<Tabs.Tab>
|
|
23
|
+
|
|
24
|
+
### App Platform
|
|
25
|
+
|
|
26
|
+
#### Prerequisites [#app-platform-prerequisites]
|
|
27
|
+
|
|
28
|
+
- A Git repository containing your Mastra application. This can be a GitHub repository, GitLab repository, or any other compatible source provider.
|
|
29
|
+
- A Digital Ocean account
|
|
30
|
+
|
|
31
|
+
#### Deployment Steps
|
|
32
|
+
|
|
33
|
+
<Steps>
|
|
34
|
+
|
|
35
|
+
#### Create a new App
|
|
36
|
+
|
|
37
|
+
- Log in to your Digital Ocean dashboard.
|
|
38
|
+
- Navigate to the App Platform service.
|
|
39
|
+
- Select your source provider and create a new app.
|
|
40
|
+
|
|
41
|
+
#### Configure Deployment Source
|
|
42
|
+
|
|
43
|
+
- Connect and select your repository. You may also choose a container image or a sample app.
|
|
44
|
+
- Select the branch you want to deploy from.
|
|
45
|
+
- Configure the source directory if necessary. If your Mastra application uses the default directory structure, no action is required here.
|
|
46
|
+
- Head to the next step.
|
|
47
|
+
|
|
48
|
+
#### Configure Resource Settings and Environment Variables
|
|
49
|
+
|
|
50
|
+
- A Node.js build should be detected automatically.
|
|
51
|
+
- Add any required environment variables for your Mastra application. This includes API keys, database URLs, and other configuration values.
|
|
52
|
+
- You may choose to configure the size of your resource here.
|
|
53
|
+
- Other things you may optionally configure include, the region of your resource, the unique app name, and what project the resource belongs to.
|
|
54
|
+
- Once you're done, you may create the app after reviewing your configuration and pricing estimates.
|
|
55
|
+
|
|
56
|
+
#### Deployment
|
|
57
|
+
|
|
58
|
+
- Your app will be built and deployed automatically.
|
|
59
|
+
- Digital Ocean will provide you with a URL to access your deployed application.
|
|
60
|
+
|
|
61
|
+
</Steps>
|
|
62
|
+
|
|
63
|
+
You can now access your deployed application at the URL provided by Digital Ocean.
|
|
64
|
+
|
|
65
|
+
<Callout>
|
|
66
|
+
The Digital Ocean App Platform uses an ephemeral file system,
|
|
67
|
+
meaning that any files written to the file system are short-lived and may be lost.
|
|
68
|
+
Avoid using a Mastra storage provider that uses the file system,
|
|
69
|
+
such as `LibSQLStore` with a file URL.
|
|
70
|
+
</Callout>
|
|
71
|
+
|
|
72
|
+
</Tabs.Tab>
|
|
73
|
+
|
|
74
|
+
<Tabs.Tab>
|
|
75
|
+
|
|
76
|
+
### Droplets
|
|
77
|
+
|
|
78
|
+
Deploy your Mastra application to Digital Ocean's Droplets.
|
|
79
|
+
This guide will cover setting up a droplet, a reverse proxy using Nginx, and running your Mastra application.
|
|
80
|
+
|
|
81
|
+
<Callout>
|
|
82
|
+
The guide assumes your droplet runs Ubuntu 24+.
|
|
83
|
+
</Callout>
|
|
84
|
+
|
|
85
|
+
#### Prerequisites [#droplets-prerequisites]
|
|
86
|
+
|
|
87
|
+
- A Digital Ocean account
|
|
88
|
+
- A droplet running Ubuntu 24+
|
|
89
|
+
- A domain name with an A record pointing to your droplet
|
|
90
|
+
|
|
91
|
+
#### Setting up the droplet
|
|
92
|
+
|
|
93
|
+
<ServerConfig />
|
|
94
|
+
|
|
95
|
+
</Tabs.Tab>
|
|
96
|
+
|
|
97
|
+
</Tabs>
|
|
98
|
+
|
|
99
|
+
### Connect to your Mastra server
|
|
100
|
+
|
|
101
|
+
You can now connect to your Mastra server from your client application using a `MastraClient` from the `@mastra/client-js` package.
|
|
102
|
+
|
|
103
|
+
Refer to the [`MastraClient` documentation](../../client-js/overview.mdx) for more information.
|
|
104
|
+
|
|
105
|
+
```typescript copy showLineNumbers
|
|
106
|
+
import { MastraClient } from "@mastra/client-js";
|
|
107
|
+
|
|
108
|
+
const mastraClient = new MastraClient({
|
|
109
|
+
baseUrl: "https://<your-domain-name>",
|
|
110
|
+
});
|
|
111
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Cloud Providers"
|
|
3
|
+
description: "Deploy your Mastra applications to popular cloud providers."
|
|
4
|
+
asIndexPage: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { CardGrid, CardGridItem } from "@/components/cards/card-grid";
|
|
8
|
+
|
|
9
|
+
## Cloud Providers
|
|
10
|
+
|
|
11
|
+
Deploy your Mastra applicaitons to popular cloud providers.
|
|
12
|
+
|
|
13
|
+
<CardGrid>
|
|
14
|
+
<CardGridItem title="Digital Ocean" description="Deploy your Mastra applications to Digital Ocean" href="./cloud-providers/digital-ocean" />
|
|
15
|
+
</CardGrid>
|
|
@@ -85,24 +85,24 @@ The current version of the integration leverages `MastraClient` to format Mastra
|
|
|
85
85
|
{/*
|
|
86
86
|
LLM CONTEXT: This Tabs component shows installation commands for the Mastra AGUI package.
|
|
87
87
|
Each tab displays the installation command for that specific package manager.
|
|
88
|
-
This installs the alpha version of @mastra
|
|
89
|
-
All commands install the same @mastra
|
|
88
|
+
This installs the alpha version of @ag-ui/mastra which provides CopilotKit integration capabilities.
|
|
89
|
+
All commands install the same @ag-ui/mastra package but use different package manager syntax.
|
|
90
90
|
*/}
|
|
91
91
|
|
|
92
92
|
<Tabs items={["npm", "yarn", "pnpm"]}>
|
|
93
93
|
<Tabs.Tab>
|
|
94
94
|
```bash copy
|
|
95
|
-
npm install @mastra
|
|
95
|
+
npm install @ag-ui/mastra
|
|
96
96
|
```
|
|
97
97
|
</Tabs.Tab>
|
|
98
98
|
<Tabs.Tab>
|
|
99
99
|
```bash copy
|
|
100
|
-
yarn add @mastra
|
|
100
|
+
yarn add @ag-ui/mastra
|
|
101
101
|
```
|
|
102
102
|
</Tabs.Tab>
|
|
103
103
|
<Tabs.Tab>
|
|
104
104
|
```bash copy
|
|
105
|
-
pnpm add @mastra
|
|
105
|
+
pnpm add @ag-ui/mastra
|
|
106
106
|
```
|
|
107
107
|
</Tabs.Tab>
|
|
108
108
|
</Tabs>
|
|
@@ -114,7 +114,7 @@ import { Mastra } from "@mastra/core/mastra";
|
|
|
114
114
|
import { PinoLogger } from "@mastra/loggers";
|
|
115
115
|
import { LibSQLStore } from "@mastra/libsql";
|
|
116
116
|
import { CopilotRuntime, copilotRuntimeNodeHttpEndpoint, ExperimentalEmptyAdapter } from "@copilotkit/runtime";
|
|
117
|
-
import { registerCopilotKit } from "@mastra
|
|
117
|
+
import { registerCopilotKit } from "@ag-ui/mastra";
|
|
118
118
|
import { weatherAgent } from "./agents/weather-agent";
|
|
119
119
|
|
|
120
120
|
const serviceAdapter = new ExperimentalEmptyAdapter();
|
|
@@ -231,6 +231,7 @@ import {
|
|
|
231
231
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
232
232
|
} from "@copilotkit/runtime";
|
|
233
233
|
import { NextRequest } from "next/server";
|
|
234
|
+
import { MastraAgent } from "@ag-ui/mastra";
|
|
234
235
|
|
|
235
236
|
export const POST = async (req: NextRequest) => {
|
|
236
237
|
// Clone the request before reading the body
|
|
@@ -238,11 +239,52 @@ export const POST = async (req: NextRequest) => {
|
|
|
238
239
|
const body = await clonedReq.json();
|
|
239
240
|
const resourceId = body.resourceId || "TEST";
|
|
240
241
|
|
|
241
|
-
const mastraAgents =
|
|
242
|
-
mastra,
|
|
242
|
+
const mastraAgents = MastraAgent.getLocalAgents({
|
|
243
243
|
resourceId,
|
|
244
|
+
mastra,
|
|
245
|
+
runtimeContext,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const runtime = new CopilotRuntime({
|
|
249
|
+
agents: mastraAgents,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
|
|
253
|
+
runtime,
|
|
254
|
+
serviceAdapter: new ExperimentalEmptyAdapter(),
|
|
255
|
+
endpoint: "/api/copilotkit",
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Use the original request for handleRequest
|
|
259
|
+
return handleRequest(req);
|
|
260
|
+
};
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Using with Mastra Client SDK
|
|
264
|
+
|
|
265
|
+
```typescript copy
|
|
266
|
+
import { MastraClient } from "@mastra/client-js";
|
|
267
|
+
import {
|
|
268
|
+
CopilotRuntime,
|
|
269
|
+
ExperimentalEmptyAdapter,
|
|
270
|
+
copilotRuntimeNextJSAppRouterEndpoint,
|
|
271
|
+
} from "@copilotkit/runtime";
|
|
272
|
+
import { NextRequest } from "next/server";
|
|
273
|
+
import { MastraAgent } from "@ag-ui/mastra";
|
|
274
|
+
|
|
275
|
+
export const POST = async (req: NextRequest) => {
|
|
276
|
+
// Clone the request before reading the body
|
|
277
|
+
const clonedReq = req.clone();
|
|
278
|
+
const body = await clonedReq.json();
|
|
279
|
+
const resourceId = body.resourceId || "TEST";
|
|
280
|
+
|
|
281
|
+
const baseUrl = process.env.MASTRA_BASE_URL || "http://localhost:4111";
|
|
282
|
+
const mastraClient = new MastraClient({
|
|
283
|
+
baseUrl,
|
|
244
284
|
});
|
|
245
285
|
|
|
286
|
+
const mastraAgents = await MastraAgent.getRemoteAgents({ mastraClient });
|
|
287
|
+
|
|
246
288
|
const runtime = new CopilotRuntime({
|
|
247
289
|
agents: mastraAgents,
|
|
248
290
|
});
|
|
@@ -258,7 +300,8 @@ export const POST = async (req: NextRequest) => {
|
|
|
258
300
|
};
|
|
259
301
|
```
|
|
260
302
|
|
|
261
|
-
|
|
303
|
+
|
|
304
|
+
## Using Typed Runtime Context
|
|
262
305
|
|
|
263
306
|
For better type safety, you can specify the type of your runtime context:
|
|
264
307
|
|
|
@@ -266,7 +309,7 @@ For better type safety, you can specify the type of your runtime context:
|
|
|
266
309
|
import { Mastra } from "@mastra/core/mastra";
|
|
267
310
|
import { PinoLogger } from "@mastra/loggers";
|
|
268
311
|
import { LibSQLStore } from "@mastra/libsql";
|
|
269
|
-
import { registerCopilotKit } from "@mastra
|
|
312
|
+
import { registerCopilotKit } from "@ag-ui/mastra";
|
|
270
313
|
import { weatherAgent } from "./agents";
|
|
271
314
|
|
|
272
315
|
// Define your runtime context type
|