@mastra/mcp-docs-server 1.3.2-alpha.8 → 1.3.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.docs/docs/agents/code-mode.md +1 -1
  2. package/.docs/docs/agents/human-in-the-loop.md +2 -2
  3. package/.docs/docs/agents/processors.md +61 -7
  4. package/.docs/docs/agents/tools.md +3 -1
  5. package/.docs/docs/connections/acp.md +3 -3
  6. package/.docs/docs/connections/mcp.md +3 -1
  7. package/.docs/docs/deployment/workers.md +10 -3
  8. package/.docs/docs/develop.md +4 -4
  9. package/.docs/docs/evals/datasets.md +1 -1
  10. package/.docs/docs/evals/evals-with-memory.md +7 -6
  11. package/.docs/docs/evals/experiments.md +4 -4
  12. package/.docs/docs/evals/multi-turn.md +2 -2
  13. package/.docs/docs/evals/vitest-integration.md +1 -1
  14. package/.docs/docs/guides/authentication-identity.md +4 -2
  15. package/.docs/docs/guides/mcp-authentication-authorization.md +136 -0
  16. package/.docs/docs/harness/agent-controller.md +6 -4
  17. package/.docs/docs/harness/background-tasks.md +2 -2
  18. package/.docs/docs/harness/goals.md +27 -4
  19. package/.docs/docs/harness/schedules.md +28 -1
  20. package/.docs/docs/harness/signals.md +2 -2
  21. package/.docs/docs/index.md +1 -1
  22. package/.docs/docs/mastra-platform/deploy.md +1 -1
  23. package/.docs/docs/mastra-platform/environments.md +1 -1
  24. package/.docs/docs/mastra-platform/observability.md +1 -1
  25. package/.docs/docs/mastra-platform/workspaces.md +1 -1
  26. package/.docs/docs/memory/observational-memory.md +3 -3
  27. package/.docs/docs/memory/overview.md +1 -1
  28. package/.docs/docs/sandbox/skills.md +1 -1
  29. package/.docs/docs/server/pubsub.md +1 -1
  30. package/.docs/docs/server/server-adapters.md +55 -12
  31. package/.docs/docs/studio/auth.md +1 -1
  32. package/.docs/docs/workflows/control-flow.md +2 -1
  33. package/.docs/docs/workflows/dynamic-workflows.md +1 -1
  34. package/.docs/docs/workflows/overview.md +1 -1
  35. package/.docs/docs/workflows/scheduled-workflows.md +16 -8
  36. package/.docs/integrations/frameworks/nestjs.md +34 -1
  37. package/.docs/models/environment-variables.md +3 -1
  38. package/.docs/models/gateways/merge-gateway.md +3 -1
  39. package/.docs/models/gateways/netlify.md +3 -6
  40. package/.docs/models/gateways/openrouter.md +6 -3
  41. package/.docs/models/gateways/vercel.md +10 -4
  42. package/.docs/models/index.md +212 -2
  43. package/.docs/models/providers/302ai.md +5 -1
  44. package/.docs/models/providers/alibaba-cn.md +2 -1
  45. package/.docs/models/providers/alibaba-coding-plan-cn.md +1 -3
  46. package/.docs/models/providers/alibaba-coding-plan.md +1 -3
  47. package/.docs/models/providers/alibaba.md +5 -2
  48. package/.docs/models/providers/ambient.md +3 -1
  49. package/.docs/models/providers/anthropic.md +3 -2
  50. package/.docs/models/providers/bailing.md +1 -1
  51. package/.docs/models/providers/baseten.md +2 -1
  52. package/.docs/models/providers/bee.md +82 -0
  53. package/.docs/models/providers/cloudflare-workers-ai.md +3 -3
  54. package/.docs/models/providers/coralbricks.md +2 -3
  55. package/.docs/models/providers/cortecs.md +4 -3
  56. package/.docs/models/providers/crossmodel.md +2 -1
  57. package/.docs/models/providers/deepinfra.md +2 -5
  58. package/.docs/models/providers/digitalocean.md +2 -1
  59. package/.docs/models/providers/edenai.md +289 -290
  60. package/.docs/models/providers/kilo.md +30 -27
  61. package/.docs/models/providers/llmgateway-providers.md +25 -21
  62. package/.docs/models/providers/llmgateway.md +17 -8
  63. package/.docs/models/providers/minimax-cn-coding-plan.md +12 -11
  64. package/.docs/models/providers/minimax-coding-plan.md +12 -11
  65. package/.docs/models/providers/mistral.md +1 -2
  66. package/.docs/models/providers/nan.md +3 -2
  67. package/.docs/models/providers/nano-gpt.md +8 -6
  68. package/.docs/models/providers/nebius.md +2 -1
  69. package/.docs/models/providers/nvidia.md +1 -47
  70. package/.docs/models/providers/ofox.md +3 -1
  71. package/.docs/models/providers/openai.md +44 -41
  72. package/.docs/models/providers/opencode-go.md +1 -5
  73. package/.docs/models/providers/opencode.md +4 -2
  74. package/.docs/models/providers/pareto.md +77 -0
  75. package/.docs/models/providers/pioneer.md +4 -2
  76. package/.docs/models/providers/privatemode-ai.md +2 -2
  77. package/.docs/models/providers/requesty.md +7 -1
  78. package/.docs/models/providers/scaleway.md +2 -1
  79. package/.docs/models/providers/tempr.md +48 -5
  80. package/.docs/models/providers/togetherai.md +1 -3
  81. package/.docs/models/providers/umans-ai-coding-plan.md +1 -1
  82. package/.docs/models/providers/umans-ai.md +1 -1
  83. package/.docs/models/providers.md +3 -1
  84. package/.docs/reference/agent-controller/agent-controller-class.md +2 -0
  85. package/.docs/reference/agent-controller/session.md +5 -5
  86. package/.docs/reference/agents/channels.md +3 -1
  87. package/.docs/reference/agents/durable-agent.md +1 -1
  88. package/.docs/reference/channels/teams-provider.md +189 -0
  89. package/.docs/reference/classifier/classifier.md +84 -15
  90. package/.docs/reference/client-js/agent-controller.md +1 -1
  91. package/.docs/reference/client-js/observability.md +1 -1
  92. package/.docs/reference/code-sdk/acp-server.md +101 -0
  93. package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
  94. package/.docs/reference/configuration.md +2 -1
  95. package/.docs/reference/datasets/finalizeExperiment.md +1 -1
  96. package/.docs/reference/evals/create-classifier-scorer.md +2 -1
  97. package/.docs/reference/evals/create-scorer.md +1 -1
  98. package/.docs/reference/file-based-agents/logger.md +1 -1
  99. package/.docs/reference/file-based-agents/schedules.md +3 -3
  100. package/.docs/reference/file-based-agents/workspace.md +1 -1
  101. package/.docs/reference/index.md +2 -0
  102. package/.docs/reference/memory/observational-memory.md +3 -1
  103. package/.docs/reference/migrations/mcp-v2.md +1 -1
  104. package/.docs/reference/observability/tracing/interfaces.md +1 -1
  105. package/.docs/reference/observability/tracing/spans.md +1 -1
  106. package/.docs/reference/observability/tracing/trace-query.md +37 -16
  107. package/.docs/reference/processors/classifier-processor.md +12 -4
  108. package/.docs/reference/processors/model-selection-processor.md +13 -6
  109. package/.docs/reference/processors/prefill-error-handler.md +2 -2
  110. package/.docs/reference/processors/processor-interface.md +2 -2
  111. package/.docs/reference/processors/provider-history-compat.md +37 -17
  112. package/.docs/reference/processors/stream-error-retry-processor.md +9 -4
  113. package/.docs/reference/processors/tool-search-processor.md +1 -1
  114. package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
  115. package/.docs/reference/pubsub/redis-streams.md +3 -3
  116. package/.docs/reference/rag/graph-rag.md +1 -1
  117. package/.docs/reference/server/elysia-adapter.md +2 -0
  118. package/.docs/reference/server/express-adapter.md +1 -1
  119. package/.docs/reference/server/fastify-adapter.md +2 -0
  120. package/.docs/reference/server/hono-adapter.md +2 -0
  121. package/.docs/reference/server/koa-adapter.md +2 -0
  122. package/.docs/reference/server/nestjs-adapter.md +48 -0
  123. package/.docs/reference/storage/retention.md +1 -1
  124. package/.docs/reference/tools/mcp-server.md +25 -10
  125. package/.docs/reference/workers/overview.md +3 -1
  126. package/.docs/reference/workflows/step.md +2 -1
  127. package/.docs/reference/workflows/workflow.md +1 -1
  128. package/.docs/reference/workspace/local-sandbox.md +2 -0
  129. package/.docs/reference/workspace/platform-sandbox.md +1 -1
  130. package/.docs/reference/workspace/sandbox.md +1 -1
  131. package/.docs/reference/workspace/workspace-class.md +1 -1
  132. package/package.json +6 -6
