@mastra/mcp-docs-server 1.0.0-beta.5 → 1.0.0-beta.7

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 (163) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +9 -9
  2. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +67 -67
  3. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  4. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +12 -12
  5. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +57 -57
  6. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +110 -110
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +57 -57
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +57 -57
  9. package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
  10. package/.docs/organized/changelogs/%40mastra%2Fconvex.md +60 -0
  11. package/.docs/organized/changelogs/%40mastra%2Fcore.md +358 -358
  12. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +24 -24
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +12 -12
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +79 -79
  16. package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +57 -57
  18. package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +61 -0
  19. package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +57 -57
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +55 -55
  22. package/.docs/organized/changelogs/%40mastra%2Floggers.md +12 -12
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +125 -125
  25. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +36 -36
  26. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +57 -57
  27. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +57 -57
  28. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
  29. package/.docs/organized/changelogs/%40mastra%2Fpg.md +59 -59
  30. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  31. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +77 -77
  32. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
  33. package/.docs/organized/changelogs/%40mastra%2Frag.md +43 -43
  34. package/.docs/organized/changelogs/%40mastra%2Freact.md +16 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fserver.md +113 -113
  38. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
  39. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +57 -57
  40. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +19 -19
  42. package/.docs/organized/changelogs/create-mastra.md +15 -15
  43. package/.docs/organized/changelogs/mastra.md +30 -30
  44. package/.docs/organized/code-examples/agui.md +1 -0
  45. package/.docs/organized/code-examples/ai-elements.md +1 -1
  46. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
  47. package/.docs/organized/code-examples/ai-sdk-v5.md +2 -1
  48. package/.docs/organized/code-examples/assistant-ui.md +1 -1
  49. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
  50. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
  51. package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
  52. package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
  53. package/.docs/organized/code-examples/server-app-access.md +342 -0
  54. package/.docs/organized/code-examples/server-express-adapter.md +87 -0
  55. package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
  56. package/.docs/raw/agents/agent-approval.mdx +189 -0
  57. package/.docs/raw/agents/guardrails.mdx +13 -9
  58. package/.docs/raw/agents/networks.mdx +1 -0
  59. package/.docs/raw/agents/overview.mdx +8 -152
  60. package/.docs/raw/agents/processors.mdx +279 -0
  61. package/.docs/raw/agents/structured-output.mdx +224 -0
  62. package/.docs/raw/deployment/cloud-providers/index.mdx +19 -26
  63. package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
  64. package/.docs/raw/evals/running-in-ci.mdx +0 -2
  65. package/.docs/raw/{guides/getting-started → getting-started}/manual-install.mdx +2 -2
  66. package/.docs/raw/getting-started/start.mdx +1 -1
  67. package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +8 -0
  68. package/.docs/raw/guides/getting-started/quickstart.mdx +1 -1
  69. package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
  70. package/.docs/raw/guides/index.mdx +3 -35
  71. package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +11 -0
  72. package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +37 -0
  73. package/.docs/raw/index.mdx +1 -1
  74. package/.docs/raw/memory/memory-processors.mdx +265 -79
  75. package/.docs/raw/memory/working-memory.mdx +11 -2
  76. package/.docs/raw/observability/overview.mdx +0 -1
  77. package/.docs/raw/observability/tracing/bridges/otel.mdx +200 -0
  78. package/.docs/raw/observability/tracing/exporters/arize.mdx +36 -0
  79. package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
  80. package/.docs/raw/observability/tracing/exporters/langfuse.mdx +83 -0
  81. package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
  82. package/.docs/raw/observability/tracing/exporters/otel.mdx +34 -22
  83. package/.docs/raw/observability/tracing/exporters/posthog.mdx +20 -0
  84. package/.docs/raw/observability/tracing/overview.mdx +76 -6
  85. package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
  86. package/.docs/raw/rag/retrieval.mdx +23 -6
  87. package/.docs/raw/rag/vector-databases.mdx +93 -2
  88. package/.docs/raw/reference/agents/generate.mdx +55 -6
  89. package/.docs/raw/reference/agents/network.mdx +44 -0
  90. package/.docs/raw/reference/client-js/memory.mdx +43 -0
  91. package/.docs/raw/reference/client-js/workflows.mdx +92 -63
  92. package/.docs/raw/reference/deployer/netlify.mdx +1 -2
  93. package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
  94. package/.docs/raw/reference/index.mdx +1 -0
  95. package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +177 -0
  96. package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
  97. package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +29 -0
  98. package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +43 -0
  99. package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
  100. package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +33 -43
  101. package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
  102. package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
  103. package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
  104. package/.docs/raw/reference/processors/language-detector.mdx +9 -2
  105. package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
  106. package/.docs/raw/reference/processors/moderation-processor.mdx +10 -3
  107. package/.docs/raw/reference/processors/pii-detector.mdx +10 -3
  108. package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
  109. package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -2
  110. package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
  111. package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
  112. package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
  113. package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
  114. package/.docs/raw/reference/server/create-route.mdx +314 -0
  115. package/.docs/raw/reference/server/express-adapter.mdx +193 -0
  116. package/.docs/raw/reference/server/hono-adapter.mdx +174 -0
  117. package/.docs/raw/reference/server/mastra-server.mdx +316 -0
  118. package/.docs/raw/reference/server/routes.mdx +250 -0
  119. package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
  120. package/.docs/raw/reference/storage/convex.mdx +164 -0
  121. package/.docs/raw/reference/storage/lance.mdx +33 -0
  122. package/.docs/raw/reference/storage/libsql.mdx +37 -0
  123. package/.docs/raw/reference/storage/mongodb.mdx +39 -0
  124. package/.docs/raw/reference/storage/mssql.mdx +37 -0
  125. package/.docs/raw/reference/storage/postgresql.mdx +37 -0
  126. package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
  127. package/.docs/raw/reference/streaming/agents/stream.mdx +56 -1
  128. package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
  129. package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
  130. package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
  131. package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
  132. package/.docs/raw/reference/tools/mcp-client.mdx +128 -18
  133. package/.docs/raw/reference/vectors/convex.mdx +429 -0
  134. package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
  135. package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
  136. package/.docs/raw/reference/voice/google.mdx +159 -20
  137. package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
  138. package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
  139. package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
  140. package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
  141. package/.docs/raw/reference/workflows/run.mdx +27 -5
  142. package/.docs/raw/reference/workflows/step.mdx +13 -0
  143. package/.docs/raw/reference/workflows/workflow.mdx +19 -0
  144. package/.docs/raw/server-db/custom-adapters.mdx +380 -0
  145. package/.docs/raw/server-db/mastra-server.mdx +16 -8
  146. package/.docs/raw/server-db/request-context.mdx +0 -1
  147. package/.docs/raw/server-db/server-adapters.mdx +286 -0
  148. package/.docs/raw/server-db/storage.mdx +11 -0
  149. package/.docs/raw/streaming/overview.mdx +6 -6
  150. package/.docs/raw/streaming/tool-streaming.mdx +2 -2
  151. package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
  152. package/.docs/raw/workflows/error-handling.mdx +1 -0
  153. package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
  154. package/.docs/raw/workflows/overview.mdx +56 -44
  155. package/.docs/raw/workflows/snapshots.mdx +1 -0
  156. package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
  157. package/.docs/raw/workflows/time-travel.mdx +313 -0
  158. package/.docs/raw/workflows/workflow-state.mdx +191 -0
  159. package/CHANGELOG.md +16 -0
  160. package/package.json +4 -4
  161. package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -91
  162. package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
  163. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  title: "Reference: Run.stream() | Streaming"
