@mastra/mcp-docs-server 0.13.1 → 0.13.2-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.
Files changed (102) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +21 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fagui.md +37 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fastra.md +25 -25
  4. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +48 -48
  5. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +71 -71
  6. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +62 -62
  7. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +25 -25
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +68 -68
  9. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +37 -37
  10. package/.docs/organized/changelogs/%40mastra%2Fcore.md +64 -64
  11. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +37 -31
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +80 -80
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +77 -77
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +73 -73
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +94 -94
  16. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +80 -41
  17. package/.docs/organized/changelogs/%40mastra%2Fevals.md +36 -36
  18. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +42 -42
  19. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +36 -36
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +59 -0
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +62 -62
  22. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +65 -65
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +45 -45
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +56 -56
  25. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +36 -36
  26. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +58 -58
  27. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +74 -74
  28. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +47 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fpg.md +75 -75
  30. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +14 -14
  31. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +107 -107
  32. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +37 -37
  33. package/.docs/organized/changelogs/%40mastra%2Frag.md +41 -41
  34. package/.docs/organized/changelogs/%40mastra%2Fragie.md +36 -36
  35. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fserver.md +61 -61
  37. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +37 -37
  38. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +75 -75
  39. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +14 -14
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +24 -24
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +36 -36
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +36 -36
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +36 -36
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +34 -0
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +36 -36
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +37 -37
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +25 -25
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +36 -36
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +36 -36
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +36 -36
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +36 -36
  52. package/.docs/organized/changelogs/create-mastra.md +35 -35
  53. package/.docs/organized/changelogs/mastra.md +116 -116
  54. package/.docs/organized/code-examples/a2a.md +1 -1
  55. package/.docs/organized/code-examples/agent-network.md +125 -7
  56. package/.docs/organized/code-examples/agent.md +1 -1
  57. package/.docs/organized/code-examples/agui.md +4 -4
  58. package/.docs/organized/code-examples/ai-sdk-useChat.md +6 -6
  59. package/.docs/organized/code-examples/assistant-ui.md +5 -5
  60. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
  61. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +5 -5
  62. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +5 -5
  63. package/.docs/organized/code-examples/client-side-tools.md +6 -6
  64. package/.docs/organized/code-examples/crypto-chatbot.md +4 -4
  65. package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
  66. package/.docs/organized/code-examples/fireworks-r1.md +1 -1
  67. package/.docs/organized/code-examples/mcp-configuration.md +2 -2
  68. package/.docs/organized/code-examples/mcp-registry-registry.md +1 -1
  69. package/.docs/organized/code-examples/memory-per-resource-example.md +236 -0
  70. package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
  71. package/.docs/organized/code-examples/memory-with-processors.md +1 -1
  72. package/.docs/organized/code-examples/openapi-spec-writer.md +5 -5
  73. package/.docs/organized/code-examples/quick-start.md +1 -1
  74. package/.docs/organized/code-examples/stock-price-tool.md +1 -1
  75. package/.docs/organized/code-examples/weather-agent.md +1 -1
  76. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
  77. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
  78. package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
  79. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
  80. package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +53 -10
  81. package/.docs/raw/local-dev/mastra-dev.mdx +103 -105
  82. package/.docs/raw/mastra-cloud/dashboard.mdx +100 -0
  83. package/.docs/raw/mastra-cloud/observability.mdx +24 -138
  84. package/.docs/raw/mastra-cloud/overview.mdx +50 -42
  85. package/.docs/raw/mastra-cloud/setting-up.mdx +51 -87
  86. package/.docs/raw/memory/overview.mdx +4 -0
  87. package/.docs/raw/memory/working-memory.mdx +88 -1
  88. package/.docs/raw/observability/nextjs-tracing.mdx +2 -2
  89. package/.docs/raw/reference/storage/libsql.mdx +1 -0
  90. package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -0
  91. package/.docs/raw/reference/workflows/sleep.mdx +43 -0
  92. package/.docs/raw/reference/workflows/sleepUntil.mdx +43 -0
  93. package/.docs/raw/reference/workflows/waitForEvent.mdx +49 -0
  94. package/.docs/raw/storage/overview.mdx +50 -1
  95. package/.docs/raw/tools-mcp/mcp-overview.mdx +52 -0
  96. package/.docs/raw/workflows/inngest-workflow.mdx +1 -1
  97. package/.docs/raw/workflows/input-data-mapping.mdx +4 -4
  98. package/.docs/raw/workflows/pausing-execution.mdx +60 -0
  99. package/package.json +6 -6
  100. package/.docs/raw/local-dev/add-to-existing-project.mdx +0 -43
  101. package/.docs/raw/local-dev/creating-a-new-project.mdx +0 -53
  102. 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
