@mastra/mcp-docs-server 1.0.0-beta.10 → 1.0.0-beta.13

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 (168) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +12 -12
  2. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +50 -50
  3. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
  4. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +45 -45
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +109 -109
  6. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +39 -39
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +39 -39
  8. package/.docs/organized/changelogs/%40mastra%2Fconvex.md +38 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +264 -264
  10. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +25 -25
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +37 -37
  12. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +39 -39
  13. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
  14. package/.docs/organized/changelogs/%40mastra%2Flance.md +39 -39
  15. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +45 -45
  16. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +22 -22
  17. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +13 -13
  18. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +39 -39
  19. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +39 -39
  20. package/.docs/organized/changelogs/%40mastra%2Fpg.md +45 -45
  21. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +104 -104
  22. package/.docs/organized/changelogs/%40mastra%2Freact.md +66 -0
  23. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  24. package/.docs/organized/changelogs/%40mastra%2Fserver.md +59 -59
  25. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +39 -39
  26. package/.docs/organized/changelogs/create-mastra.md +31 -31
  27. package/.docs/organized/changelogs/mastra.md +49 -49
  28. package/.docs/organized/code-examples/quick-start.md +0 -4
  29. package/.docs/organized/code-examples/stock-price-tool.md +21 -2
  30. package/.docs/raw/agents/agent-approval.mdx +136 -2
  31. package/.docs/raw/agents/agent-memory.mdx +4 -4
  32. package/.docs/raw/agents/guardrails.mdx +44 -7
  33. package/.docs/raw/agents/networks.mdx +1 -1
  34. package/.docs/raw/agents/overview.mdx +2 -2
  35. package/.docs/raw/agents/processors.mdx +151 -0
  36. package/.docs/raw/agents/using-tools.mdx +1 -1
  37. package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
  38. package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
  39. package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
  40. package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
  41. package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
  42. package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
  43. package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
  44. package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
  45. package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -2
  46. package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
  47. package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
  48. package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +3 -4
  49. package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -3
  50. package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +2 -3
  51. package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -2
  52. package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +2 -3
  53. package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
  54. package/.docs/raw/deployment/cloud-providers.mdx +20 -0
  55. package/.docs/raw/deployment/{building-mastra.mdx → mastra-server.mdx} +2 -2
  56. package/.docs/raw/deployment/monorepo.mdx +23 -44
  57. package/.docs/raw/deployment/overview.mdx +28 -53
  58. package/.docs/raw/deployment/web-framework.mdx +12 -14
  59. package/.docs/raw/getting-started/mcp-docs-server.mdx +57 -0
  60. package/.docs/raw/getting-started/start.mdx +10 -1
  61. package/.docs/raw/getting-started/studio.mdx +25 -2
  62. package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1021 -67
  63. package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +3 -6
  64. package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +4 -6
  65. package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +4 -0
  66. package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +3 -6
  67. package/.docs/raw/guides/deployment/index.mdx +32 -0
  68. package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +4 -0
  69. package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +4 -0
  70. package/.docs/raw/guides/getting-started/express.mdx +71 -152
  71. package/.docs/raw/guides/getting-started/hono.mdx +227 -0
  72. package/.docs/raw/guides/getting-started/next-js.mdx +173 -63
  73. package/.docs/raw/guides/getting-started/vite-react.mdx +307 -137
  74. package/.docs/raw/guides/guide/research-assistant.mdx +4 -4
  75. package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +70 -0
  76. package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +17 -0
  77. package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +6 -0
  78. package/.docs/raw/index.mdx +1 -1
  79. package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/dashboard.mdx +2 -6
  80. package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/observability.mdx +1 -5
  81. package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/overview.mdx +2 -6
  82. package/.docs/raw/{deployment/mastra-cloud → mastra-cloud}/setting-up.mdx +3 -6
  83. package/.docs/raw/memory/overview.mdx +1 -1
  84. package/.docs/raw/memory/storage/memory-with-libsql.mdx +1 -1
  85. package/.docs/raw/memory/storage/memory-with-mongodb.mdx +1 -1
  86. package/.docs/raw/memory/storage/memory-with-pg.mdx +1 -1
  87. package/.docs/raw/memory/storage/memory-with-upstash.mdx +1 -1
  88. package/.docs/raw/{server-db/storage.mdx → memory/storage/overview.mdx} +2 -2
  89. package/.docs/raw/observability/logging.mdx +1 -1
  90. package/.docs/raw/observability/tracing/exporters/cloud.mdx +1 -1
  91. package/.docs/raw/observability/tracing/exporters/default.mdx +1 -1
  92. package/.docs/raw/rag/chunking-and-embedding.mdx +12 -25
  93. package/.docs/raw/rag/graph-rag.mdx +220 -0
  94. package/.docs/raw/rag/overview.mdx +1 -2
  95. package/.docs/raw/rag/retrieval.mdx +13 -29
  96. package/.docs/raw/rag/vector-databases.mdx +7 -3
  97. package/.docs/raw/reference/agents/agent.mdx +11 -4
  98. package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
  99. package/.docs/raw/reference/agents/getDefaultOptions.mdx +1 -1
  100. package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
  101. package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
  102. package/.docs/raw/reference/agents/getLLM.mdx +1 -1
  103. package/.docs/raw/reference/agents/getMemory.mdx +1 -1
  104. package/.docs/raw/reference/agents/getModel.mdx +1 -1
  105. package/.docs/raw/reference/agents/listScorers.mdx +1 -1
  106. package/.docs/raw/reference/ai-sdk/chat-route.mdx +1 -1
  107. package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +1 -1
  108. package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +1 -1
  109. package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +1 -1
  110. package/.docs/raw/reference/ai-sdk/network-route.mdx +1 -1
  111. package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +127 -0
  112. package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +107 -0
  113. package/.docs/raw/reference/ai-sdk/workflow-route.mdx +1 -1
  114. package/.docs/raw/reference/auth/auth0.mdx +1 -1
  115. package/.docs/raw/reference/auth/clerk.mdx +1 -1
  116. package/.docs/raw/reference/auth/firebase.mdx +1 -1
  117. package/.docs/raw/reference/auth/jwt.mdx +1 -1
  118. package/.docs/raw/reference/auth/supabase.mdx +1 -1
  119. package/.docs/raw/reference/auth/workos.mdx +1 -1
  120. package/.docs/raw/reference/cli/mastra.mdx +1 -1
  121. package/.docs/raw/reference/client-js/mastra-client.mdx +1 -1
  122. package/.docs/raw/reference/client-js/workflows.mdx +20 -0
  123. package/.docs/raw/reference/core/getServer.mdx +3 -3
  124. package/.docs/raw/reference/core/getStorage.mdx +1 -1
  125. package/.docs/raw/reference/core/getStoredAgentById.mdx +1 -1
  126. package/.docs/raw/reference/core/listStoredAgents.mdx +1 -1
  127. package/.docs/raw/reference/core/setStorage.mdx +1 -1
  128. package/.docs/raw/reference/logging/pino-logger.mdx +1 -1
  129. package/.docs/raw/reference/processors/processor-interface.mdx +314 -13
  130. package/.docs/raw/reference/rag/database-config.mdx +1 -1
  131. package/.docs/raw/reference/server/create-route.mdx +1 -1
  132. package/.docs/raw/reference/server/express-adapter.mdx +4 -4
  133. package/.docs/raw/reference/server/hono-adapter.mdx +4 -4
  134. package/.docs/raw/reference/server/mastra-server.mdx +2 -2
  135. package/.docs/raw/reference/server/routes.mdx +28 -1
  136. package/.docs/raw/reference/streaming/ChunkType.mdx +23 -2
  137. package/.docs/raw/reference/streaming/agents/stream.mdx +38 -29
  138. package/.docs/raw/reference/streaming/workflows/stream.mdx +33 -20
  139. package/.docs/raw/reference/tools/create-tool.mdx +23 -1
  140. package/.docs/raw/reference/tools/graph-rag-tool.mdx +3 -3
  141. package/.docs/raw/reference/tools/vector-query-tool.mdx +3 -3
  142. package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +143 -0
  143. package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +35 -0
  144. package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +68 -3
  145. package/.docs/raw/reference/workflows/workflow.mdx +37 -0
  146. package/.docs/raw/{auth → server/auth}/auth0.mdx +1 -1
  147. package/.docs/raw/{auth → server/auth}/clerk.mdx +1 -1
  148. package/.docs/raw/{auth → server/auth}/firebase.mdx +1 -1
  149. package/.docs/raw/{auth → server/auth}/index.mdx +6 -6
  150. package/.docs/raw/{auth → server/auth}/jwt.mdx +1 -1
  151. package/.docs/raw/{auth → server/auth}/supabase.mdx +1 -1
  152. package/.docs/raw/{auth → server/auth}/workos.mdx +1 -1
  153. package/.docs/raw/{server-db → server}/custom-adapters.mdx +3 -3
  154. package/.docs/raw/{server-db → server}/custom-api-routes.mdx +1 -1
  155. package/.docs/raw/{server-db → server}/mastra-client.mdx +2 -2
  156. package/.docs/raw/{server-db → server}/mastra-server.mdx +12 -10
  157. package/.docs/raw/{server-db → server}/middleware.mdx +2 -2
  158. package/.docs/raw/{server-db → server}/request-context.mdx +3 -3
  159. package/.docs/raw/{server-db → server}/server-adapters.mdx +6 -6
  160. package/.docs/raw/tools-mcp/overview.mdx +2 -2
  161. package/.docs/raw/workflows/control-flow.mdx +348 -2
  162. package/.docs/raw/workflows/error-handling.mdx +162 -1
  163. package/.docs/raw/workflows/overview.mdx +2 -2
  164. package/CHANGELOG.md +21 -0
  165. package/package.json +5 -5
  166. package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
  167. package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
  168. /package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +0 -0
