@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
|
@@ -17,14 +17,18 @@
|
|
|
17
17
|
"@ai-sdk/openai": "^1.3.22",
|
|
18
18
|
"@mastra/client-js": "latest",
|
|
19
19
|
"@mastra/core": "latest",
|
|
20
|
+
"@mastra/libsql": "latest",
|
|
20
21
|
"@mastra/loggers": "latest",
|
|
21
|
-
"
|
|
22
|
+
"@mastra/memory": "latest",
|
|
23
|
+
"zod": "^3.25.67"
|
|
22
24
|
},
|
|
23
25
|
"pnpm": {
|
|
24
26
|
"overrides": {
|
|
25
27
|
"@mastra/client-js": "link:../../client-sdks/client-js",
|
|
26
28
|
"@mastra/core": "link:../../packages/core",
|
|
27
|
-
"@mastra/
|
|
29
|
+
"@mastra/libsql": "link:../../stores/libsql",
|
|
30
|
+
"@mastra/loggers": "link:../../packages/loggers",
|
|
31
|
+
"@mastra/memory": "link:../../packages/memory"
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
|
|
@@ -198,19 +202,28 @@ export const dataAnalysisAgent = new Agent({
|
|
|
198
202
|
```typescript
|
|
199
203
|
import { Mastra } from '@mastra/core';
|
|
200
204
|
import { PinoLogger } from '@mastra/loggers';
|
|
201
|
-
import { researchNetwork } from './network';
|
|
205
|
+
// import { researchNetwork } from './network';
|
|
202
206
|
import { webSearchAgent } from './agents';
|
|
203
|
-
import { agentWorkflow } from './workflows';
|
|
207
|
+
// import { agentWorkflow } from './workflows';
|
|
208
|
+
import { v_nextNetwork } from './network/v-next';
|
|
209
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
210
|
+
import { workflow1 } from './network/v-next';
|
|
204
211
|
|
|
205
212
|
export const mastra = new Mastra({
|
|
206
213
|
agents: {
|
|
207
214
|
webSearchAgent,
|
|
208
215
|
},
|
|
209
|
-
networks: {
|
|
210
|
-
|
|
216
|
+
// networks: {
|
|
217
|
+
// researchNetwork,
|
|
218
|
+
// },
|
|
219
|
+
vnext_networks: {
|
|
220
|
+
v_nextNetwork,
|
|
211
221
|
},
|
|
222
|
+
storage: new LibSQLStore({
|
|
223
|
+
url: 'file:../mastra.db', // Or your database URL
|
|
224
|
+
}),
|
|
212
225
|
workflows: {
|
|
213
|
-
|
|
226
|
+
workflow1,
|
|
214
227
|
},
|
|
215
228
|
logger: new PinoLogger({ name: 'Chef', level: 'info' }),
|
|
216
229
|
serverMiddleware: [
|
|
@@ -263,6 +276,111 @@ export const researchNetwork = new AgentNetwork({
|
|
|
263
276
|
|
|
264
277
|
```
|
|
265
278
|
|
|
279
|
+
### mastra/network/v-next.ts
|
|
280
|
+
```typescript
|
|
281
|
+
import { openai } from '@ai-sdk/openai';
|
|
282
|
+
import { NewAgentNetwork } from '@mastra/core/network/vNext';
|
|
283
|
+
import { Agent } from '@mastra/core/agent';
|
|
284
|
+
import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
285
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
286
|
+
import { Memory } from '@mastra/memory';
|
|
287
|
+
import { z } from 'zod';
|
|
288
|
+
|
|
289
|
+
const memory = new Memory({
|
|
290
|
+
storage: new LibSQLStore({
|
|
291
|
+
url: 'file:../mastra.db', // Or your database URL
|
|
292
|
+
}),
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const agent1 = new Agent({
|
|
296
|
+
name: 'agent1',
|
|
297
|
+
instructions:
|
|
298
|
+
'This agent is used to do research, but not create full responses. Answer in bullet points only and be concise.',
|
|
299
|
+
description:
|
|
300
|
+
'This agent is used to do research, but not create full responses. Answer in bullet points only and be concise.',
|
|
301
|
+
model: openai('gpt-4o'),
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const agent2 = new Agent({
|
|
305
|
+
name: 'agent2',
|
|
306
|
+
description: 'This agent is used to do text synthesis on researched material. It writes articles in full paragraphs.',
|
|
307
|
+
instructions:
|
|
308
|
+
'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.',
|
|
309
|
+
model: openai('gpt-4o'),
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
const agentStep1 = createStep({
|
|
313
|
+
id: 'agent-workflow-step-1',
|
|
314
|
+
description: 'This step is used to do research and text synthesis.',
|
|
315
|
+
inputSchema: z.object({
|
|
316
|
+
city: z.string().describe('The city to research'),
|
|
317
|
+
}),
|
|
318
|
+
outputSchema: z.object({
|
|
319
|
+
text: z.string(),
|
|
320
|
+
}),
|
|
321
|
+
execute: async ({ inputData }) => {
|
|
322
|
+
const resp = await agent1.generate(inputData.city, {
|
|
323
|
+
output: z.object({
|
|
324
|
+
text: z.string(),
|
|
325
|
+
}),
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
return { text: resp.object.text };
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const agentStep2 = createStep({
|
|
333
|
+
id: 'agent-workflow-step-2',
|
|
334
|
+
description: 'This step is used to do research and text synthesis.',
|
|
335
|
+
inputSchema: z.object({
|
|
336
|
+
text: z.string().describe('The city to research'),
|
|
337
|
+
}),
|
|
338
|
+
outputSchema: z.object({
|
|
339
|
+
text: z.string(),
|
|
340
|
+
}),
|
|
341
|
+
execute: async ({ inputData }) => {
|
|
342
|
+
const resp = await agent2.generate(inputData.text, {
|
|
343
|
+
output: z.object({
|
|
344
|
+
text: z.string(),
|
|
345
|
+
}),
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
return { text: resp.object.text };
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
export const workflow1 = createWorkflow({
|
|
353
|
+
id: 'workflow1',
|
|
354
|
+
description: 'This workflow is perfect for researching a specific city.',
|
|
355
|
+
inputSchema: z.object({
|
|
356
|
+
city: z.string(),
|
|
357
|
+
}),
|
|
358
|
+
outputSchema: z.object({
|
|
359
|
+
text: z.string(),
|
|
360
|
+
}),
|
|
361
|
+
})
|
|
362
|
+
.then(agentStep1)
|
|
363
|
+
.then(agentStep2)
|
|
364
|
+
.commit();
|
|
365
|
+
|
|
366
|
+
export const v_nextNetwork = new NewAgentNetwork({
|
|
367
|
+
id: 'test-network',
|
|
368
|
+
name: 'Test Network',
|
|
369
|
+
instructions:
|
|
370
|
+
'You can research cities. You can also synthesize research material. You can also write a full report based on the researched material.',
|
|
371
|
+
model: openai('gpt-4o'),
|
|
372
|
+
agents: {
|
|
373
|
+
agent1,
|
|
374
|
+
agent2,
|
|
375
|
+
},
|
|
376
|
+
workflows: {
|
|
377
|
+
workflow1,
|
|
378
|
+
},
|
|
379
|
+
memory: memory,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
```
|
|
383
|
+
|
|
266
384
|
### mastra/workflows/index.ts
|
|
267
385
|
```typescript
|
|
268
386
|
import { Workflow } from '@mastra/core/workflows';
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"ai": "^4.3.16",
|
|
20
20
|
"fetch-to-node": "^2.1.0",
|
|
21
21
|
"mastra": "latest",
|
|
22
|
-
"zod": "^3.25.
|
|
22
|
+
"zod": "^3.25.67"
|
|
23
23
|
},
|
|
24
24
|
"pnpm": {
|
|
25
25
|
"overrides": {
|
|
@@ -50,21 +50,147 @@
|
|
|
50
50
|
### client.ts
|
|
51
51
|
```typescript
|
|
52
52
|
import { MCPClient } from '@mastra/mcp';
|
|
53
|
+
// import type { ElicitationHandler } from '@mastra/mcp';
|
|
54
|
+
import { createInterface } from 'readline';
|
|
55
|
+
|
|
56
|
+
// Create readline interface for user input
|
|
57
|
+
const readline = createInterface({
|
|
58
|
+
input: process.stdin,
|
|
59
|
+
output: process.stdout,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Helper function to prompt user for input
|
|
63
|
+
function askQuestion(question: string): Promise<string> {
|
|
64
|
+
return new Promise(resolve => {
|
|
65
|
+
readline.question(question, answer => {
|
|
66
|
+
resolve(answer.trim());
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Elicitation handler that prompts the user for input
|
|
72
|
+
const elicitationHandler = async request => {
|
|
73
|
+
console.log('\n🔔 Elicitation Request Received:');
|
|
74
|
+
console.log(`Message: ${request.message}`);
|
|
75
|
+
console.log('Requested Schema:');
|
|
76
|
+
console.log(JSON.stringify(request.requestedSchema, null, 2));
|
|
77
|
+
|
|
78
|
+
const schema = request.requestedSchema;
|
|
79
|
+
const properties = schema.properties;
|
|
80
|
+
const required = schema.required || [];
|
|
81
|
+
|
|
82
|
+
console.log('\nPlease provide the following information:');
|
|
83
|
+
|
|
84
|
+
const content: Record<string, unknown> = {};
|
|
85
|
+
|
|
86
|
+
// Collect input for each field
|
|
87
|
+
for (const [fieldName, fieldSchema] of Object.entries(properties)) {
|
|
88
|
+
const field = fieldSchema as {
|
|
89
|
+
type?: string;
|
|
90
|
+
title?: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
format?: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const isRequired = required.includes(fieldName);
|
|
96
|
+
let prompt = `${field.title || fieldName}`;
|
|
97
|
+
|
|
98
|
+
// Add helpful information to the prompt
|
|
99
|
+
if (field.description) {
|
|
100
|
+
prompt += ` (${field.description})`;
|
|
101
|
+
}
|
|
102
|
+
if (field.format) {
|
|
103
|
+
prompt += ` [format: ${field.format}]`;
|
|
104
|
+
}
|
|
105
|
+
if (isRequired) {
|
|
106
|
+
prompt += ' *required*';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
prompt += ': ';
|
|
110
|
+
|
|
111
|
+
const answer = await askQuestion(prompt);
|
|
112
|
+
|
|
113
|
+
// Check for cancellation
|
|
114
|
+
if (answer.toLowerCase() === 'cancel' || answer.toLowerCase() === 'c') {
|
|
115
|
+
return { action: 'cancel' as const };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Handle empty responses
|
|
119
|
+
if (answer === '' && isRequired) {
|
|
120
|
+
console.log(`❌ Error: ${fieldName} is required`);
|
|
121
|
+
return { action: 'reject' as const };
|
|
122
|
+
} else if (answer !== '') {
|
|
123
|
+
content[fieldName] = answer;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Show the collected data and ask for confirmation
|
|
128
|
+
console.log('\n✅ Collected data:');
|
|
129
|
+
console.log(JSON.stringify(content, null, 2));
|
|
130
|
+
|
|
131
|
+
const confirmAnswer = await askQuestion('\nSubmit this information? (yes/no/cancel): ');
|
|
132
|
+
|
|
133
|
+
if (confirmAnswer.toLowerCase() === 'yes' || confirmAnswer.toLowerCase() === 'y') {
|
|
134
|
+
return {
|
|
135
|
+
action: 'accept' as const,
|
|
136
|
+
content,
|
|
137
|
+
};
|
|
138
|
+
} else if (confirmAnswer.toLowerCase() === 'cancel' || confirmAnswer.toLowerCase() === 'c') {
|
|
139
|
+
return { action: 'cancel' as const };
|
|
140
|
+
} else {
|
|
141
|
+
return { action: 'reject' as const };
|
|
142
|
+
}
|
|
143
|
+
};
|
|
53
144
|
|
|
54
145
|
async function main() {
|
|
55
146
|
const mcpClient = new MCPClient({
|
|
56
147
|
servers: {
|
|
57
|
-
|
|
58
|
-
url: new URL('http://localhost:4111/api/mcp/
|
|
148
|
+
myMcpServerTwo: {
|
|
149
|
+
url: new URL('http://localhost:4111/api/mcp/myMcpServerTwo/mcp'),
|
|
59
150
|
},
|
|
60
151
|
},
|
|
61
152
|
});
|
|
62
153
|
|
|
63
|
-
|
|
64
|
-
|
|
154
|
+
mcpClient.elicitation.onRequest('myMcpServerTwo', elicitationHandler);
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
console.log('Connecting to MCP server...');
|
|
158
|
+
const tools = await mcpClient.getTools();
|
|
159
|
+
console.log('Available tools:', Object.keys(tools));
|
|
160
|
+
|
|
161
|
+
// Test the elicitation functionality
|
|
162
|
+
console.log('\n🧪 Testing elicitation functionality...');
|
|
163
|
+
|
|
164
|
+
// Find the collectContactInfo tool
|
|
165
|
+
const collectContactInfoTool = tools['myMcpServerTwo_collectContactInfo'];
|
|
166
|
+
if (collectContactInfoTool) {
|
|
167
|
+
console.log('\nCalling collectContactInfo tool...');
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const result = await collectContactInfoTool.execute({
|
|
171
|
+
context: {
|
|
172
|
+
reason: 'We need your contact information to send you updates about our service.',
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
console.log('\n📋 Tool Result:');
|
|
177
|
+
console.log(result);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('❌ Error calling collectContactInfo tool:', error);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
console.log('❌ collectContactInfo tool not found');
|
|
183
|
+
console.log('Available tools:', Object.keys(tools));
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.error('❌ Error:', error);
|
|
187
|
+
} finally {
|
|
188
|
+
readline.close();
|
|
189
|
+
await mcpClient.disconnect();
|
|
190
|
+
}
|
|
65
191
|
}
|
|
66
192
|
|
|
67
|
-
main();
|
|
193
|
+
main().catch(console.error);
|
|
68
194
|
|
|
69
195
|
```
|
|
70
196
|
|
|
@@ -664,6 +790,57 @@ export const myMcpServerTwo = new MCPServer({
|
|
|
664
790
|
return `Hello, ${context.name}! Welcome to the MCP server.`;
|
|
665
791
|
},
|
|
666
792
|
}),
|
|
793
|
+
collectContactInfo: createTool({
|
|
794
|
+
id: 'collectContactInfo',
|
|
795
|
+
description: 'Collects user contact information through elicitation.',
|
|
796
|
+
inputSchema: z.object({
|
|
797
|
+
reason: z.string().optional().describe('Optional reason for collecting contact info'),
|
|
798
|
+
}),
|
|
799
|
+
execute: async ({ context }, options) => {
|
|
800
|
+
const { reason } = context;
|
|
801
|
+
|
|
802
|
+
try {
|
|
803
|
+
// Use the session-aware elicitation functionality
|
|
804
|
+
const result = await options.elicitation.sendRequest({
|
|
805
|
+
message: reason
|
|
806
|
+
? `Please provide your contact information. ${reason}`
|
|
807
|
+
: 'Please provide your contact information',
|
|
808
|
+
requestedSchema: {
|
|
809
|
+
type: 'object',
|
|
810
|
+
properties: {
|
|
811
|
+
name: {
|
|
812
|
+
type: 'string',
|
|
813
|
+
title: 'Full Name',
|
|
814
|
+
description: 'Your full name',
|
|
815
|
+
},
|
|
816
|
+
email: {
|
|
817
|
+
type: 'string',
|
|
818
|
+
title: 'Email Address',
|
|
819
|
+
description: 'Your email address',
|
|
820
|
+
format: 'email',
|
|
821
|
+
},
|
|
822
|
+
phone: {
|
|
823
|
+
type: 'string',
|
|
824
|
+
title: 'Phone Number',
|
|
825
|
+
description: 'Your phone number (optional)',
|
|
826
|
+
},
|
|
827
|
+
},
|
|
828
|
+
required: ['name', 'email'],
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
if (result.action === 'accept') {
|
|
833
|
+
return `Thank you! Contact information collected: ${JSON.stringify(result.content, null, 2)}`;
|
|
834
|
+
} else if (result.action === 'reject') {
|
|
835
|
+
return 'Contact information collection was declined by the user.';
|
|
836
|
+
} else {
|
|
837
|
+
return 'Contact information collection was cancelled by the user.';
|
|
838
|
+
}
|
|
839
|
+
} catch (error) {
|
|
840
|
+
return `Error collecting contact information: ${error}`;
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
}),
|
|
667
844
|
},
|
|
668
845
|
});
|
|
669
846
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mastra": "latest",
|
|
27
27
|
"react": "^19.1.0",
|
|
28
28
|
"react-dom": "^19.1.0",
|
|
29
|
-
"zod": "^3.25.
|
|
29
|
+
"zod": "^3.25.67"
|
|
30
30
|
},
|
|
31
31
|
"pnpm": {
|
|
32
32
|
"overrides": {
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/js": "^9.25.0",
|
|
43
|
-
"@types/react": "^19.1.
|
|
44
|
-
"@types/react-dom": "^19.1.
|
|
43
|
+
"@types/react": "^19.1.8",
|
|
44
|
+
"@types/react-dom": "^19.1.6",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
46
46
|
"@typescript-eslint/parser": "^8.32.0",
|
|
47
47
|
"@vitejs/plugin-react": "^4.4.1",
|
|
48
|
-
"eslint": "^9.
|
|
48
|
+
"eslint": "^9.29.0",
|
|
49
49
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
50
50
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
51
51
|
"globals": "^16.0.0",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"@ai-sdk/react": "^1.2.12",
|
|
16
16
|
"@mastra/core": "latest",
|
|
17
17
|
"next": "^15.3.1",
|
|
18
|
-
"react": "^19.
|
|
19
|
-
"react-dom": "^19.
|
|
20
|
-
"zod": "^3.25.
|
|
18
|
+
"react": "^19.1.0",
|
|
19
|
+
"react-dom": "^19.1.0",
|
|
20
|
+
"zod": "^3.25.67"
|
|
21
21
|
},
|
|
22
22
|
"pnpm": {
|
|
23
23
|
"overrides": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@eslint/eslintrc": "^3.3.0",
|
|
29
29
|
"@types/node": "^20.17.57",
|
|
30
|
-
"@types/react": "^19.
|
|
31
|
-
"@types/react-dom": "^19.
|
|
32
|
-
"eslint": "^9.
|
|
30
|
+
"@types/react": "^19.1.8",
|
|
31
|
+
"@types/react-dom": "^19.1.6",
|
|
32
|
+
"eslint": "^9.29.0",
|
|
33
33
|
"eslint-config-next": "15.3.3",
|
|
34
34
|
"postcss": "^8.5.3",
|
|
35
35
|
"tailwindcss": "^3.4.17",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"@assistant-ui/react-ui": "^0.1.8",
|
|
17
17
|
"@mastra/client-js": "latest",
|
|
18
18
|
"next": "^15.3.1",
|
|
19
|
-
"react": "^19.
|
|
20
|
-
"react-dom": "^19.
|
|
19
|
+
"react": "^19.1.0",
|
|
20
|
+
"react-dom": "^19.1.0",
|
|
21
21
|
"tailwindcss-animate": "^1.0.7",
|
|
22
|
-
"zod": "^3.25.
|
|
22
|
+
"zod": "^3.25.67"
|
|
23
23
|
},
|
|
24
24
|
"pnpm": {
|
|
25
25
|
"overrides": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^20.17.57",
|
|
31
|
-
"@types/react": "^19.
|
|
32
|
-
"@types/react-dom": "^19.
|
|
33
|
-
"eslint": "^
|
|
31
|
+
"@types/react": "^19.1.8",
|
|
32
|
+
"@types/react-dom": "^19.1.6",
|
|
33
|
+
"eslint": "^9.29.0",
|
|
34
34
|
"eslint-config-next": "15.3.3",
|
|
35
35
|
"postcss": "^8.5.3",
|
|
36
36
|
"tailwindcss": "^3.4.17",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"next": "^15.3.1",
|
|
24
24
|
"next-themes": "^0.4.5",
|
|
25
25
|
"nuqs": "^2.4.1",
|
|
26
|
-
"react": "19.
|
|
27
|
-
"react-dom": "19.
|
|
26
|
+
"react": "19.1.0",
|
|
27
|
+
"react-dom": "19.1.0",
|
|
28
28
|
"sonner": "^1.7.4",
|
|
29
29
|
"tailwind-merge": "^2.6.0",
|
|
30
30
|
"tailwindcss-animate": "^1.0.7",
|
|
31
|
-
"zod": "^3.25.
|
|
31
|
+
"zod": "^3.25.67"
|
|
32
32
|
},
|
|
33
33
|
"pnpm": {
|
|
34
34
|
"overrides": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^20.17.57",
|
|
40
|
-
"@types/react": "^18.3.
|
|
41
|
-
"@types/react-dom": "^18.3.
|
|
42
|
-
"eslint": "^
|
|
40
|
+
"@types/react": "^18.3.23",
|
|
41
|
+
"@types/react-dom": "^18.3.7",
|
|
42
|
+
"eslint": "^9.29.0",
|
|
43
43
|
"eslint-config-next": "15.3.3",
|
|
44
44
|
"postcss": "^8.5.3",
|
|
45
45
|
"tailwindcss": "^3.4.17",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"next": "^15.3.1",
|
|
21
21
|
"next-themes": "^0.4.5",
|
|
22
22
|
"nuqs": "^2.4.1",
|
|
23
|
-
"react": "19.
|
|
24
|
-
"react-dom": "19.
|
|
23
|
+
"react": "19.1.0",
|
|
24
|
+
"react-dom": "19.1.0",
|
|
25
25
|
"sonner": "^1.7.4",
|
|
26
26
|
"tailwind-merge": "^2.6.0",
|
|
27
27
|
"tailwindcss-animate": "^1.0.7",
|
|
28
|
-
"zod": "^3.25.
|
|
28
|
+
"zod": "^3.25.67"
|
|
29
29
|
},
|
|
30
30
|
"pnpm": {
|
|
31
31
|
"overrides": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@libsql/client": "^0.15.4",
|
|
38
38
|
"@types/node": "^20.17.57",
|
|
39
|
-
"@types/react": "^19.
|
|
40
|
-
"@types/react-dom": "^19.
|
|
41
|
-
"eslint": "^
|
|
39
|
+
"@types/react": "^19.1.8",
|
|
40
|
+
"@types/react-dom": "^19.1.6",
|
|
41
|
+
"eslint": "^9.29.0",
|
|
42
42
|
"eslint-config-next": "15.3.3",
|
|
43
43
|
"postcss": "^8.5.3",
|
|
44
44
|
"tailwindcss": "^3.4.17",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"@ai-sdk/openai": "^1.3.22",
|
|
16
16
|
"@mastra/client-js": "latest",
|
|
17
17
|
"@mastra/core": "latest",
|
|
18
|
-
"react": "^19.
|
|
19
|
-
"react-dom": "^19.
|
|
20
|
-
"zod": "^3.25.
|
|
18
|
+
"react": "^19.1.0",
|
|
19
|
+
"react-dom": "^19.1.0",
|
|
20
|
+
"zod": "^3.25.67"
|
|
21
21
|
},
|
|
22
22
|
"pnpm": {
|
|
23
23
|
"overrides": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@eslint/js": "^9.21.0",
|
|
30
|
-
"@types/react": "^19.
|
|
31
|
-
"@types/react-dom": "^19.
|
|
30
|
+
"@types/react": "^19.1.8",
|
|
31
|
+
"@types/react-dom": "^19.1.6",
|
|
32
32
|
"@vitejs/plugin-react": "^4.3.4",
|
|
33
|
-
"eslint": "^9.
|
|
33
|
+
"eslint": "^9.29.0",
|
|
34
34
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
35
35
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
36
36
|
"globals": "^15.15.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"tailwind-merge": "^2.6.0",
|
|
71
71
|
"tailwindcss-animate": "^1.0.7",
|
|
72
72
|
"usehooks-ts": "^3.1.1",
|
|
73
|
-
"zod": "^3.25.
|
|
73
|
+
"zod": "^3.25.67"
|
|
74
74
|
},
|
|
75
75
|
"pnpm": {
|
|
76
76
|
"overrides": {
|
|
@@ -86,13 +86,13 @@
|
|
|
86
86
|
"@types/d3-scale": "^4.0.9",
|
|
87
87
|
"@types/node": "^22.15.29",
|
|
88
88
|
"@types/pdf-parse": "^1.1.4",
|
|
89
|
-
"@types/react": "^19.1",
|
|
90
|
-
"@types/react-dom": "^19.1",
|
|
89
|
+
"@types/react": "^19.1.8",
|
|
90
|
+
"@types/react-dom": "^19.1.6",
|
|
91
91
|
"drizzle-kit": "^0.31.0",
|
|
92
|
-
"eslint": "^9.
|
|
92
|
+
"eslint": "^9.29.0",
|
|
93
93
|
"eslint-config-next": "15.3.3",
|
|
94
|
-
"eslint-config-prettier": "^
|
|
95
|
-
"eslint-import-resolver-typescript": "^
|
|
94
|
+
"eslint-config-prettier": "^10.1.5",
|
|
95
|
+
"eslint-import-resolver-typescript": "^4.4.3",
|
|
96
96
|
"eslint-plugin-import": "^2.31.0",
|
|
97
97
|
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
98
98
|
"postcss": "^8.5.3",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@mastra/core": "latest",
|
|
20
20
|
"@mastra/mcp": "latest",
|
|
21
21
|
"@mastra/memory": "latest",
|
|
22
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.13.0",
|
|
23
23
|
"chalk": "^5.4.1",
|
|
24
|
-
"zod": "^3.25.
|
|
24
|
+
"zod": "^3.25.67",
|
|
25
25
|
"zod-to-json-schema": "^3.24.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|