+ ```
@@ -18,7 +18,7 @@
18
18
  "@ai-sdk/openai": "latest",
19
19
  "@mastra/core": "latest",
20
20
  "@mastra/mem0": "latest",
21
- "zod": "^3.25.56"
21
+ "zod": "^3.25.67"
22
22
  },
23
23
  "pnpm": {
24
24
  "overrides": {
@@ -20,7 +20,7 @@
20
20
  "js-tiktoken": "^1.0.13",
21
21
  "tiktoken": "^1.0.13",
22
22
  "tsx": "^4.6.2",
23
- "zod": "^3.25.56"
23
+ "zod": "^3.25.67"
24
24
  },
25
25
  "pnpm": {
26
26
  "overrides": {
@@ -25,21 +25,21 @@
25
25
  "clsx": "^2.1.1",
26
26
  "lucide-react": "^0.454.0",
27
27
  "next": "15.2.4",
28
- "react": "^19.0.0",
29
- "react-dom": "^19.0.0",
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.56"
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.0.10",
42
- "@types/react-dom": "^19.0.4",
41
+ "@types/react": "^19.1.8",
42
+ "@types/react-dom": "^19.1.6",
43
43
  "@types/react-syntax-highlighter": "^15.5.13",
44
44
  "eslint": "^8.57.1",
45
45
  "eslint-config-next": "15.3.3",
@@ -16,7 +16,7 @@
16
16
  "@types/node": "^20.17.57",
17
17
  "tsx": "^4.19.3",
18
18
  "typescript": "^5.8.2",
19
- "zod": "^3.25.56"
19
+ "zod": "^3.25.67"
20
20
  },
21
21
  "dependencies": {
22
22
  "@ai-sdk/anthropic": "^1.2.12",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "@ai-sdk/openai": "latest",
18
18
  "@mastra/core": "latest",
19
- "zod": "^3.25.56"
19
+ "zod": "^3.25.67"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@jest/globals": "^29.7.0",
@@ -16,7 +16,7 @@
16
16
  "@ai-sdk/openai": "^1.3.22",
17
17
  "@mastra/core": "latest",
18
18
  "@mastra/libsql": "latest",
19
- "zod": "^3.25.56"
19
+ "zod": "^3.25.67"
20
20
  },
21
21
  "version": "0.0.1",
22
22
  "pnpm": {
@@ -19,7 +19,7 @@
19
19
  "mastra": "latest",
20
20
  "tsx": "^4.19.3",
21
21
  "typescript": "^5.8.2",
22
- "zod": "^3.25.56"
22
+ "zod": "^3.25.67"
23
23
  },
24
24
  "dependencies": {
25
25
  "@ai-sdk/openai": "latest",
@@ -17,7 +17,7 @@
17
17
  "mastra": "latest",
18
18
  "tsx": "^4.19.3",
19
19
  "typescript": "^5.8.2",
20
- "zod": "^3.25.56"
20
+ "zod": "^3.25.67"
21
21
  },
22
22
  "dependencies": {
23
23
  "@mastra/core": "latest"
@@ -16,7 +16,7 @@
16
16
  "@types/node": "^20.17.57",
17
17
  "tsx": "^4.19.3",
18
18
  "typescript": "^5.8.2",
19
- "zod": "^3.25.56"
19
+ "zod": "^3.25.67"
20
20
  },
21
21
  "dependencies": {
22
22
  "@ai-sdk/openai": "latest",
@@ -19,7 +19,7 @@
19
19
  "mastra": "latest",
20
20
  "tsx": "^4.19.3",
21
21
  "typescript": "^5.8.2",
22
- "zod": "^3.25.56"
22
+ "zod": "^3.25.67"
23
23
  },
24
24
  "dependencies": {
25
25
  "@mastra/core": "latest"
@@ -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/agui which provides CopilotKit integration capabilities.
89
- All commands install the same @mastra/agui@alpha package but use different package manager syntax.
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/agui@alpha
95
+ npm install @ag-ui/mastra
96
96
  ```
97
97
  </Tabs.Tab>
98
98
  <Tabs.Tab>
99
99
  ```bash copy
100
- yarn add @mastra/agui@alpha
100
+ yarn add @ag-ui/mastra
101
101
  ```
102
102
  </Tabs.Tab>
103
103
  <Tabs.Tab>
104
104
  ```bash copy
105
- pnpm add @mastra/agui@alpha
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/agui";
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 = getAGUI({
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
- ### Using Typed Runtime Context
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/agui";
312
+ import { registerCopilotKit } from "@ag-ui/mastra";
270
313
  import { weatherAgent } from "./agents";
271
314
 
272
315
  // Define your runtime context type