@@ -9,7 +9,7 @@ The `Processor` interface defines the contract for all processors in Mastra. Pro
9
9
 
10
10
  ## When processor methods run
11
11
 
12
- The four processor methods run at different points in the agent execution lifecycle:
12
+ The five processor methods run at different points in the agent execution lifecycle:
13
13
 
14
14
  ```
15
15
  ┌─────────────────────────────────────────────────────────────────┐
@@ -39,6 +39,11 @@ The four processor methods run at different points in the agent execution lifecy
39
39
  │ │ └──────────┬───────────┘ │ │
40
40
  │ │ │ │ │
41
41
  │ │ ▼ │ │
42
+ │ │ ┌──────────────────────┐ │ │
43
+ │ │ │ processOutputStep │ ← Runs after EACH LLM step │ │
44
+ │ │ └──────────┬───────────┘ │ │
45
+ │ │ │ │ │
46
+ │ │ ▼ │ │
42
47
  │ │ Tool Execution (if needed) │ │
43
48
  │ │ │ │ │
44
49
  │ │ └──────── Loop back if tools called ────────│ │
@@ -60,6 +65,7 @@ The four processor methods run at different points in the agent execution lifecy
60
65
  | `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context |
61
66
  | `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results |
62
67
  | `processOutputStream` | On each streaming chunk during LLM response | Filter/modify streaming content, detect patterns in real-time |
68
+ | `processOutputStep` | After each LLM response, before tool execution | Validate output quality, implement guardrails with retry |
63
69
  | `processOutputResult` | Once after generation completes | Post-process final response, log results |
64
70
 
65
71
  ## Interface definition
@@ -70,9 +76,10 @@ interface Processor<TId extends string = string> {
70
76
  readonly name?: string;
71
77
 
72
78
  processInput?(args: ProcessInputArgs): Promise<ProcessInputResult> | ProcessInputResult;
79
+ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
73
80
  processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null | undefined>;
81
+ processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult;
74
82
  processOutputResult?(args: ProcessOutputResultArgs): ProcessorMessageResult;
75
- processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
76
83
  }
77
84
  ```