@@ -10,7 +10,7 @@ Use it when an agent may switch between model providers or reuse message history
10
10
 
11
11
  ## Usage example
12
12
 
13
- Add `ProviderHistoryCompat` to both lists when you want all built-in compatibility rules available for an agent. `inputProcessors` drives the preemptive rewrites, `errorProcessors` drives the reactive recovery:
13
+ Mastra adds this processor to every agent's `errorProcessors` by default when your list doesn't already contain that `id`. Among the added defaults it comes first. Its outbound prompt rules run before the other defaults, including the retry processor's blind resend. Supply your own instance to add custom rules or position it yourself:
14
14
 
15
15
  ```typescript
16
16
  import { Agent } from '@mastra/core/agent'
@@ -21,19 +21,18 @@ export const agent = new Agent({
21
21
  name: 'my-agent',
22
22
  instructions: 'You are a helpful assistant.',
23
23
  model: 'anthropic/claude-sonnet-4-5',
24
- inputProcessors: [new ProviderHistoryCompat()],
25
- errorProcessors: [new ProviderHistoryCompat()],
24
+ errorProcessors: [new ProviderHistoryCompat({ additionalRules: [/* ... */] })],
26
25
  })
27
26
  ```
28
27
 
29
- Mastra agents don't add this processor automatically. Add it explicitly when you need provider history compatibility rules, reactive API error recovery, custom rules, or predictable processor ordering.
28
+ A supplied `ProviderHistoryCompat` is used instead of the default. The default is only added when no processor in your list carries that `id`. Place an instance in `inputProcessors` when you want the prompt-rewriting rules to run in the input lane instead.
30
29
 
