@mastra/mcp-docs-server 0.13.17-alpha.4 → 0.13.17-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +20 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +9 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  4. package/.docs/organized/changelogs/%40mastra%2Fauth.md +6 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
  6. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
  7. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +17 -17
  8. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +21 -21
  9. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +11 -11
  11. package/.docs/organized/changelogs/%40mastra%2Fcore.md +39 -39
  12. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +10 -10
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +21 -0
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +15 -15
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +11 -11
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +12 -12
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +24 -24
  18. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +11 -11
  19. package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
  20. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
  21. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +20 -20
  22. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +19 -19
  23. package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
  24. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +19 -19
  25. package/.docs/organized/changelogs/%40mastra%2Floggers.md +11 -11
  26. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +23 -23
  27. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
  28. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +23 -23
  29. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +19 -19
  30. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +21 -21
  31. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +11 -11
  32. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +10 -5
  33. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
  34. package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
  35. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  36. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +24 -24
  37. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +13 -13
  38. package/.docs/organized/changelogs/%40mastra%2Frag.md +10 -10
  39. package/.docs/organized/changelogs/%40mastra%2Fragie.md +19 -19
  40. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +12 -0
  41. package/.docs/organized/changelogs/%40mastra%2Fserver.md +20 -20
  42. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +11 -11
  43. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +10 -10
  44. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +10 -10
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +10 -10
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +10 -10
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +9 -0
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +10 -10
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +10 -10
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +10 -10
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +10 -10
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +11 -11
  56. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +11 -11
  57. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
  58. package/.docs/organized/changelogs/create-mastra.md +13 -13
  59. package/.docs/organized/changelogs/mastra.md +26 -26
  60. package/.docs/organized/code-examples/assistant-ui.md +1 -1
  61. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
  62. package/.docs/organized/code-examples/heads-up-game.md +32 -56
  63. package/.docs/raw/getting-started/installation.mdx +2 -7
  64. package/.docs/raw/getting-started/templates.mdx +2 -7
  65. package/.docs/raw/memory/working-memory.mdx +17 -17
  66. package/.docs/raw/observability/ai-tracing.mdx +438 -0
  67. package/.docs/raw/reference/scorers/noise-sensitivity.mdx +87 -20
  68. package/.docs/raw/reference/tools/mcp-server.mdx +26 -27
  69. package/.docs/raw/tools-mcp/mcp-overview.mdx +6 -5
  70. package/.docs/raw/workflows/suspend-and-resume.mdx +64 -7
  71. package/CHANGELOG.md +1823 -0
  72. package/dist/logger.d.ts +5 -1
  73. package/dist/logger.d.ts.map +1 -1
  74. package/dist/stdio.js +47 -4
  75. package/dist/tools/blog.d.ts.map +1 -1
  76. package/package.json +16 -6
@@ -18,8 +18,7 @@ To create a new `MCPServer`, you need to provide some basic information about yo
18
18
  ```typescript
19
19
  import { openai } from "@ai-sdk/openai";
20
20
  import { Agent } from "@mastra/core/agent";
21
- import { createTool } from "@mastra/core/tools";
22
- import { MCPServer } from "@mastra/mcp";
21
+ import { MCPServer, createMCPTool } from "@mastra/mcp";
23
22
  import { z } from "zod";
24
23
  import { dataProcessingWorkflow } from "../workflows/dataProcessingWorkflow";
25
24
 
@@ -30,7 +29,7 @@ const myAgent = new Agent({
30
29
  model: openai("gpt-4o-mini"),
31
30
  });
32
31
 
33
- const weatherTool = createTool({
32
+ const weatherTool = createMCPTool({
34
33
  id: "getWeather",
35
34
  description: "Gets the current weather for a location.",
36
35
  inputSchema: z.object({ location: z.string() }),
@@ -69,10 +68,10 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
69
68
  },
70
69
  {
71
70
  name: "tools",
72
- type: "ToolsInput",
71
+ type: "MCPToolsInput",
73
72
  isOptional: false,
74
73
  description:
75
- "An object where keys are tool names and values are Mastra tool definitions (created with `createTool` or Vercel AI SDK). These tools will be directly exposed.",
74
+ "An object where keys are tool names and values are tool definitions. Supports Mastra tools (created with `createMCPTool` or `createTool`) or Vercel AI SDK tools. Tools created with `createMCPTool` have access to MCP-specific features like elicitation for user interaction.",
76
75
  },
77
76
  {
78
77
  name: "agents",
@@ -846,17 +845,18 @@ The `MCPServer` class automatically includes elicitation capabilities. Tools rec
846
845
  When tools are executed within an MCP server context, they receive an additional `options` parameter:
847
846
 
848
847
  ```typescript