78
85
 
@@ -129,10 +136,16 @@ processInput?(args: ProcessInputArgs): Promise<ProcessInputResult> | ProcessInpu
129
136
  },
130
137
  {
131
138
  name: "abort",
132
- type: "(reason?: string) => never",
133
- description: "Function to abort processing. Throws a TripWire error that stops execution.",
139
+ type: "(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never",
140
+ description: "Function to abort processing. Throws a TripWire error that stops execution. Pass `retry: true` to request the LLM retry the step with feedback.",
134
141
  isOptional: false,
135
142
  },
143
+ {
144
+ name: "retryCount",
145
+ type: "number",
146
+ description: "Number of times processors have triggered retry for this generation. Use this to limit retry attempts.",
147
+ isOptional: true,
148
+ },
136
149
  {
137
150
  name: "tracingContext",
138
151
  type: "TracingContext",
@@ -185,8 +198,8 @@ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
185
198
  #### Execution order in the agentic loop
186
199
 
187
200
  1. `processInput` (once at start)
188
- 2. `processInputStep` (at each step, before LLM call)
189
- 3. `prepareStep` callback (if provided)
201
+ 2. `processInputStep` from inputProcessors (at each step, before LLM call)
202
+ 3. `prepareStep` callback (runs as part of the processInputStep pipeline, after inputProcessors)
190
203
  4. LLM execution
191
204
  5. Tool execution (if needed)
192
205
  6. Repeat from step 2 if tools were called
@@ -198,13 +211,13 @@ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
198
211
  {
199
212
  name: "messages",
200
213
  type: "MastraDBMessage[]",
201
- description: "All messages including tool calls and results from previous steps.",
214
+ description: "All messages including tool calls and results from previous steps (read-only snapshot).",
202
215
  isOptional: false,
203
216
  },
204
217
  {
205
218
  name: "messageList",
206
219
  type: "MessageList",
207
- description: "MessageList instance for managing messages.",
220
+ description: "MessageList instance for managing messages. Can mutate directly or return in result.",
208
221
  isOptional: false,
209
222
  },
210
223
  {
@@ -213,12 +226,60 @@ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
213
226
  description: "Current step number (0-indexed). Step 0 is the initial LLM call.",
214
227
  isOptional: false,
215
228
  },
229
+ {
230
+ name: "steps",
231
+ type: "StepResult[]",
232
+ description: "Results from previous steps, including text, toolCalls, and toolResults.",
233
+ isOptional: false,
234
+ },
216
235
  {
217
236
  name: "systemMessages",
218
237
  type: "CoreMessage[]",
219
- description: "All system messages for read/modify access.",
238
+ description: "All system messages (read-only snapshot). Return in result to replace.",
220
239
  isOptional: false,
221
240
  },
241
+ {
242
+ name: "model",
243
+ type: "MastraLanguageModelV2",
244
+ description: "Current model being used. Return a different model in result to switch.",
245
+ isOptional: false,
246
+ },
247
+ {
248
+ name: "toolChoice",
249
+ type: "ToolChoice",
250
+ description: "Current tool choice setting ('auto', 'none', 'required', or specific tool).",
251
+ isOptional: true,
252
+ },
253
+ {
254
+ name: "activeTools",
255
+ type: "string[]",
256
+ description: "Currently active tool names. Return filtered array to limit tools.",
257
+ isOptional: true,
258
+ },
259
+ {
260
+ name: "tools",
261
+ type: "ToolSet",
262
+ description: "Current tools available for this step. Return in result to add/replace tools.",
263
+ isOptional: true,
264
+ },
265
+ {
266
+ name: "providerOptions",
267
+ type: "SharedV2ProviderOptions",
268
+ description: "Provider-specific options (e.g., Anthropic cacheControl, OpenAI reasoningEffort).",
269
+ isOptional: true,
270
+ },
271
+ {
272
+ name: "modelSettings",
273
+ type: "CallSettings",
274
+ description: "Model settings like temperature, maxTokens, topP.",
275
+ isOptional: true,
276
+ },
277
+ {
278
+ name: "structuredOutput",
279
+ type: "StructuredOutputOptions",
280
+ description: "Structured output configuration (schema, output mode). Return in result to modify.",
281
+ isOptional: true,
282
+ },
222
283
  {
223
284
  name: "abort",
224
285
  type: "(reason?: string) => never",
@@ -240,12 +301,99 @@ processInputStep?(args: ProcessInputStepArgs): ProcessorMessageResult;
240
301
  ]}