3
- description: Documentation for the `Run.stream()` method in workflows, which allows you to monitor the execution of a workflow run as a stream.
3
+ description: Documentation for the `Run.stream()` method in workflows, which enables real-time streaming of responses.
4
4
  ---
5
5
 
6
6
  # Run.stream()
7
7
 
8
- The `.stream()` method allows you to monitor the execution of a workflow run, providing real-time updates on the status of steps.
8
+ The `.stream()` method enables real-time streaming of responses from a workflow.
9
9
 
10
10
  ## Usage example
11
11
 
12
12
  ```typescript showLineNumbers copy
13
13
  const run = await workflow.createRun();
14
14
 
15
- const { stream } = await run.stream({
15
+ const stream = run.stream({
16
16
  inputData: {
17
17
  value: "initial data",
18
18
  },
@@ -40,7 +40,7 @@ const { stream } = await run.stream({
40
40
  type: "TracingContext",
41
41
  isOptional: true,
42
42
  description:
43
- "Tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.",
43
+ "Tracing context for creating child spans and adding metadata.",
44
44
  properties: [
45
45
  {
46
46
  parameters: [
@@ -49,7 +49,7 @@ const { stream } = await run.stream({
49
49
  type: "Span",
50
50
  isOptional: true,
51
51
  description:
52
- "Current span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.",
52
+ "Current span for creating child spans and adding metadata.",
53
53
  },
54
54
  ],
55
55
  },
@@ -67,13 +67,63 @@ const { stream } = await run.stream({
67
67
  name: "metadata",
68
68
  type: "Record<string, any>",
69
69
  isOptional: true,
70
+ description: "Metadata to add to the root trace span.",
71
+ },
72
+ ],
73
+ },
74
+ {
75
+ parameters: [
76
+ {
77
+ name: "requestContextKeys",
78
+ type: "string[]",
79
+ isOptional: true,
80
+ description:
81
+ "Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').",
82
+ },
83
+ ],
84
+ },
85
+ {
86
+ parameters: [
87
+ {
88
+ name: "traceId",
89
+ type: "string",
90
+ isOptional: true,
91
+ description:
92
+ "Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.",
93
+ },
94
+ ],
95
+ },
96
+ {
97
+ parameters: [
98
+ {
99
+ name: "parentSpanId",
100
+ type: "string",
101
+ isOptional: true,
70
102
  description:
71
- "Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.",
103
+ "Parent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.",
104
+ },
105
+ ],
106
+ },
107
+ {
108
+ parameters: [
109
+ {
110
+ name: "tags",
111
+ type: "string[]",
112
+ isOptional: true,
113
+ description:
114
+ "Tags to apply to this trace. String labels for categorizing and filtering traces.",
72
115
  },
73
116
  ],
74
117
  },
75
118
  ],
76
119
  },
120
+ {
121
+ name: "closeOnSuspend",
122
+ type: "boolean",
123
+ description:
124
+ "Whether to close the stream when the workflow is suspended, or to keep the stream open until the workflow is finished (by success or error). Default value is true.",
125
+ isOptional: true,
126
+ },
77
127
  ]}
78
128
  />
79
129
 
@@ -83,22 +133,31 @@ const { stream } = await run.stream({
83
133
  content={[
84
134
  {
85
135
  name: "stream",
86
- type: "ReadableStream<StreamEvent>",
136
+ type: "MastraWorkflowStream<ChunkType>",
87
137
  description:
88
- "A readable stream that emits workflow execution events in real-time",
138
+ "A custom stream that extends ReadableStream<ChunkType> with additional workflow-specific properties",
89
139
  },
90
140
  {
91
- name: "getWorkflowState",
92
- type: "() => Promise<WorkflowResult<TState, TOutput, TSteps>>",
93
- description:
94
- "A function that returns a promise resolving to the final workflow result",
141
+ name: "stream.status",
142
+ type: "Promise<RunStatus>",
143
+ description: "A promise that resolves to the current workflow run status",
144
+ },
145
+ {
146
+ name: "stream.result",
147
+ type: "Promise<WorkflowResult<TState, TOutput, TSteps>>",
148
+ description: "A promise that resolves to the final workflow result",
149
+ },
150
+ {
151
+ name: "stream.usage",
152
+ type: "Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>",
153
+ description: "A promise that resolves to token usage statistics",
95
154
  },
96
155
  {
97
- name: "traceId",
156
+ name: "stream.traceId",
98
157
  type: "string",
99
158
  isOptional: true,
100
159
  description:
101
- "The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.",
160
+ "The trace ID associated with this execution when Tracing is enabled.",
102
161
  },
103
162
  ]}
104
163
  />
@@ -106,29 +165,29 @@ const { stream } = await run.stream({
106
165
  ## Extended usage example
107
166
 
108
167
  ```typescript showLineNumbers copy