31
30
  The placement decides which half of the processor works:
32
31
 
33
- - **Reactive rules need `errorProcessors`.** On the standard loop, `processAPIError` runs from any of the three lists, so an input-processor registration does repair the message list, but the retry it asks for is only honored when the agent has a retry budget, and that budget is left `undefined` unless the agent configures `errorProcessors` or sets `maxProcessorRetries` explicitly. Registered only as an input processor and without an explicit `maxProcessorRetries`, a reactive rule repairs the history and the request still fails. On the durable path the API-error pass additionally requires a non-empty `errorProcessors` list. If that list is empty, an input-processor registration can't trigger reactive recovery there at all, even with `maxProcessorRetries` set.
34
- - **Preemptive rules need `inputProcessors`.** `processLLMRequest` runs over the input processors only, so prompt rewrites don't happen from the error list.
32
+ - **Reactive rules need `errorProcessors`.** On the standard loop, `processAPIError` runs from any of the three lists, so an input-processor registration does repair the message list, but the retry it asks for is only honored when the agent has a retry budget. With the default error processors in place the resolved list is non-empty, so a safety cap of `3` applies. The budget is left `undefined` only when the caller runs with no error processors at all (`errorProcessorDefaults: false` with none configured) and doesn't set `maxProcessorRetries` explicitly. Registered only as an input processor in that no-budget state, a reactive rule repairs the history and the request still fails. On the durable path the API-error pass additionally requires a non-empty `errorProcessors` list. If that list is empty, an input-processor registration can't trigger reactive recovery there at all, even with `maxProcessorRetries` set.
33
+ - **Preemptive rules run from either list.** `processLLMRequest` runs over the input processors and over the resolved error processors, so a `ProviderHistoryCompat` in `errorProcessors` gets its prompt rewrites as well as its reactive recovery. An instance registered in `inputProcessors` runs once, in its input position.
35
34
 
36
- An agent that wants both registers the processor in both lists, as the example above does. Double registration can't cause a double retry: the runner stops at the first processor that asks for one, and each reactive rule bails once `retryCount` is above zero, so a repaired turn is attempted exactly once more.
35
+ Registering in `errorProcessors` alone, as the example above does, covers both halves. Double registration can't cause a double retry: the runner stops at the first processor that asks for one, and each reactive rule bails once `retryCount` is above zero, so a repaired turn is attempted exactly once more.
37
36
 
38
37
  ## Constructor parameters
39
38
 
@@ -55,19 +54,21 @@ An agent that wants both registers the processor in both lists, as the example a
55
54
 
56
55
  `ProviderHistoryCompat` includes these built-in compatibility rules:
57
56
 
58
- | Rule | Provider | Timing | Behavior |
59
- | ------------------------------------------- | -------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
60
- | `anthropic-tool-id-format` | Anthropic | Reactive API error recovery | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` and retries the request. |
61
- | `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
62
- | `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
63
- | `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-4-6`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
64
- | `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
65
- | `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, so the message replays by value instead of as an unsatisfiable `item_reference`, and retries. The repair is applied to the in-memory list for the current turn. |
57
+ | Rule | Provider | Timing | Behavior |
58
+ | ------------------------------------------- | -------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59
+ | `anthropic-tool-id-format` | Anthropic | Preemptive prompt rewrite | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` in the outbound prompt, on both the call and its result. A sanitized ID that would collide with one already in the prompt gets a `_2`, `_3`, … suffix. The provider's rejection never fires, and persisted history keeps the original IDs. A reactive fallback covers providers the preemptive check doesn't recognize, such as Vertex-hosted Claude. |
60
+ | `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
61
+ | `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
62
+ | `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-4-6`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
63
+ | `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
64
+ | `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, and retries. The message then replays by value instead of as an unsatisfiable `item_reference`. The repair is applied to the in-memory list for the current turn. |
66
65
 
67
- Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call.
66
+ Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call. Persisted history is never changed, so the IDs and content in memory and in the Studio stay exactly as written.
68
67
 
69
68
  Reactive rules run through `processAPIError` after a provider rejection. They can update the persisted `messageList` and request a retry.
70
69
 