241
302
  />
242
303
 
304
+ #### ProcessInputStepResult
305
+
306
+ The method can return any combination of these properties:
307
+
308
+ <PropertiesTable
309
+ content={[
310
+ {
311
+ name: "model",
312
+ type: "LanguageModelV2 | string",
313
+ description: "Change the model for this step. Can be a model instance or router ID like 'openai/gpt-4o'.",
314
+ isOptional: true,
315
+ },
316
+ {
317
+ name: "toolChoice",
318
+ type: "ToolChoice",
319
+ description: "Change tool selection behavior for this step.",
320
+ isOptional: true,
321
+ },
322
+ {
323
+ name: "activeTools",
324
+ type: "string[]",
325
+ description: "Filter which tools are available for this step.",
326
+ isOptional: true,
327
+ },
328
+ {
329
+ name: "tools",
330
+ type: "ToolSet",
331
+ description: "Replace or modify tools for this step. Use spread to merge: { tools: { ...tools, newTool } }.",
332
+ isOptional: true,
333
+ },
334
+ {
335
+ name: "messages",
336
+ type: "MastraDBMessage[]",
337
+ description: "Replace all messages. Cannot be used with messageList.",
338
+ isOptional: true,
339
+ },
340
+ {
341
+ name: "messageList",
342
+ type: "MessageList",
343
+ description: "Return the same messageList instance (indicates you mutated it). Cannot be used with messages.",
344
+ isOptional: true,
345
+ },
346
+ {
347
+ name: "systemMessages",
348
+ type: "CoreMessage[]",
349
+ description: "Replace all system messages for this step only.",
350
+ isOptional: true,
351
+ },
352
+ {
353
+ name: "providerOptions",
354
+ type: "SharedV2ProviderOptions",
355
+ description: "Change provider-specific options for this step.",
356
+ isOptional: true,
357
+ },
358
+ {
359
+ name: "modelSettings",
360
+ type: "CallSettings",
361
+ description: "Change model settings for this step.",
362
+ isOptional: true,
363
+ },
364
+ {
365
+ name: "structuredOutput",
366
+ type: "StructuredOutputOptions",
367
+ description: "Change structured output configuration for this step.",
368
+ isOptional: true,
369
+ },
370
+ ]}
371
+ />
372
+
373
+ #### Processor chaining
374
+
375
+ When multiple processors implement `processInputStep`, they run in order and changes chain through:
376
+
377
+ ```
378
+ Processor 1: receives { model: 'gpt-4o' } → returns { model: 'gpt-4o-mini' }
379
+ Processor 2: receives { model: 'gpt-4o-mini' } → returns { toolChoice: 'none' }
380
+ Final: model = 'gpt-4o-mini', toolChoice = 'none'
381
+ ```
382
+
383
+ #### System message isolation
384
+
385
+ System messages are **reset to their original values** at the start of each step. Modifications made in `processInputStep` only affect the current step, not subsequent steps.
386
+
243
387
  #### Use cases