109
- const { getWorkflowState } = await run.stream({
168
+ const run = await workflow.createRun();
169
+
170
+ const stream = run.stream({
110
171
  inputData: {
111
172
  value: "initial data",
112
173
  },
113
174
  });
114
175
 
115
- const result = await getWorkflowState();
176
+ const result = await stream.result;
116
177
  ```
117
178
 
118
179
  ## Stream Events
119
180
 
120
181
  The stream emits various event types during workflow execution. Each event has a `type` field and a `payload` containing relevant data:
121
182
 
122
- - **`start`**: Workflow execution begins
123
- - **`step-start`**: A step begins execution
124
- - **`tool-call`**: A tool call is initiated
125
- - **`tool-call-streaming-start`**: Tool call streaming begins
126
- - **`tool-call-delta`**: Incremental tool output updates
127
- - **`step-result`**: A step completes with results
128
- - **`step-finish`**: A step finishes execution
129
- - **`finish`**: Workflow execution completes
183
+ - **`workflow-start`**: Workflow execution begins
184
+ - **`workflow-step-start`**: A step begins execution
185
+ - **`workflow-step-output`**: Custom output from a step
186
+ - **`workflow-step-result`**: A step completes with results
187
+ - **`workflow-finish`**: Workflow execution completes with usage statistics
130
188
 
131
189
  ## Related
132
190
 
133
191
  - [Workflows overview](/docs/v1/workflows/overview#running-workflows)
134
192
  - [Workflow.createRun()](/reference/v1/workflows/workflow-methods/create-run)
193
+ - [Run.resumeStream()](./resumeStream)
@@ -0,0 +1,170 @@
1
+ ---
2
+ title: "Reference: Run.timeTravelStream() | Streaming"
3
+ description: Documentation for the `Run.timeTravelStream()` method for streaming workflow time travel execution.
4
+ ---
5
+
6
+ # Run.timeTravelStream()
7
+
8
+ The `.timeTravelStream()` method re-executes a workflow starting from any specific step with streaming events. This allows you to receive real-time updates during time travel execution while maintaining full visibility into each step's progress.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript showLineNumbers copy
13
+ const run = await workflow.createRun();
14
+
15
+ const output = run.timeTravelStream({
16
+ step: "step2",
17
+ inputData: { value: 10 },
18
+ });
19
+
20
+ // Process events as they arrive
21
+ for await (const event of output.fullStream) {
22
+ console.log(event.type, event.payload);
23
+ }
24
+
25
+ // Get the final result
26
+ const result = await output.result;
27
+ ```
28
+
29
+ ## Parameters
30
+
31
+ All parameters are the same as [`Run.timeTravel()`](../../workflows/run-methods/timeTravel#parameters). See the [timeTravel reference](../../workflows/run-methods/timeTravel#parameters) for detailed parameter documentation.
32
+
33
+ ## Returns
34
+
35
+ <PropertiesTable
36
+ content={[
37
+ {
38
+ name: "output",
39
+ type: "WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>",
40
+ description:
41
+ "An object containing both the stream and result promise",
42
+ },
43
+ {
44
+ name: "output.fullStream",
45
+ type: "ReadableStream<WorkflowStreamEvent>",
46
+ description:
47
+ "A readable stream that emits workflow events as execution progresses",
48
+ },
49
+ {
50
+ name: "output.result",
51
+ type: "Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>",
52
+ description:
53
+ "A promise that resolves to the final workflow execution result",
54
+ },
55
+ {
56
+ name: "output.traceId",
57
+ type: "string",
58
+ isOptional: true,
59
+ description:
60
+ "The trace ID associated with this execution when Tracing is enabled",
61
+ },
62
+ ]}
63
+ />
64
+
65
+ ## Stream events
66
+
67
+ The stream emits various workflow events during execution:
68
+
69
+ - `workflow-step-start`: Emitted when a step begins execution
70
+ - `workflow-step-finish`: Emitted when a step completes successfully
71
+ - `workflow-step-error`: Emitted when a step encounters an error
72
+ - `workflow-step-suspended`: Emitted when a step suspends
73
+ - Additional events depending on step types (agents, tools, etc.)
74
+
75
+ ## Extended usage examples
76
+
77
+ ### Processing events during time travel
78
+
79
+ ```typescript showLineNumbers copy
80
+ const run = await workflow.createRun();
81
+
82
+ const output = run.timeTravelStream({
83
+ step: "step2",
84
+ inputData: { value: 10 },
85
+ });
86
+
87
+ for await (const event of output.fullStream) {
88
+ switch (event.type) {
89
+ case "workflow-step-start":
90
+ console.log(`Starting step: ${event.payload.stepName}`);
91
+ break;
92
+ case "workflow-step-finish":
93
+ console.log(`Completed step: ${event.payload.stepName}`);
94
+ break;
95
+ case "workflow-step-error":
96
+ console.error(`Error in step: ${event.payload.stepName}`, event.payload.error);
97
+ break;
98
+ }
99
+ }
100
+
101
+ const result = await output.result;
102
+ console.log("Time travel completed:", result);
103
+ ```
104
+
105
+ ### Time travel stream with context
106
+
107
+ ```typescript showLineNumbers copy
108
+ const output = run.timeTravelStream({
109
+ step: "step2",
110
+ context: {
111
+ step1: {
112
+ status: "success",
113
+ payload: { value: 0 },
114
+ output: { step1Result: 2 },
115
+ startedAt: Date.now(),
116
+ endedAt: Date.now(),
117
+ },
118
+ },
119
+ });
120
+
121
+ for await (const event of output.fullStream) {
122
+ // Handle events
123
+ console.log(event);
124
+ }
125
+
126
+ const result = await output.result;
127
+ ```
128
+
129
+ ### Time travel stream with nested workflows
130
+
131
+ ```typescript showLineNumbers copy
132
+ const output = run.timeTravelStream({
133
+ step: ["nestedWorkflow", "step3"],
134
+ inputData: { value: 10 },
135
+ nestedStepsContext: {
136
+ nestedWorkflow: {
137
+ step2: {
138
+ status: "success",
139
+ payload: { step1Result: 2 },
140
+ output: { step2Result: 3 },
141
+ startedAt: Date.now(),
142
+ endedAt: Date.now(),
143
+ },
144
+ },
145
+ },
146
+ });
147
+
148
+ for await (const event of output.fullStream) {
149
+ console.log(event.type, event.payload);
150
+ }
151
+
152
+ const result = await output.result;
153
+ ```
154
+
155
+ ## Notes
156
+
157
+ - The stream closes automatically when time travel execution completes or encounters an error
158
+ - You can process events from the stream while the workflow is still executing
159
+ - The `result` promise resolves only after all steps have completed
160
+ - Stream events follow the same format as regular workflow streaming
161
+ - Time travel streaming requires storage to be configured since it relies on persisted workflow snapshots
162
+
163
+ ## Related
164
+
165
+ - [Run.timeTravel()](../../workflows/run-methods/timeTravel)
166
+ - [Time Travel](/docs/v1/workflows/time-travel)
167
+ - [Workflow Streaming](/docs/v1/streaming/workflow-streaming)
168
+ - [Run.stream()](./stream)
169
+ - [Run.resumeStream()](./resumeStream)
170
+
@@ -99,6 +99,13 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
99
99
  description:
100
100
  "For SSE fallback: Custom fetch configuration for SSE connections. Required when using custom headers with SSE.",
101
101
  },
102
+ {
103
+ name: "fetch",
104
+ type: "FetchLike",
105
+ isOptional: true,
106
+ description:
107
+ "For HTTP servers: Custom fetch implementation used for all network requests. When provided, this function will be used for all HTTP requests, allowing you to add dynamic authentication headers (e.g., refreshing bearer tokens), customize request behavior per-request, or intercept and modify requests/responses. When `fetch` is provided, `requestInit`, `eventSourceInit`, and `authProvider` become optional, as you can handle these concerns within your custom fetch function.",
108
+ },
102
109
  {
103
110
  name: "logger",
104
111
  type: "LogHandler",
@@ -291,23 +298,6 @@ mcpClient.resources.onListChanged("myWeatherServer", () => {
291
298
  });
292
299
  ```
293
300
 
294
- ### `prompts` Property
295
-
296
- The `MCPClient` instance has a `prompts` property that provides access to prompt-related operations.
297
-
298
- ```typescript
299
- const mcpClient = new MCPClient({
300
- /* ...servers configuration... */
301
- });
302
-
303
- // Access prompt methods via mcpClient.prompts
304
- const allPromptsByServer = await mcpClient.prompts.list();
305
- const { prompt, messages } = await mcpClient.prompts.get({
306
- serverName: "myWeatherServer",
307
- name: "current",
308
- });
309
- ```
310
-
311
301
  ### `elicitation` Property
312
302
 
313
303
  The `MCPClient` instance has an `elicitation` property that provides access to elicitation-related operations. Elicitation allows MCP servers to request structured information from users.
@@ -451,6 +441,23 @@ await mcpClient.elicitation.onRequest("interactiveServer", async (request) => {
451
441
  });
452
442
  ```
453
443
 
444
+ ### `prompts` Property
445
+
446
+ The `MCPClient` instance has a `prompts` property that provides access to prompt-related operations.
447
+
448
+ ```typescript
449
+ const mcpClient = new MCPClient({
450
+ /* ...servers configuration... */
451
+ });
452
+
453
+ // Access prompt methods via mcpClient.prompts
454
+ const allPromptsByServer = await mcpClient.prompts.list();
455
+ const { prompt, messages } = await mcpClient.prompts.get({
456
+ serverName: "myWeatherServer",
457
+ name: "current",
458
+ });
459
+ ```
460
+
454
461
  #### `prompts.list()`
455
462
 
456
463
  Retrieves all available prompts from all connected MCP servers, grouped by server name.
@@ -516,6 +523,63 @@ mcpClient.prompts.onListChanged("myWeatherServer", () => {
516
523
  });
517
524
  ```
518
525
 
526
+ ### `progress` Property
527
+
528
+ The `MCPClient` instance has a `progress` property for subscribing to progress notifications emitted by MCP servers while tools execute.
529
+
530
+ ```typescript
531
+ const mcpClient = new MCPClient({
532
+ servers: {
533
+ myServer: {
534
+ url: new URL('http://localhost:4111/api/mcp/myServer/mcp'),
535
+ // Enabled by default; set to false to disable
536
+ enableProgressTracking: true,
537
+ },
538
+ },
539
+ });
540
+
541
+ // Subscribe to progress updates for a specific server
542
+ await mcpClient.progress.onUpdate('myServer', (params) => {
543
+ console.log('📊 Progress:', params.progress, '/', params.total);
544
+ if (params.message) console.log('Message:', params.message);
545
+ if (params.progressToken) console.log('Token:', params.progressToken);
546
+ });
547
+ ```
548
+
549
+ #### `progress.onUpdate(serverName: string, handler)`
550
+
551
+ Registers a handler function to receive progress updates from the specified server.
552
+
553
+ ```typescript
554
+ async onUpdate(
555
+ serverName: string,
556
+ handler: (params: {
557
+ progressToken: string;
558
+ progress: number;
559
+ total?: number;
560
+ message?: string;
561
+ }) => void,
562
+ ): Promise<void>
563
+ ```
564
+
565
+ Notes:
566
+
567
+ - When `enableProgressTracking` is true (default), tool calls include a `progressToken` so you can correlate updates to a specific run.
568
+ - If you pass a `runId` when executing a tool, it will be used as the `progressToken`.
569
+
570
+ To disable progress tracking for a server:
571
+
572
+ ```typescript
573
+ const mcpClient = new MCPClient({
574
+ servers: {
575
+ myServer: {
576
+ url: new URL('http://localhost:4111/api/mcp/myServer/mcp'),
577
+ enableProgressTracking: false,
578
+ },
579
+ },
580
+ });
581
+ ```
582
+
519
583
  ## Elicitation
520
584
 
521
585
  Elicitation is a feature that allows MCP servers to request structured information from users. When a server needs additional data, it can send an elicitation request that the client handles by prompting the user. A common example is during a tool call.
@@ -797,11 +861,40 @@ MCPClient handles server connections gracefully:
797
861
  2. Graceful server shutdown to prevent error messages during development
798
862
  3. Proper cleanup of resources when disconnecting
799
863
 
864
+ ## Using Custom Fetch for Dynamic Authentication
865
+
866
+ For HTTP servers, you can provide a custom `fetch` function to handle dynamic authentication, request interception, or other custom behavior. This is particularly useful when you need to refresh tokens on each request or customize request behavior.
867
+
868
+ When `fetch` is provided, `requestInit`, `eventSourceInit`, and `authProvider` become optional, as you can handle these concerns within your custom fetch function.
869
+
870
+ ```typescript
871
+ const mcpClient = new MCPClient({
872
+ servers: {
873
+ apiServer: {
874
+ url: new URL("https://api.example.com/mcp"),
875
+ fetch: async (url, init) => {
876
+ // Refresh token on each request
877
+ const token = await getAuthToken(); // Your token refresh logic
878
+
879
+ return fetch(url, {
880
+ ...init,
881
+ headers: {
882
+ ...init?.headers,
883
+ Authorization: `Bearer ${token}`,
884
+ },
885
+ });
886
+ },
887
+ },
888
+ },
889
+ });
890
+ ```
891
+
800
892
  ## Using SSE Request Headers
801
893
 
802
- When using the legacy SSE MCP transport, you must configure both `requestInit` and `eventSourceInit` due to a bug in the MCP SDK:
894
+ When using the legacy SSE MCP transport, you must configure both `requestInit` and `eventSourceInit` due to a bug in the MCP SDK. Alternatively, you can use a custom `fetch` function which will be automatically used for both POST requests and SSE connections:
803
895
 
804
896
  ```ts
897
+ // Option 1: Using requestInit and eventSourceInit (required for SSE)
805
898
  const sseClient = new MCPClient({
806
899
  servers: {
807
900
  exampleServer: {
@@ -826,6 +919,23 @@ const sseClient = new MCPClient({
826
919
  },
827
920
  },
828
921
  });
922
+
923
+ // Option 2: Using custom fetch (simpler, works for both Streamable HTTP and SSE)
924
+ const sseClientWithFetch = new MCPClient({
925
+ servers: {
926
+ exampleServer: {
927
+ url: new URL("https://your-mcp-server.com/sse"),
928
+ fetch: async (url, init) => {
929
+ const headers = new Headers(init?.headers || {});
930
+ headers.set("Authorization", "Bearer your-token");
931
+ return fetch(url, {
932
+ ...init,
933
+ headers,
934
+ });
935
+ },
936
+ },
937
+ },
938
+ });
829
939
  ```
830
940
 
831
941
  ## Related Information