70
+ `anthropic-tool-id-format` implements both. Its preemptive hook normally prevents the rejection from happening at all, which leaves the reactive hook dormant. See [Tool call ID repair is prompt-scoped](#tool-call-id-repair-is-prompt-scoped) below.
71
+
71
72
  ## `CompatRule`
72
73
 
73
74
  A `CompatRule` defines one provider history compatibility fix:
@@ -140,7 +141,26 @@ export const agent = new Agent({
140
141
  })
141
142
  ```
142
143
 
143
- Use `applyToPrompt` for provider-specific rewrites that shouldn't be saved to memory. Use `fix` with `errorPatterns` when the provider rejects persisted message history and the repaired history should be reused on future turns.
144
+ Use `applyToPrompt` for provider-specific rewrites that shouldn't be saved to memory. This is what new rules should normally reach for, and it's the hook the built-in rules use. Use `fix` with `errorPatterns` only when the repaired history must persist and be reused on future turns, and when the provider can't be stopped from rejecting the request up front.
145
+
146
+ ## Tool call ID repair is prompt-scoped
147
+
148
+ Anthropic enforces `^[a-zA-Z0-9_-]+$` on `tool_use.id`. A tool call whose ID came from another provider, containing `.` or `:`, is rejected. The rule sanitizes those IDs in the outbound request:
149
+
150
+ ```typescript
151
+ // What the provider receives
152
+ tool_use.id: 'call_abc_1'
153
+ // What stays in memory, in the returned messages, and in the Studio
154
+ toolCallId: 'call.abc:1'
155
+ ```
156
+
157
+ Both the `tool-call` and its paired `tool-result` are rewritten from the same map, so call/result pairing survives the rewrite. Replacement IDs are assigned in encounter order and never collide with an ID the prompt already carries: if `a.b` sanitizes to `a_b` and the prompt already has an `a_b`, the rewritten ID becomes `a_b_2`.
158
+
159
+ Because nothing is persisted, a caller that reuses the same message list in a later turn sees the original IDs again, and the repair runs again on that request.
160
+
161
+ ### Reactive fallback
162
+
163
+ The rule's `errorPatterns` and `fix` hooks repair the same rejection after the provider raises it. The preemptive rewrite only runs when `isMaybeAnthropic(model)` matches. The reactive path stays the fallback for Claude served through a provider the check doesn't recognize, such as Vertex-hosted Claude, and the only repair once a call has already been rejected. A rule can use both hooks together, and `fix` on the `CompatRule` interface itself isn't deprecated: custom rules legitimately use it.
144
164
 
145
165
  ## Related
146
166
 
@@ -6,11 +6,11 @@
6
6
 
7
7
  `StreamErrorRetryProcessor` is an **error processor** that retries transient LLM API and stream failures. It includes built-in matching for OpenAI Responses stream errors and supports additional matchers for other provider-specific error shapes.
8
8
 
9
- The processor isn't enabled by default in core. Add it to `errorProcessors` for agents that need bounded retry handling.
9
+ Mastra adds this processor to every agent's `errorProcessors` by default, last, after the `ProviderHistoryCompat` and `PrefillErrorHandler` defaults, so the processors that repair a request get their chance before this one retries it unchanged. The default instance uses `maxRetries: 2` with a connection-reset matcher alongside the built-in matching, and it doesn't retry unknown errors or replay bad-request (HTTP 400) responses the repair processors couldn't fix. Supply your own instance in `errorProcessors` to change its policy. Because a default is only added when its `id` is missing from your list, your instance is used and the default isn't added alongside it.
10
10
 
11
11
  ## Usage example
12
12
 
13
- Add `StreamErrorRetryProcessor` to `errorProcessors`:
13
+ Configure `StreamErrorRetryProcessor`. Supplying the same `id` means the default isn't added:
14
14
 
15
15
  ```typescript
16
16
  import { Agent } from '@mastra/core/agent'
@@ -21,10 +21,15 @@ export const agent = new Agent({
21
21
  name: 'openai-agent',
22
22
  instructions: 'You are a helpful assistant.',
23
23
  model: 'openai/gpt-5',
24
- errorProcessors: [new StreamErrorRetryProcessor()],
24
+ errorProcessors: [new StreamErrorRetryProcessor({ maxRetries: 5 })],
25
+ maxProcessorRetries: 5,
25
26
  })
26
27
  ```
27
28
 
29
+ Set `maxProcessorRetries` alongside a `maxRetries` above `3`, because the agent stops error-processor retries at `3` when it's unset. See [Retry limits](#retry-limits).
30
+
31
+ To run only the processors you configure, with none of the defaults merged in, set `errorProcessorDefaults: false`. Without an `errorProcessors` list, the agent then runs no error processors. An empty `errorProcessors` list still gets the defaults. Supplying your own processor for all three default ids replaces every default with your own implementation.
32
+
28
33
  ## How it works
29
34
 
30
35
  The processor checks the error and its cause chain for:
@@ -39,7 +44,7 @@ When `delayMs` is set, the processor waits before signaling a retry. This is use
39
44
 
40
45
  ### Retry limits
41
46
 
42
- `maxRetries` defaults to `1` and limits this processor's retry requests. The agent also limits processor retries with `maxProcessorRetries`. When error processors are configured without an agent limit, the runtime cap is `10`.
47
+ `maxRetries` defaults to `1` and limits this processor's retry requests. The agent also limits processor retries with `maxProcessorRetries`. When error processors are configured without an agent limit, the runtime cap is `3`.
43
48
 
44
49
  Set both values explicitly to the same bounded value when you need a single retry budget. Keep model `maxRetries` at `0` for that call to avoid multiplying provider attempts.
45
50
 
@@ -37,7 +37,7 @@ const toolSearch = new ToolSearchProcessor({
37
37
 
38
38
  **options.search.topK** (`number`): Maximum number of tools to return in search results.
39
39
 
40
- **options.search.minScore** (`number`): Minimum relevance score (0-1) for including a tool in search results.
40
+ **options.search.minScore** (`number`): Minimum relevance score for including a tool in search results. Scores are raw BM25 relevance plus name-match boosts (+5 when a query term equals the tool ID, +2 when it appears in the ID). They are not normalized and often exceed 1. Scores depend on the tools in the catalog and their descriptions, so a threshold tuned for one tool set may not carry over to another. Tools scoring less than or equal to this value are excluded. Use small values such as 0 to 0.5 to require some term overlap.
41
41
 
42
42
  **options.search.autoLoad** (`boolean`): When true, tools returned by search\_tools are activated immediately as part of the search. The load\_tool meta-tool is not exposed, collapsing the two-step search then load flow into a single search step. Discovered tools become available on the next turn. Keep topK conservative since every match is activated.
43
43
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  Use it for distributed deployments on Google Cloud. For single-process delivery, use [`EventEmitterPubSub`](https://mastra.ai/reference/pubsub/event-emitter). For Redis, use [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams).
10
10
 
11
- Each topic maps to a Google Cloud topic. Subscriptions with a group share a subscription, so members compete for events. Subscriptions without a group create a per-instance subscription, so every instance receives every event.
11
+ Each topic maps to a Google Cloud topic. Subscriptions with a group share a subscription. Members compete for events. Subscriptions without a group create a per-instance subscription. Every instance receives every event.
12
12
 
13
13
  ## Installation
14
14
 
@@ -4,11 +4,11 @@
4
4
 
5
5
  # RedisStreamsPubSub
6
6
 
7
- `RedisStreamsPubSub` is a [`PubSub`](https://mastra.ai/reference/pubsub/base) implementation backed by [Redis Streams](https://redis.io/docs/latest/develop/data-types/streams/). It delivers events across processes and hosts, with persistence, consumer groups, and redelivery on failure. It also implements [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider), so the signals layer can elect a single owner per resource across instances, which is what lets signals coordinate runs in distributed and serverless deployments.
7
+ `RedisStreamsPubSub` is a [`PubSub`](https://mastra.ai/reference/pubsub/base) implementation backed by [Redis Streams](https://redis.io/docs/latest/develop/data-types/streams/). It delivers events across processes and hosts, with persistence, consumer groups, and redelivery on failure. It also implements [`LeaseProvider`](https://mastra.ai/reference/pubsub/lease-provider). The signals layer can elect a single owner per resource across instances, which is what lets signals coordinate runs in distributed and serverless deployments.
8
8
 
9
9
  Use it for distributed deployments where several services share an event stream. For single-process delivery, use [`EventEmitterPubSub`](https://mastra.ai/reference/pubsub/event-emitter). For Google Cloud, use [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub).
10
10
 
11
- Each topic maps to a Redis stream key. Subscriptions with a group use a Redis consumer group, so members share work round-robin. Subscriptions without a group create a private consumer group, so every subscriber receives every event.
11
+ Each topic maps to a Redis stream key. Subscriptions with a group use a Redis consumer group. Members share work round-robin. Subscriptions without a group create a private consumer group. Every subscriber receives every event.
12
12
 
13
13
  `RedisStreamsPubSub` is a pull transport: consumers read events with `XREADGROUP`, so Mastra runs an orchestration worker to read on its behalf.
14
14
 
@@ -74,7 +74,7 @@ export const mastra = new Mastra({
74
74
 
75
75
  ### Bring your own client
76
76
 
77
- To control client construction yourself (TLS, credential providers, and so on), pass an unconnected `redis` client as `client`. The pubsub uses it as its writer and calls `client.duplicate()` for each subscription's blocking reader, so every connection stays distinct. The pubsub owns the client's lifecycle (it connects on first use and quits it on `close()`), so don't share it with the rest of your app.
77
+ To control client construction yourself (TLS, credential providers, and so on), pass an unconnected `redis` client as `client`. The pubsub uses it as its writer and calls `client.duplicate()` for each subscription's blocking reader. Every connection stays distinct. The pubsub owns the client's lifecycle (it connects on first use and quits it on `close()`), so don't share it with the rest of your app.
78
78
 
79
79
  ```typescript
80
80
  import { RedisStreamsPubSub } from '@mastra/redis-streams'
@@ -127,7 +127,7 @@ Throws if the snapshot version is unsupported, if a node embedding doesn't match
127
127
 
128
128
  ## Persisting a graph
129
129
 
130
- Building a graph is O(n²) in the number of chunks, so rebuilding it on every process start is wasteful. Serialize the graph once and store the snapshot wherever you already keep state. A snapshot is plain JSON, so any store works (a file, a blob column, a key-value cache), and `GraphRAG` doesn't depend on a storage backend.
130
+ Building a graph is O(n²) in the number of chunks, so rebuilding it on every process start is wasteful. Serialize the graph once and store the snapshot wherever you already keep state. A snapshot is plain JSON. Any store works (a file, a blob column, a key-value cache), and `GraphRAG` doesn't depend on a storage backend.
131
131
 
132
132
  ```typescript
133
133
  import { readFile, writeFile } from 'node:fs/promises'
@@ -53,6 +53,8 @@ app.listen(3000)
53
53
  console.log('Server running on http://localhost:3000')
54
54
  ```
55
55
 
56
+ `init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
57
+
56
58
  ## Constructor parameters
57
59
 
58
60
  **app** (`Elysia`): Elysia app instance
@@ -52,7 +52,7 @@ app.listen(4111, () => {
52
52
  })
53
53
  ```
54
54
 
55
- > **Note:** Express requires `express.json()` middleware for JSON body parsing. Add it before creating the `MastraServer`.
55
+ Express requires `express.json()` middleware for JSON body parsing. Add it before creating the `MastraServer`. `init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
56
56
 
57
57
  ## Constructor parameters
58
58
 
@@ -55,6 +55,8 @@ app.listen({ port: 3000 }, (err, address) => {
55
55
  })
56
56
  ```
57
57
 
58
+ `init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
59
+
58
60
  ## Constructor parameters
59
61
 
60
62
  **app** (`FastifyInstance`): Fastify app instance
@@ -49,6 +49,8 @@ await server.init()
49
49
  export default app
50
50
  ```
51
51
 
52
+ `init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
53
+
52
54
  ## Constructor parameters
53
55
 
54
56
  **app** (`Hono`): Hono app instance
@@ -54,6 +54,8 @@ app.listen(3000, () => {
54
54
  })
55
55
  ```
56
56
 
57
+ `init()` doesn't start Mastra's background workers. To run [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, or event listeners, call `await mastra.startWorkers()` after the server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
58
+
57
59
  ## Constructor parameters
58
60
 
59
61
  **app** (`Koa`): Koa app instance
@@ -149,6 +149,54 @@ export class WorkflowService {
149
149
  }
150
150
  ```
151
151
 
152
+ ## Start background workers
153
+
154
+ `MastraModule` doesn't start Mastra's background workers. Without them, [scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows), agent schedules, and event listeners never run. Call `mastra.startWorkers()` after the app starts listening:
155
+
156
+ ```typescript
157
+ import { NestFactory } from '@nestjs/core'
158
+ import { MASTRA } from '@mastra/nestjs'
159
+ import type { Mastra } from '@mastra/core/mastra'
160
+ import { AppModule } from './app.module'
161
+
162
+ async function bootstrap() {
163
+ const app = await NestFactory.create(AppModule)
164
+ app.enableShutdownHooks()
165
+ await app.listen(3000)
166
+
167
+ try {
168
+ await app.get<Mastra>(MASTRA).startWorkers()
169
+ } catch (error) {
170
+ console.error('Failed to start background workers', error)
171
+ await app.close()
172
+ process.exit(1)
173
+ }
174
+ }
175
+
176
+ bootstrap()
177
+ ```
178
+
179
+ The module's shutdown handling drains in-flight requests but doesn't stop Mastra. To stop workers and drain in-flight workflow runs, call `mastra.shutdown()` from a shutdown hook. The drain is bounded by `drainTimeout` (default 5 seconds), and runs that don't settle within it are abandoned with a warning:
180
+
181
+ ```typescript
182
+ import { Inject, Injectable, type OnApplicationShutdown } from '@nestjs/common'
183
+ import { MASTRA } from '@mastra/nestjs'
184
+ import type { Mastra } from '@mastra/core/mastra'
185
+
186
+ @Injectable()
187
+ export class MastraLifecycleService implements OnApplicationShutdown {
188
+ constructor(@Inject(MASTRA) private readonly mastra: Mastra) {}
189
+
190
+ async onApplicationShutdown() {
191
+ await this.mastra.shutdown()
192
+ }
193
+ }
194
+ ```
195
+
196
+ Add `MastraLifecycleService` to the `providers` of a module that imports `MastraModule`. Shutdown hooks only run when `app.enableShutdownHooks()` is called.
197
+
198
+ See [Start background workers](https://mastra.ai/docs/server/server-adapters) for more details.
199
+
152
200
  ## MCP routes
153
201
 
154
202
  MCP endpoints are exposed under the API prefix:
@@ -202,7 +202,7 @@ async function retentionTick() {
202
202
  }
203
203
  ```
204
204
 
205
- You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`, so the next run resumes cleanly.
205
+ You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`. The next run resumes cleanly.
206
206
 
207
207
  ## ClickHouse native TTL
208
208
 
@@ -154,37 +154,48 @@ The same request also populates `context.requestContext`, the trusted applicatio
154
154
  const authInfo = context.mcp?.extra.authInfo ?? context.requestContext?.get('authInfo')
155
155
  ```
156
156
 
157
- #### Example: Tool that reads the caller's token
157
+ #### Example: Tool that uses caller identity with a separate credential
158
158
 
159
159
  ```typescript
160
160
  import { createTool } from '@mastra/core/tools'
161
161
  import { z } from 'zod'
162
162
 
163
+ import { apiCredentials } from '../lib/api-credentials'
164
+
163
165
  const fetchUserData = createTool({
164
166
  id: 'fetchUserData',
165
- description: 'Fetches user data using authentication from MCP context',
167
+ description: 'Fetches data for the authenticated MCP caller',
166
168
  inputSchema: z.object({
167
- userId: z.string().describe('The ID of the user to fetch'),
169
+ resourceId: z.string().describe('The ID of the record to fetch'),
168
170
  }),
169
171
  execute: async (inputData, context) => {
170
172
  const authInfo = context.mcp?.extra.authInfo ?? context.requestContext?.get('authInfo')
173
+ const user = authInfo?.extra?.user as { id?: string } | undefined
171
174
 
172
- if (!authInfo?.token) {
175
+ if (!user?.id) {
173
176
  throw new Error('Authentication required')
174
177
  }
175
178
 
176
- const response = await fetch(`https://api.example.com/users/${inputData.userId}`, {
177
- headers: {
178
- Authorization: `Bearer ${authInfo.token}`,
179
+ // Resolve the owner from trusted context, not from model input
180
+ const credential = await apiCredentials.getForUser(user.id)
181
+
182
+ const response = await fetch(
183
+ `https://api.example.com/users/${encodeURIComponent(user.id)}/records/${encodeURIComponent(inputData.resourceId)}`,
184
+ {
185
+ headers: {
186
+ Authorization: `Bearer ${credential.token}`,
187
+ },
188
+ signal: context.mcp?.extra.signal,
179
189
  },
180
- signal: context.mcp?.extra.signal,
181
- })
190
+ )
182
191
 
183
192
  return response.json()
184
193
  },
185
194
  })
186
195
  ```
187
196
 
197
+ Use `authInfo` for caller identity, then select a credential intended for the service the tool calls. The model supplies business input such as `resourceId`, while trusted code selects the credential. An MCP access token is for your MCP server, so it must not be forwarded to another API. See [Access upstream services safely](https://mastra.ai/docs/guides/mcp-authentication-authorization).
198
+
188
199
  #### Where `authInfo` comes from
189
200
 
190
201
  When an MCP server is served by a Mastra server, `extra.authInfo` is populated from the principal resolved by `server.auth`. Nothing extra is required:
@@ -1113,8 +1124,12 @@ execute: async (inputData, context) => {
1113
1124
  console.log('User ID:', authInfo.extra.sub)
1114
1125
  console.log('Email:', authInfo.extra.email)
1115
1126
 
1127
+ // Use a credential intended for the API being called, not the MCP token.
1128
+ // See https://mastra.ai/docs/guides/mcp-authentication-authorization#access-upstream-services-safely
1129
+ const credential = await apiCredentials.getForUser(authInfo.extra.sub as string)
1130
+
1116
1131
  const response = await fetch('/api/data', {
1117
- headers: { Authorization: `Bearer ${authInfo.token}` },
1132
+ headers: { Authorization: `Bearer ${credential.token}` },
1118
1133
  signal: context.mcp?.extra.signal,
1119
1134
  })
1120
1135
 
@@ -25,6 +25,8 @@ Controls which workers start in the current process.
25
25
 
26
26
  Use this to run different worker types in separate containers from the same build artifact.
27
27
 
28
+ Setting `MASTRA_WORKERS` to any value, including `"false"`, also makes `createWorkflow` build workflows that declare `schedule` on the evented engine. Set it on every process in a split deployment. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows).
29
+
28
30
  ### `MASTRA_STEP_EXECUTION_URL`
29
31
 
30
32
  The base URL of the API server, used by the orchestration worker to execute workflow steps remotely. Required when the orchestration worker runs in a separate process from the API.
@@ -61,7 +63,7 @@ Processes workflow events from the PubSub `workflows` topic. Requires a pull-cap
61
63
 
62
64
  ### SchedulerWorker
63
65
 
64
- Polls storage for due cron schedules and publishes `workflow.start` events.
66
+ Polls storage for due cron schedules and publishes a `workflow.start` event to the `workflows` topic for each fire. The orchestration worker runs default-engine workflows in-process and evented workflows step by step.
65
67
 
66
68
  - **Name**: `scheduler`
67
69
  - **Single instance only**: Run exactly one instance to avoid duplicate fires
@@ -155,11 +155,12 @@ Pass a [`Classifier`](https://mastra.ai/reference/classifier/classifier) with co
155
155
 
156
156
  ```typescript
157
157
  import { Classifier } from '@mastra/core/classifier'
158
+ import { typeSafeAi } from '@ai-sdk/typesafe-ai'
158
159
  import { createStep } from '@mastra/core/workflows'
159
160
 
160
161
  const router = new Classifier({
161
162
  id: 'ticket-router',
162
- model,
163
+ model: typeSafeAi.evaluationModel('jev-latest'),
163
164
  questions: {
164
165
  route: {
165
166
  type: 'choice',
@@ -103,7 +103,7 @@ export const testWorkflow = createWorkflow({
103
103
 
104
104
  **requestContextSchema** (`StandardJSONSchemaV1`): Standard JSON Schema for validating request context values. When provided, the context is validated at the start of run.start(), throwing an error if validation fails.
105
105
 
106
- **schedule** (`WorkflowScheduleConfig | WorkflowScheduleConfig[]`): Optional cron schedule for the workflow. Accepts a single config or an array of configs to fire on multiple cadences. Setting this auto-promotes the workflow to the evented execution engine. See the scheduled workflows guide for usage.
106
+ **schedule** (`WorkflowScheduleConfig | WorkflowScheduleConfig[]`): Optional cron schedule for the workflow. Accepts a single config or an array of configs to fire on multiple cadences. Declaring a schedule keeps the execution engine unchanged unless the MASTRA\_WORKERS environment variable is set, in which case the workflow runs on the evented engine. See the scheduled workflows guide for usage.
107
107
 
108
108
  **schedule.id** (`string`): Stable identifier for the schedule. Required when passing an array of schedules. Defaults to the workflow id when passing a single schedule object.
109
109
 
@@ -48,6 +48,8 @@ const response = await agent.generate('Run npm install')
48
48
 
49
49
  **env** (`NodeJS.ProcessEnv`): Environment variables to set. PATH is included by default unless overridden.
50
50
 
51
+ **outputEncoding** (`string`): Encoding used to decode command stdout and stderr. Accepts any WHATWG encoding label, such as 'gbk' for native Windows commands on a Chinese (code page 936) system. (Default: `'utf-8'`)
52
+
51
53
  **timeout** (`number`): Default timeout for operations in milliseconds (Default: `30000`)
52
54
 
53
55
  **isolation** (`'none' | 'seatbelt' | 'bwrap'`): Native OS sandboxing backend. 'seatbelt' for macOS, 'bwrap' for Linux. (Default: `'none'`)
@@ -227,7 +227,7 @@ await sandbox.snapshot()
227
227
 
228
228
  Each `id` maps to one independent filesystem. Reusing the same `id` across unrelated sandboxes causes the platform to boot them from each other's checkpoint.
229
229
 
230
- Set `seedCheckpointName` to provide a boot-only fallback when the checkpoint for `id` doesn't exist yet. The platform restores the checkpoint for `id` first when both exist. Later snapshots continue writing to the checkpoint for `id`, so the seed remains unchanged.
230
+ Set `seedCheckpointName` to provide a boot-only fallback when the checkpoint for `id` doesn't exist yet. The platform restores the checkpoint for `id` first when both exist. Later snapshots continue writing to the checkpoint for `id`. The seed remains unchanged.
231
231
 
232
232
  ```typescript
233
233
  const sandbox = new PlatformSandbox({
@@ -67,7 +67,7 @@ new E2BSandbox({
67
67
 
68
68
  Semantics:
69
69
 
70
- - A thrown error is fatal: `start()` rejects with the hook's error and the sandbox is marked `error`, so a caller never observes a running sandbox whose setup hook failed. Nothing is latched, and the next `start()` (including the one triggered by the next lazy command) retries the hook. `onStop` and `onDestroy` remain non-fatal observers, because teardown proceeds best-effort.
70
+ - A thrown error is fatal: `start()` rejects with the hook's error and the sandbox is marked `error`. A caller never observes a running sandbox whose setup hook failed. Nothing is latched, and the next `start()` (including the one triggered by the next lazy command) retries the hook. `onStop` and `onDestroy` remain non-fatal observers, because teardown proceeds best-effort.
71
71
  - `outcome` distinguishes the branches: `'created'` means this start provisioned a fresh VM (run setup), `'connected'` means it reconnected or resumed (setup normally already ran, so probe when the hook must self-heal a crash between create and setup-complete). `undefined` means the provider doesn't report.
72
72
  - Keep setup work idempotent. A hook re-runs whenever a probe decides it should, and a checkpoint-recovered fresh VM reports `outcome: 'created'`.
73
73
  - The sandbox status flips to `running` before the hook executes (the hook runs commands through the sandbox's own command path), so commands issued concurrently through `ensureRunning()` can interleave with it. Callers awaiting the original `start()` always observe a sandbox whose hook finished.
@@ -253,7 +253,7 @@ await workspace.stop()
253
253
 
254
254
  `stop()` shuts down language servers and the browser before stopping the sandbox provider. Remote providers suspend or pause the sandbox for later resumption, while `LocalSandbox` kills background processes and unmounts filesystems. Stopping isn't a teardown. The filesystem and search index remain available along with skills, and the next sandbox operation starts the sandbox again.
255
255
 
256
- `mastra.shutdown()` calls `stop()` for registered workspaces, so a process restart suspends remote sandboxes instead of deleting them. To fully tear a workspace down, call `destroy()` or `mastra.removeWorkspace(id, { destroy: true })` explicitly.
256
+ `mastra.shutdown()` calls `stop()` for registered workspaces. A process restart suspends remote sandboxes instead of deleting them. To fully tear a workspace down, call `destroy()` or `mastra.removeWorkspace(id, { destroy: true })` explicitly.
257
257
 
258
258
  #### `destroy()`
259
259
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.3.2-alpha.8",
3
+ "version": "1.3.3-alpha.1",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,8 +26,8 @@
26
26
  "@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
27
27
  "local-pkg": "^1.1.2",
28
28
  "zod": "^4.6.4",
29
- "@mastra/mcp": "^2.1.0",
30
- "@mastra/core": "1.72.0-alpha.4"
29
+ "@mastra/mcp": "^2.1.2-alpha.0",
30
+ "@mastra/core": "1.73.0-alpha.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@hono/node-server": "^2.0.0",
@@ -43,9 +43,9 @@
43
43
  "tsx": "^4.23.1",
44
44
  "typescript": "^7.0.2",
45
45
  "vitest": "4.1.11",
46
- "@internal/lint": "0.0.137",
47
- "@mastra/core": "1.72.0-alpha.4",
48
- "@internal/types-builder": "0.0.112"
46
+ "@internal/types-builder": "0.0.113",
47
+ "@internal/lint": "0.0.138",
48
+ "@mastra/core": "1.73.0-alpha.0"
49
49
  },
50
50
  "homepage": "https://mastra.ai",
51
51
  "repository": {