244
388
 
389
+ - Dynamic model switching based on step number or context
390
+ - Disabling tools after a certain number of steps
391
+ - Dynamically adding or replacing tools based on conversation context
245
392
  - Transforming message part types between providers (e.g., `reasoning` → `thinking` for Anthropic)
246
393
  - Modifying messages based on step number or accumulated context
247
- - Implementing per-step message filtering or enrichment
248
- - Adding step-specific context or instructions
394
+ - Adding step-specific system instructions
395
+ - Adjusting provider options per step (e.g., cache control)
396
+ - Modifying structured output schema based on step context
249
397
 
250
398
  ---
251
399
 
@@ -358,6 +506,125 @@ processOutputResult?(args: ProcessOutputResultArgs): ProcessorMessageResult;
358
506
  ]}
359
507
  />
360
508
 
509
+ ---
510
+
511
+ ### processOutputStep
512
+
513
+ Processes output after each LLM response in the agentic loop, before tool execution. Unlike `processOutputResult` which runs once at the end, this runs at every step. This is the ideal method for implementing guardrails that can trigger retries.
514
+
515
+ ```typescript copy
516
+ processOutputStep?(args: ProcessOutputStepArgs): ProcessorMessageResult;
517
+ ```
518
+
519
+ #### ProcessOutputStepArgs
520
+
521
+ <PropertiesTable
522
+ content={[
523
+ {
524
+ name: "messages",
525
+ type: "MastraDBMessage[]",
526
+ description: "All messages including the latest LLM response.",
527
+ isOptional: false,
528
+ },
529
+ {
530
+ name: "messageList",
531
+ type: "MessageList",
532
+ description: "MessageList instance for managing messages.",
533
+ isOptional: false,
534
+ },
535
+ {
536
+ name: "stepNumber",
537
+ type: "number",
538
+ description: "Current step number (0-indexed).",
539
+ isOptional: false,
540
+ },
541
+ {
542
+ name: "finishReason",
543
+ type: "string",
544
+ description: "The finish reason from the LLM (stop, tool-use, length, etc.).",
545
+ isOptional: true,
546
+ },
547
+ {
548
+ name: "toolCalls",
549
+ type: "ToolCallInfo[]",
550
+ description: "Tool calls made in this step (if any).",
551
+ isOptional: true,
552
+ },
553
+ {
554
+ name: "text",
555
+ type: "string",
556
+ description: "Generated text from this step.",
557
+ isOptional: true,
558
+ },
559
+ {
560
+ name: "systemMessages",
561
+ type: "CoreMessage[]",
562
+ description: "All system messages for read/modify access.",
563
+ isOptional: true,
564
+ },
565
+ {
566
+ name: "abort",
567
+ type: "(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never",
568
+ description: "Function to abort processing. Pass `retry: true` to request the LLM retry the step.",
569
+ isOptional: false,
570
+ },
571
+ {
572
+ name: "retryCount",
573
+ type: "number",
574
+ description: "Number of times processors have triggered retry. Use this to limit retry attempts.",
575
+ isOptional: true,
576
+ },
577
+ {
578
+ name: "tracingContext",
579
+ type: "TracingContext",
580
+ description: "Tracing context for observability.",
581
+ isOptional: true,
582
+ },
583
+ {
584
+ name: "requestContext",
585
+ type: "RequestContext",
586
+ description: "Request-scoped context with execution metadata.",
587
+ isOptional: true,
588
+ },
589
+ ]}
590
+ />
591
+
592
+ #### Use cases
593
+
594
+ - Implementing quality guardrails that can request retries
595
+ - Validating LLM output before tool execution
596
+ - Adding per-step logging or metrics
597
+ - Implementing output moderation with retry capability
598
+
599
+ #### Example: Quality guardrail with retry
600
+
601
+ ```typescript title="src/mastra/processors/quality-guardrail.ts" showLineNumbers copy
602
+ import type { Processor } from "@mastra/core";
603
+
604
+ export class QualityGuardrail implements Processor {
605
+ id = "quality-guardrail";
606
+
607
+ async processOutputStep({ text, abort, retryCount }) {
608
+ const score = await evaluateResponseQuality(text);
609
+
610
+ if (score < 0.7) {
611
+ if (retryCount < 3) {
612
+ // Request retry with feedback for the LLM
613
+ abort("Response quality too low. Please provide more detail.", {
614
+ retry: true,
615
+ metadata: { qualityScore: score },
616
+ });
617
+ } else {
618
+ // Max retries reached, block the response
619
+ abort("Response quality too low after multiple attempts.");
620
+ }
621
+ }
622
+
623
+ return [];
624
+ }
625
+ }
626
+ ```
627
+
361
628
  ## Processor types