849
- execute: async ({ context }, options) => {
850
- // context contains the tool's input parameters
851
- // options contains server capabilities like elicitation and authentication info
848
+ execute: async (params, { elicitation, extra }) => {
849
+ // params contains the validated tool input parameters
850
+ // elicitation provides user interaction capabilities
851
+ // extra contains MCP-specific context (auth, session, etc.)
852
852
 
853
853
  // Access authentication information (when available)
854
- if (options.extra?.authInfo) {
855
- console.log('Authenticated request from:', options.extra.authInfo.clientId);
854
+ if (extra?.authInfo) {
855
+ console.log('Authenticated request from:', extra.authInfo.clientId);
856
856
  }
857
857
 
858
858
  // Use elicitation capabilities
859
- const result = await options.elicitation.sendRequest({
859
+ const result = await elicitation.sendRequest({
860
860
  message: "Please provide information",
861
861
  requestedSchema: { /* schema */ }
862
862
  });
@@ -881,29 +881,28 @@ A common use case is during tool execution. When a tool needs user input, it can
881
881
  Here's an example of a tool that uses elicitation to collect user contact information:
882
882
 
883
883
  ```typescript
884
- import { MCPServer } from "@mastra/mcp";
885
- import { createTool } from "@mastra/core/tools";
884
+ import { MCPServer, createMCPTool } from "@mastra/mcp";
886
885
  import { z } from "zod";
887
886
 
888
887
  const server = new MCPServer({
889
888
  name: "Interactive Server",
890
889
  version: "1.0.0",
891
890
  tools: {
892
- collectContactInfo: createTool({
891
+ collectContactInfo: createMCPTool({
893
892
  id: "collectContactInfo",
894
893
  description: "Collects user contact information through elicitation",
895
894
  inputSchema: z.object({
896
895
  reason: z.string().optional().describe("Reason for collecting contact info"),
897
896
  }),
898
- execute: async ({ context }, options) => {
899
- const { reason } = context;
897
+ execute: async (params, { context, elicitation, extra }) => {
898
+ const { reason } = params;
900
899
 
901
900
  // Log session info if available
902
- console.log('Request from session:', options.extra?.sessionId);
901
+ console.log('Request from session:', extra?.sessionId);
903
902
 
904
903
  try {
905
904
  // Request user input via elicitation
906
- const result = await options.elicitation.sendRequest({
905
+ const result = await elicitation.sendRequest({
907
906
  message: reason
908
907
  ? `Please provide your contact information. ${reason}`
909
908
  : 'Please provide your contact information',
@@ -1010,17 +1009,17 @@ Tools should handle all three response types appropriately.
1010
1009
  The elicitation functionality is available through the `options` parameter in tool execution:
1011
1010
 
1012
1011
  ```typescript
1013
- // Within a tool's execute function
1014
- execute: async ({ context }, options) => {
1012
+ // Within a tool's execute function (using createMCPTool)
1013
+ execute: async (params, { elicitation, extra }) => {
1015
1014
  // Use elicitation for user input
1016
- const result = await options.elicitation.sendRequest({
1015
+ const result = await elicitation.sendRequest({
1017
1016
  message: string, // Message to display to user
1018
1017
  requestedSchema: object // JSON schema defining expected response structure
1019
1018
  }): Promise<ElicitResult>
1020
1019
 
1021
1020
  // Access authentication info if needed
1022
- if (options.extra?.authInfo) {
1023
- // Use options.extra.authInfo.token, etc.
1021
+ if (extra?.authInfo) {
1022
+ // Use extra.authInfo.token, etc.
1024
1023
  }
1025
1024
  }
1026
1025
  ```
@@ -1041,15 +1040,15 @@ type ElicitResult = {
1041
1040
  Tools can access request metadata via `options.extra` when using HTTP-based transports:
1042
1041
 
1043
1042
  ```typescript
1044
- execute: async ({ context }, options) => {
1045
- if (!options.extra?.authInfo?.token) {
1043
+ execute: async (params, { elicitation, extra }) => {
1044
+ if (!extra?.authInfo?.token) {
1046
1045
  return "Authentication required";
1047
1046
  }
1048
1047
 
1049
1048
  // Use the auth token
1050
1049
  const response = await fetch('/api/data', {
1051
- headers: { Authorization: `Bearer ${options.extra.authInfo.token}` },
1052
- signal: options.extra.signal,
1050
+ headers: { Authorization: `Bearer ${extra.authInfo.token}` },
1051
+ signal: extra.signal,
1053
1052
  });
1054
1053
 
1055
1054
  return response.json();
@@ -341,22 +341,23 @@ When a tool includes an `outputSchema`, its `execute` function **must** return a
341
341
  Here's an example of a tool with an `outputSchema`:
342
342
 
343
343
  ```typescript filename="src/tools/structured-tool.ts"
344
- import { createTool } from '@mastra/core/tools';
344
+ import { createMCPTool } from '@mastra/mcp';
345
345
  import { z } from 'zod';
346
346
 
347
- export const structuredTool = createTool({
347
+ export const structuredTool = createMCPTool({
348
+ id: 'structuredTool',
348
349
  description: 'A test tool that returns structured data.',
349
- parameters: z.object({
350
+ inputSchema: z.object({
350
351
  input: z.string().describe('Some input string.'),
351
352
  }),
352
353
  outputSchema: z.object({
353
354
  processedInput: z.string().describe('The processed input string.'),
354
355
  timestamp: z.string().describe('An ISO timestamp.'),
355
356
  }),
356
- execute: async ({ input }) => {
357
+ execute: async (params, { elicitation, extra }) => {
357
358
  // When outputSchema is defined, you must return an object
358
359
  return {
359
- processedInput: `processed: ${input}`,
360
+ processedInput: `processed: ${params.input}`,
360
361
  timestamp: new Date().toISOString(),
361
362
  };
362
363
  },
@@ -30,17 +30,15 @@ To pause execution at a specific step until user input is received, use the `⁠
30
30
 
31
31
  ![Suspending a workflow with suspend()](/image/workflows/workflows-suspend-resume-suspend.jpg)
32
32
 
33
- ```typescript {18} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
33
+ ```typescript {16} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
34
34
  const step1 = createStep({
35
35
  id: "step-1",
36
- description: "Test suspend",
37
36
  inputSchema: z.object({
38
37
  input: z.string()
39
38
  }),
40
39
  outputSchema: z.object({
41
40
  output: z.string()
42
41
  }),
43
- suspendSchema: z.object({}),
44
42
  resumeSchema: z.object({
45
43
  city: z.string()
46
44
  }),
@@ -48,15 +46,16 @@ const step1 = createStep({
48
46
  const { city } = resumeData ?? {};
49
47
 
50
48
  if (!city) {
51
- await suspend({});
52
- return { output: "" };
49
+ return await suspend({});
53
50
  }
54
51
 
55
52
  return { output: "" };
56
53
  }
57
54
  });
58
55
 
59
- export const testWorkflow = createWorkflow({})
56
+ export const testWorkflow = createWorkflow({
57
+ // ...
58
+ })
60
59
  .then(step1)
61
60
  .commit();
62
61
  ```
@@ -88,9 +87,10 @@ if (result.status === "suspended") {
88
87
  }
89
88
  });
90
89
  }
91
-
92
90
  ```
93
91
 
92
+ > See [Run Workflow Results](/docs/workflows/overview#run-workflow-results) for more details.
93
+
94
94
  In this case, the logic resumes the first step listed in the `suspended` array. A `step` can also be defined using it's `id`, for example: 'step-1'.
95
95
 
96
96
  ```json
@@ -111,6 +111,63 @@ In this case, the logic resumes the first step listed in the `suspended` array.
111
111
  }
112
112
  ```
113
113
 
114
+ ## Providing user feedback with suspend
115
+
116
+ When a workflow is suspended, feedback can be surfaced to the user through the `suspendSchema`. Include a reason in the `suspend` payload to explain why the workflow paused.
117
+
118
+ ```typescript {13,23} filename="src/mastra/workflows/test-workflow.ts" showLineNumbers copy
119
+ import { createWorkflow, createStep } from "@mastra/core/workflows";
120
+ import { z } from "zod";
121
+
122
+ const step1 = createStep({
123
+ id: "step-1",
124
+ inputSchema: z.object({
125
+ value: z.string()
126
+ }),
127
+ resumeSchema: z.object({
128
+ confirm: z.boolean()
129
+ }),
130
+ suspendSchema: z.object({
131
+ reason: z.string()
132
+ }),
133
+ outputSchema: z.object({
134
+ value: z.string()
135
+ }),
136
+ execute: async ({ resumeData, suspend }) => {
137
+ const { confirm } = resumeData ?? {};
138
+
139
+ if (!confirm) {
140
+ return await suspend({
141
+ reason: "Confirm to continue"
142
+ });
143
+ }
144
+
145
+ return { value: "" };
146
+ }
147
+ });
148
+
149
+ export const testWorkflow = createWorkflow({
150
+ // ...
151
+ })
152
+ .then(step1)
153
+ .commit();
154
+
155
+ ```
156
+
157
+ In this case, the reason provided explains that the user must confirm to continue.
158
+
159
+ ```json
160
+ {
161
+ "step-1": {
162
+ // ...
163
+ "status": "suspended",
164
+ "suspendPayload": {
165
+ "reason": "Confirm to continue"
166
+ },
167
+ }
168
+ }
169
+ ```
170
+
114
171
  > See [Run Workflow Results](/docs/workflows/overview#run-workflow-results) for more details.
115
172
 
116
173
  ## Resuming a workflow with `resume()`