362
629
 
363
630
  Mastra provides type aliases to ensure processors implement the required methods:
@@ -369,9 +636,10 @@ type InputProcessor = Processor & (
369
636
  | { processInputStep: required }
370
637
  );
371
638
 
372
- // Must implement processOutputStream OR processOutputResult (or both)
639
+ // Must implement processOutputStream, processOutputStep, OR processOutputResult (or any combination)
373
640
  type OutputProcessor = Processor & (
374
641
  | { processOutputStream: required }
642
+ | { processOutputStep: required }
375
643
  | { processOutputResult: required }
376
644
  );
377
645
  ```
@@ -404,13 +672,46 @@ export class LowercaseProcessor implements Processor {
404
672
 
405
673
  ### Per-step processor with processInputStep
406
674
 
675
+ ```typescript title="src/mastra/processors/dynamic-model.ts" showLineNumbers copy
676
+ import type { Processor, ProcessInputStepArgs, ProcessInputStepResult } from "@mastra/core";
677
+
678
+ export class DynamicModelProcessor implements Processor {
679
+ id = "dynamic-model";
680
+
681
+ async processInputStep({
682
+ stepNumber,
683
+ steps,
684
+ toolChoice,
685
+ }: ProcessInputStepArgs): Promise<ProcessInputStepResult> {
686
+ // Use a fast model for initial response
687
+ if (stepNumber === 0) {
688
+ return { model: "openai/gpt-4o-mini" };
689
+ }
690
+
691
+ // Switch to powerful model after tool calls
692
+ if (steps.length > 0 && steps[steps.length - 1].toolCalls?.length) {
693
+ return { model: "openai/gpt-4o" };
694
+ }
695
+
696
+ // Disable tools after 5 steps to force completion
697
+ if (stepNumber > 5) {
698
+ return { toolChoice: "none" };
699
+ }
700
+
701
+ return {};
702
+ }
703
+ }
704
+ ```
705
+
706
+ ### Message transformer with processInputStep
707
+
407
708
  ```typescript title="src/mastra/processors/reasoning-transformer.ts" showLineNumbers copy
408
709
  import type { Processor, MastraDBMessage } from "@mastra/core";
409
710
 
410
711
  export class ReasoningTransformer implements Processor {
411
712
  id = "reasoning-transformer";
412
713
 
413
- async processInputStep({ messages, messageList, stepNumber }) {
714
+ async processInputStep({ messages, messageList }) {
414
715
  // Transform reasoning parts to thinking parts at each step
415
716
  // This is useful when switching between model providers
416
717
  for (const msg of messages) {
@@ -348,5 +348,5 @@ const vectorTool = createVectorQueryTool({
348
348
  ## Related
349
349
 
350
350
  - [createVectorQueryTool()](/reference/v1/tools/vector-query-tool)
351
- - [Hybrid Vector Search](/examples/v1/rag/query/hybrid-vector-search)
351
+ - [Hybrid Vector Search](/docs/v1/rag/retrieval#metadata-filtering)
352
352
  - [Metadata Filters](/reference/v1/rag/metadata-filters)
@@ -325,4 +325,4 @@ Common status codes:
325
325
 
326
326
  - [Server Routes](/reference/v1/server/routes) - Default Mastra routes
327
327
  - [MastraServer](/reference/v1/server/mastra-server) - Server adapter class
328
- - [Server Adapters](/docs/v1/server-db/server-adapters) - Using adapters
328
+ - [Server Adapters](/docs/v1/server/server-adapters) - Using adapters
@@ -13,7 +13,7 @@ The `@mastra/express` package provides a server adapter for running Mastra with
13
13
 
14
14
  :::info
15
15
 
16
- For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server-db/server-adapters).
16
+ For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server/server-adapters).
17
17
 
18
18
  :::
19
19
 
@@ -26,7 +26,7 @@ For general adapter concepts (constructor options, initialization flow, etc.), s
26
26
  Install the Express adapter and Express framework:
27
27
 
28
28
  ```bash copy
29
- npm install @mastra/express express
29
+ npm install @mastra/express@beta express
30
30
  ```
31
31
 
32
32
  </StepItem>
@@ -246,7 +246,7 @@ app.use((req, res, next) => {
246
246
 
247
247
  ## Manual initialization
248
248
 
249
- For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server-db/server-adapters#manual-initialization) for details.
249
+ For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server/server-adapters#manual-initialization) for details.
250
250
 
251
251
  ## Examples
252
252
 
@@ -254,7 +254,7 @@ For custom middleware ordering, call each method separately instead of `init()`.
254
254
 
255
255
  ## Related
256
256
 
257
- - [Server Adapters](/docs/v1/server-db/server-adapters) - Shared adapter concepts
257
+ - [Server Adapters](/docs/v1/server/server-adapters) - Shared adapter concepts
258
258
  - [Hono Adapter](/reference/v1/server/hono-adapter) - Alternative adapter
259
259
  - [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
260
260
  - [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
@@ -13,7 +13,7 @@ The `@mastra/hono` package provides a server adapter for running Mastra with [Ho
13
13
 
14
14
  :::info
15
15
 
16
- For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server-db/server-adapters).
16
+ For general adapter concepts (constructor options, initialization flow, etc.), see [Server Adapters](/docs/v1/server/server-adapters).
17
17
 
18
18
  :::
19
19
 
@@ -26,7 +26,7 @@ For general adapter concepts (constructor options, initialization flow, etc.), s
26
26
  Install the Hono adapter and Hono framework:
27
27
 
28
28
  ```bash copy
29
- npm install @mastra/hono hono
29
+ npm install @mastra/hono@beta hono
30
30
  ```
31
31
 
32
32
  </StepItem>
@@ -228,7 +228,7 @@ app.use('*', async (c, next) => {
228
228
 
229
229
  ## Manual initialization
230
230
 
231
- For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server-db/server-adapters#manual-initialization) for details.
231
+ For custom middleware ordering, call each method separately instead of `init()`. See [Server Adapters: Manual initialization](/docs/v1/server/server-adapters#manual-initialization) for details.
232
232
 
233
233
  ## Examples
234
234
 
@@ -236,7 +236,7 @@ For custom middleware ordering, call each method separately instead of `init()`.
236
236
 
237
237
  ## Related
238
238
 
239
- - [Server Adapters](/docs/v1/server-db/server-adapters) - Shared adapter concepts
239
+ - [Server Adapters](/docs/v1/server/server-adapters) - Shared adapter concepts
240
240
  - [Express Adapter](/reference/v1/server/express-adapter) - Alternative adapter
241
241
  - [MastraServer Reference](/reference/v1/server/mastra-server) - Full API reference
242
242
  - [createRoute() Reference](/reference/v1/server/create-route) - Creating type-safe custom routes
@@ -340,6 +340,6 @@ export class MyServer extends MastraServer<MyApp, MyRequest, MyResponse> {
340
340
 
341
341
  ## Related
342
342
 
343
- - [Server Adapters](/docs/v1/server-db/server-adapters) - Using adapters
344
- - [Custom Adapters](/docs/v1/server-db/custom-adapters) - Creating custom adapters
343
+ - [Server Adapters](/docs/v1/server/server-adapters) - Using adapters
344
+ - [Custom Adapters](/docs/v1/server/custom-adapters) - Creating custom adapters
345
345
  - [createRoute()](/reference/v1/server/create-route) - Creating custom routes
@@ -58,16 +58,43 @@ Server adapters register these routes when you call `server.init()`. All routes
58
58
  |--------|------|-------------|
59
59
  | `GET` | `/api/workflows` | List all workflows |
60
60
  | `GET` | `/api/workflows/:workflowId` | Get workflow by ID |
61
+ | `POST` | `/api/workflows/:workflowId/create-run` | Create a new workflow run |
62
+ | `POST` | `/api/workflows/:workflowId/start-async` | Start workflow and await result |
61
63
  | `POST` | `/api/workflows/:workflowId/stream` | Stream workflow execution |
62
64
  | `POST` | `/api/workflows/:workflowId/resume` | Resume suspended workflow |
63
65
  | `POST` | `/api/workflows/:workflowId/resume-async` | Resume asynchronously |
64
66
  | `GET` | `/api/workflows/:workflowId/runs` | List workflow runs |
65
67
  | `GET` | `/api/workflows/:workflowId/runs/:runId` | Get specific run |
66
68
 
69
+ ### Create run request body
70
+
71
+ ```typescript
72
+ {
73
+ resourceId?: string; // Associate run with a resource (e.g., user ID)
74
+ disableScorers?: boolean; // Disable scorers for this run
75
+ }
76
+ ```
77
+
78
+ ### Start-async request body
79
+
80
+ ```typescript
81
+ {
82
+ resourceId?: string; // Associate run with a resource (e.g., user ID)
83
+ inputData?: unknown;
84
+ initialState?: unknown;
85
+ requestContext?: Record<string, unknown>;
86
+ tracingOptions?: {
87
+ spanName?: string;
88
+ attributes?: Record<string, unknown>;
89
+ };
90
+ }
91
+ ```
92
+
67
93
  ### Stream workflow request body
68
94
 
69
95
  ```typescript
70
96
  {
97
+ resourceId?: string; // Associate run with a resource (e.g., user ID)
71
98
  inputData?: unknown;
72
99
  initialState?: unknown;
73
100
  requestContext?: Record<string, unknown>;
@@ -247,4 +274,4 @@ Common status codes:
247
274
  ## Related
248
275
 
249
276
  - [createRoute()](/reference/v1/server/create-route) - Creating custom routes
250
- - [Server Adapters](/docs/v1/server-db/server-adapters) - Using adapters
277
+ - [Server Adapters](/docs/v1/server/server-adapters) - Using adapters
@@ -1255,7 +1255,7 @@ Contains monitoring and observability data from agent execution. Can include wor
1255
1255
 
1256
1256
  ### tripwire
1257
1257
 
1258
- Emitted when the stream is forcibly terminated due to content being blocked by output processors. This acts as a safety mechanism to prevent harmful or inappropriate content from being streamed.
1258
+ Emitted when the stream is forcibly terminated due to content being blocked by a processor. This acts as a safety mechanism to prevent harmful or inappropriate content from being streamed. The payload includes information about why the content was blocked and whether a retry was requested.
1259
1259
 
1260
1260
  <PropertiesTable
1261
1261
  content={[
@@ -1274,11 +1274,32 @@ Emitted when the stream is forcibly terminated due to content being blocked by o
1274
1274
  type: "TripwirePayload",
1275
1275
  parameters: [
1276
1276
  {
1277
- name: "tripwireReason",
1277
+ name: "reason",
1278
1278
  type: "string",
1279
1279
  description:
1280
1280
  "Explanation of why the content was blocked (e.g., 'Output processor blocked content')",
1281
1281
  },
1282
+ {
1283
+ name: "retry",
1284
+ type: "boolean",
1285
+ isOptional: true,
1286
+ description:
1287
+ "Whether the processor requested a retry of the step",
1288
+ },
1289
+ {
1290
+ name: "metadata",
1291
+ type: "unknown",
1292
+ isOptional: true,
1293
+ description:
1294
+ "Additional metadata from the processor (e.g., scores, categories)",
1295
+ },
1296
+ {
1297
+ name: "processorId",
1298
+ type: "string",
1299
+ isOptional: true,
1300
+ description:
1301
+ "ID of the processor that triggered the tripwire",
1302
+ },
1282
1303
  ],
1283
1304
  },
1284
1305
  ],