@mastra/mcp-docs-server 1.3.9-alpha.1 → 1.3.9-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/guardrails.md +3 -0
- package/.docs/docs/agents/human-in-the-loop.md +2 -1
- package/.docs/docs/agents/processors.md +3 -0
- package/.docs/docs/harness/agent-controller.md +1 -1
- package/.docs/docs/harness/background-tasks.md +11 -0
- package/.docs/docs/harness/durable-agents.md +24 -8
- package/.docs/docs/harness/signals.md +3 -1
- package/.docs/docs/mastra-platform/connect/channels.md +14 -2
- package/.docs/docs/mastra-platform/connect/overview.md +1 -1
- package/.docs/docs/mastra-platform/connect/providers.md +1 -0
- package/.docs/docs/mastra-platform/connect/tools.md +25 -3
- package/.docs/docs/mastra-platform/observability.md +1 -1
- package/.docs/docs/memory/observational-memory.md +4 -2
- package/.docs/docs/memory/semantic-recall.md +2 -0
- package/.docs/docs/studio/overview.md +8 -0
- package/.docs/docs/workflows/control-flow.md +3 -1
- package/.docs/docs/workflows/overview.md +2 -0
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/integrations/databases/clickhouse.md +1 -1
- package/.docs/integrations/voice/google.md +6 -0
- package/.docs/models/embeddings.md +2 -1
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/gateways/merge-gateway.md +3 -1
- package/.docs/models/gateways/netlify.md +8 -4
- package/.docs/models/gateways/openrouter.md +8 -4
- package/.docs/models/gateways/vercel.md +9 -4
- package/.docs/models/index.md +3 -1
- package/.docs/models/providers/302ai.md +2 -1
- package/.docs/models/providers/aimlapi.md +3 -3
- package/.docs/models/providers/alibaba-token-plan-cn.md +31 -30
- package/.docs/models/providers/baseten.md +27 -25
- package/.docs/models/providers/cloudflare-workers-ai.md +2 -1
- package/.docs/models/providers/commandcode.md +147 -0
- package/.docs/models/providers/coralbricks.md +5 -8
- package/.docs/models/providers/cortecs.md +5 -6
- package/.docs/models/providers/databricks.md +2 -1
- package/.docs/models/providers/deepinfra.md +2 -1
- package/.docs/models/providers/edenai.md +11 -3
- package/.docs/models/providers/empiriolabs.md +3 -1
- package/.docs/models/providers/engy.md +12 -11
- package/.docs/models/providers/fireworks-ai.md +2 -1
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/hyper.md +26 -25
- package/.docs/models/providers/kenari.md +1 -1
- package/.docs/models/providers/kilo.md +29 -24
- package/.docs/models/providers/llmgateway-providers.md +9 -12
- package/.docs/models/providers/llmgateway.md +3 -4
- package/.docs/models/providers/melious.md +16 -15
- package/.docs/models/providers/minimax-cn-coding-plan.md +2 -1
- package/.docs/models/providers/minimax-cn.md +3 -2
- package/.docs/models/providers/minimax-coding-plan.md +2 -1
- package/.docs/models/providers/minimax.md +3 -2
- package/.docs/models/providers/nano-gpt.md +61 -55
- package/.docs/models/providers/nearai.md +1 -1
- package/.docs/models/providers/nebius.md +2 -1
- package/.docs/models/providers/novita-ai.md +2 -1
- package/.docs/models/providers/nvidia.md +2 -1
- package/.docs/models/providers/ofox.md +26 -25
- package/.docs/models/providers/ollama-cloud.md +31 -29
- package/.docs/models/providers/openai.md +1 -1
- package/.docs/models/providers/opencode-go.md +7 -7
- package/.docs/models/providers/opencode.md +91 -91
- package/.docs/models/providers/pioneer.md +120 -119
- package/.docs/models/providers/prime.md +4 -1
- package/.docs/models/providers/reflection.md +77 -0
- package/.docs/models/providers/requesty.md +6 -2
- package/.docs/models/providers/scaleway.md +2 -1
- package/.docs/models/providers/standardcompute.md +47 -8
- package/.docs/models/providers/togetherai.md +4 -1
- package/.docs/models/providers/upstage.md +8 -7
- package/.docs/models/providers/wandb.md +4 -2
- package/.docs/models/providers/xai.md +0 -1
- package/.docs/models/providers/zenmux.md +2 -1
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/agent-controller/session.md +3 -2
- package/.docs/reference/agents/channels.md +5 -1
- package/.docs/reference/agents/durable-agent.md +16 -7
- package/.docs/reference/agents/inngest-agent.md +4 -4
- package/.docs/reference/classifier/classifier.md +31 -7
- package/.docs/reference/cli/mastra.md +43 -6
- package/.docs/reference/client-js/agent-controller.md +2 -0
- package/.docs/reference/client-js/agents.md +20 -0
- package/.docs/reference/client-js/observability.md +165 -6
- package/.docs/reference/configuration.md +30 -0
- package/.docs/reference/connect/channels.md +2 -2
- package/.docs/reference/connect/providers.md +38 -3
- package/.docs/reference/connect/tools.md +21 -2
- package/.docs/reference/core/mastra-class.md +7 -1
- package/.docs/reference/datasets/list.md +9 -1
- package/.docs/reference/evals/create-classifier-scorer.md +1 -0
- package/.docs/reference/index.md +1 -1
- package/.docs/reference/memory/observational-memory.md +2 -2
- package/.docs/reference/memory/settled.md +13 -5
- package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
- package/.docs/reference/observability/metrics/queries.md +1 -0
- package/.docs/reference/observability/tracing/{trace-query.md → advanced-queries.md} +477 -158
- package/.docs/reference/observability/tracing/interfaces.md +6 -0
- package/.docs/reference/processors/classifier-processor.md +8 -6
- package/.docs/reference/processors/model-selection-processor.md +2 -2
- package/.docs/reference/processors/moderation-processor.md +5 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +4 -0
- package/.docs/reference/rag/embeddings.md +18 -0
- package/.docs/reference/signals/create-notification-inbox-tool.md +11 -9
- package/.docs/reference/streaming/agents/stream.md +19 -1
- package/.docs/reference/tools/create-tool.md +2 -2
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/workflows/dynamic-workflow-definition.md +1 -1
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +15 -16
- package/.docs/reference/workflows/step.md +1 -0
- package/.docs/reference/workflows/workflow-methods/classifier.md +1 -0
- package/.docs/reference/workspace/factory-sandbox.md +2 -0
- package/.docs/reference/workspace/filesystem.md +4 -0
- package/.docs/reference/workspace/workspace-class.md +10 -10
- package/package.json +7 -8
|
@@ -542,6 +542,9 @@ interface AgentRunAttributes {
|
|
|
542
542
|
|
|
543
543
|
/** Maximum steps allowed */
|
|
544
544
|
maxSteps?: number
|
|
545
|
+
|
|
546
|
+
/** When the run's model streamed its first chunk, copied from the agent's own first generation */
|
|
547
|
+
completionStartTime?: Date
|
|
545
548
|
}
|
|
546
549
|
```
|
|
547
550
|
|
|
@@ -639,6 +642,9 @@ interface ModelStepAttributes {
|
|
|
639
642
|
|
|
640
643
|
/** Result warnings */
|
|
641
644
|
warnings?: Record<string, any>
|
|
645
|
+
|
|
646
|
+
/** When the step's first inference streamed its first chunk */
|
|
647
|
+
completionStartTime?: Date
|
|
642
648
|
}
|
|
643
649
|
```
|
|
644
650
|
|
|
@@ -29,12 +29,14 @@ const safety = new Classifier({
|
|
|
29
29
|
const processor = new ClassifierProcessor({
|
|
30
30
|
classifier: safety,
|
|
31
31
|
onResult: (answers, { abort }) => {
|
|
32
|
-
if (answers.unsafe.probability > 0.8) abort('Message rejected by safety policy')
|
|
32
|
+
if ((answers.unsafe.probability ?? 1) > 0.8) abort('Message rejected by safety policy')
|
|
33
33
|
},
|
|
34
34
|
lastMessageOnly: true,
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
A decision model can refuse a question. A refused answer is `{ type: 'refusal' }` and has no `choice`, `score`, or `probability`. The example treats a refusal as unsafe.
|
|
39
|
+
|
|
38
40
|
Several conditions can share one `onResult`, or use separate processors when they need different classifiers. Give each processor a unique `id`. Processor instances with the same `id` share per-run state, including accumulated stream chunks.
|
|
39
41
|
|
|
40
42
|
```typescript
|
|
@@ -43,14 +45,14 @@ inputProcessors: [
|
|
|
43
45
|
id: 'safety-check',
|
|
44
46
|
classifier: safety,
|
|
45
47
|
onResult: (a, { abort }) => {
|
|
46
|
-
if (a.unsafe.probability > 0.8) abort('Rejected by safety policy')
|
|
48
|
+
if ((a.unsafe.probability ?? 1) > 0.8) abort('Rejected by safety policy')
|
|
47
49
|
},
|
|
48
50
|
}),
|
|
49
51
|
new ClassifierProcessor({
|
|
50
52
|
id: 'topic-check',
|
|
51
53
|
classifier: topic,
|
|
52
54
|
onResult: (a, { abort }) => {
|
|
53
|
-
if (a.topic.choice === 'other') abort('Support questions only')
|
|
55
|
+
if (a.topic.type === 'refusal' || a.topic.choice === 'other') abort('Support questions only')
|
|
54
56
|
},
|
|
55
57
|
}),
|
|
56
58
|
]
|
|
@@ -121,7 +123,7 @@ export const agent = new Agent({
|
|
|
121
123
|
classifier: topic,
|
|
122
124
|
lastMessageOnly: true,
|
|
123
125
|
onResult: (answers, { abort }) => {
|
|
124
|
-
if (answers.topic.choice === 'other') {
|
|
126
|
+
if (answers.topic.type === 'refusal' || answers.topic.choice === 'other') {
|
|
125
127
|
abort('This assistant only handles billing and account questions')
|
|
126
128
|
}
|
|
127
129
|
},
|
|
@@ -159,7 +161,7 @@ export const agent = new Agent({
|
|
|
159
161
|
new ClassifierProcessor({
|
|
160
162
|
classifier: quality,
|
|
161
163
|
onResult: (answers, { filter }) => {
|
|
162
|
-
if (answers.quality.score < 1) filter()
|
|
164
|
+
if ((answers.quality.score ?? 0) < 1) filter()
|
|
163
165
|
},
|
|
164
166
|
}),
|
|
165
167
|
],
|
|
@@ -196,7 +198,7 @@ type SafetyQuestions = {
|
|
|
196
198
|
const processor = new ClassifierProcessor<SafetyQuestions>({
|
|
197
199
|
classifier: 'safety',
|
|
198
200
|
onResult: (answers, { abort }) => {
|
|
199
|
-
if (answers.unsafe.probability > 0.8) abort('Message rejected by safety policy')
|
|
201
|
+
if ((answers.unsafe.probability ?? 1) > 0.8) abort('Message rejected by safety policy')
|
|
200
202
|
},
|
|
201
203
|
})
|
|
202
204
|
```
|
|
@@ -104,7 +104,7 @@ The decision carries the model that was applied, the criterion that was chosen,
|
|
|
104
104
|
|
|
105
105
|
**probability** (`number`): Confidence in the selected choice, taken from the answer distribution. Absent when the decision model returns no distribution.
|
|
106
106
|
|
|
107
|
-
**abstained** (`'below-threshold' | 'no-model-for-choice' | 'no-text' | 'error'`): Why no model was applied. Absent on a successful routing decision and when select returns undefined.
|
|
107
|
+
**abstained** (`'below-threshold' | 'no-model-for-choice' | 'no-text' | 'error' | 'refused'`): Why no model was applied. Absent on a successful routing decision and when select returns undefined.
|
|
108
108
|
|
|
109
109
|
## Existing classifiers
|
|
110
110
|
|
|
@@ -200,7 +200,7 @@ If your decision model doesn't report choice distributions, the processor abstai
|
|
|
200
200
|
|
|
201
201
|
## Failure behavior
|
|
202
202
|
|
|
203
|
-
Routing fails open. If the classifier errors or the classifier ID isn't registered, the processor logs a warning and the agent's configured model is used. If the request has no user text to classify, the processor abstains without logging and reports `abstained: 'no-text'` to `onDecision`. This is the safe direction for a cost optimization: the worst case is that you pay for the model you already configured.
|
|
203
|
+
Routing fails open. If the classifier errors or the classifier ID isn't registered, the processor logs a warning and the agent's configured model is used. If the request has no user text to classify, the processor abstains without logging and reports `abstained: 'no-text'` to `onDecision`. With the `choices` form, if the decision model refuses the routing question, the processor abstains and reports `abstained: 'refused'`. With the `select` form, your callback receives the refusal answer and decides whether to return a model or `undefined`. This is the safe direction for a cost optimization: the worst case is that you pay for the model you already configured.
|
|
204
204
|
|
|
205
205
|
This is the opposite of the fail-closed stance appropriate for [tool approval](https://mastra.ai/docs/agents/human-in-the-loop), where uncertainty should escalate rather than pass through.
|
|
206
206
|
|
|
@@ -40,7 +40,9 @@ const processor = new ModerationProcessor({
|
|
|
40
40
|
|
|
41
41
|
**options.lastMessageOnly** (`boolean`): Whether to run moderation only on the most recent message in the batch instead of checking every message. Use this to avoid an extra LLM call for each earlier message in long conversations.
|
|
42
42
|
|
|
43
|
-
**options.chunkWindow** (`number`): Number of previous chunks to include for context when moderating stream chunks. If set to 1, includes the previous part, etc.
|
|
43
|
+
**options.chunkWindow** (`number`): Number of previous chunks to include for context when moderating stream chunks. If set to 1, includes the previous part, etc. Only applies when bufferSize is 0.
|
|
44
|
+
|
|
45
|
+
**options.bufferSize** (`number`): Opt-in buffering for streamed text. When greater than 0, streamed text is held back and moderated in one LLM call when it ends a sentence, reaches this many characters, or a non-text part arrives. This makes far fewer LLM calls and catches content split across chunks. Recommended for production streaming, for example bufferSize: 200. With 0, every text chunk gets its own LLM call.
|
|
44
46
|
|
|
45
47
|
**options.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal moderation agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } })
|
|
46
48
|
|
|
@@ -82,6 +84,8 @@ export const agent = new Agent({
|
|
|
82
84
|
|
|
83
85
|
### Output processing with batching
|
|
84
86
|
|
|
87
|
+
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `ModerationProcessor` makes one moderation call per sentence instead of one per chunk. Buffering also catches content that is split across chunks. Text then reaches the client in sentence-sized pieces.
|
|
88
|
+
|
|
85
89
|
When using `ModerationProcessor` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the moderator, reducing the number of LLM calls required for moderation.
|
|
86
90
|
|
|
87
91
|
```typescript
|
|
@@ -42,6 +42,8 @@ const processor = new SystemPromptScrubber({
|
|
|
42
42
|
|
|
43
43
|
**options.placeholderText** (`string`): Custom placeholder text for redaction when redactionMethod is 'placeholder'
|
|
44
44
|
|
|
45
|
+
**options.bufferSize** (`number`): Opt-in buffering for streamed text. When greater than 0, streamed text is held back and checked in one LLM call when it ends a sentence, reaches this many characters, or a non-text part arrives. This makes far fewer LLM calls and catches content split across chunks. Recommended for production streaming, for example bufferSize: 200. With 0, every text chunk gets its own LLM call.
|
|
46
|
+
|
|
45
47
|
## Returns
|
|
46
48
|
|
|
47
49
|
**id** (`string`): Processor identifier set to 'system-prompt-scrubber'
|
|
@@ -54,6 +56,8 @@ const processor = new SystemPromptScrubber({
|
|
|
54
56
|
|
|
55
57
|
## Extended usage example
|
|
56
58
|
|
|
59
|
+
For production streaming, set `bufferSize` (for example `bufferSize: 200`) so `SystemPromptScrubber` makes one detection call per sentence instead of one per chunk. Buffering also catches content that is split across chunks. Text then reaches the client in sentence-sized pieces.
|
|
60
|
+
|
|
57
61
|
When using `SystemPromptScrubber` as an output processor, it's recommended to combine it with `BatchPartsProcessor` to optimize performance. The `BatchPartsProcessor` batches stream chunks together before passing them to the scrubber, reducing the number of LLM calls required for detection.
|
|
58
62
|
|
|
59
63
|
```typescript
|
|
@@ -6,6 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
Mastra uses the AI SDK's `embed` and `embedMany` functions to generate vector embeddings for text inputs, enabling similarity search and RAG workflows.
|
|
8
8
|
|
|
9
|
+
## Supported embedding models
|
|
10
|
+
|
|
11
|
+
Memory and RAG vector query tools accept embedding models with specification versions `v1`, `v2`, `v3`, and `v4`. Mastra selects the matching AI SDK implementation from the model's `specificationVersion`. Existing model configurations remain unchanged.
|
|
12
|
+
|
|
13
|
+
For direct calls, use the matching export from `@mastra/core/vector`: `embedV1`, `embedV2`, `embedV3`, or `embedV4`. For example, an AI SDK v7 provider exposes a specification `v4` embedding model:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { openai } from '@ai-sdk/openai'
|
|
17
|
+
import { embedV4 } from '@mastra/core/vector'
|
|
18
|
+
|
|
19
|
+
const { embedding } = await embedV4({
|
|
20
|
+
model: openai.embedding('text-embedding-3-small'),
|
|
21
|
+
value: 'Your text to embed',
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This example requires `@ai-sdk/openai` v4. The model specification version and AI SDK package version are different: AI SDK v4 uses embedding specification `v1`, v5 uses `v2`, v6 uses `v3`, and v7 uses `v4`.
|
|
26
|
+
|
|
9
27
|
## Single embedding
|
|
10
28
|
|
|
11
29
|
The `embed` function generates a vector embedding for a single text input:
|
|
@@ -47,7 +47,7 @@ The generated tool has the id `notification-inbox` and accepts these input field
|
|
|
47
47
|
|
|
48
48
|
**id** (`string`): Notification ID. Required for markSeen, dismiss, and archive. Optional for read.
|
|
49
49
|
|
|
50
|
-
**status** (`'pending' | 'delivered' | 'seen' | 'dismissed' | 'archived' | 'discarded'`): Status filter for list, read, or search actions.
|
|
50
|
+
**status** (`'pending' | 'delivered' | 'seen' | 'dismissed' | 'archived' | 'discarded' | 'failed'`): Status filter for list, read, or search actions.
|
|
51
51
|
|
|
52
52
|
**priority** (`'low' | 'medium' | 'high' | 'urgent'`): Priority filter for list, read, or search actions.
|
|
53
53
|
|
|
@@ -59,13 +59,15 @@ The generated tool has the id `notification-inbox` and accepts these input field
|
|
|
59
59
|
|
|
60
60
|
## Actions
|
|
61
61
|
|
|
62
|
-
| Action | Description
|
|
63
|
-
| ---------- |
|
|
64
|
-
| `list` | Returns matching notifications.
|
|
65
|
-
| `read` | Delivers readable notification contents as signals and marks delivered records as seen.
|
|
66
|
-
| `markSeen` | Marks one notification as seen.
|
|
67
|
-
| `dismiss` | Marks one notification as dismissed.
|
|
68
|
-
| `archive` | Marks one notification as archived.
|
|
69
|
-
| `search` | Searches notifications by query and optional filters.
|
|
62
|
+
| Action | Description |
|
|
63
|
+
| ---------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
+
| `list` | Returns matching notifications. Without `status`, returns pending, delivered, and failed notifications and marks them seen. |
|
|
65
|
+
| `read` | Delivers readable notification contents as signals and marks delivered records as seen. |
|
|
66
|
+
| `markSeen` | Marks one notification as seen. |
|
|
67
|
+
| `dismiss` | Marks one notification as dismissed. |
|
|
68
|
+
| `archive` | Marks one notification as archived. |
|
|
69
|
+
| `search` | Searches notifications by query and optional filters. |
|
|
70
|
+
|
|
71
|
+
A notification is `failed` when Mastra ran out of delivery attempts for it. The default `list` includes failed notifications. Any `list` or `search` that returns a failed notification shows it with `status: 'failed'` and its `lastDeliveryError`, then marks it seen, so later lists don't repeat it. Filtering by `status: 'failed'` finds the notification only until it's first returned; after that it's `seen`, and `deliveryAttempts` and `lastDeliveryError` stay on the record.
|
|
70
72
|
|
|
71
73
|
When `read` finds pending or delivered notifications, the tool delivers their contents as notification signals instead of returning the full contents as normal tool output. Use this after a `<notification-summary>` signal when the agent needs the full records behind the summary.
|
|
@@ -238,7 +238,7 @@ const stream = await agent.stream('message for agent')
|
|
|
238
238
|
|
|
239
239
|
**options.untilIdle** (`boolean | { maxIdleMs?: number }`): When set, keeps the stream open across background-task continuations. The agent will automatically re-invoke the LLM when background tasks complete, streaming continuation turns through the same fullStream. Pass true for default settings (5 min idle timeout), or an object with maxIdleMs to configure. Requires memory. Replaces the standalone streamUntilIdle() method.
|
|
240
240
|
|
|
241
|
-
**options.untilIdle.maxIdleMs** (`number`): Closes the outer stream after this many ms of idleness between turns. The timer only runs while the wrapper is between turns. Default: 5 minutes.
|
|
241
|
+
**options.untilIdle.maxIdleMs** (`number`): Closes the outer stream after this many ms of idleness between turns. The timer only runs while the wrapper is between turns. Default: backgroundTasks.untilIdleMaxIdleMs from the Mastra config, or 5 minutes.
|
|
242
242
|
|
|
243
243
|
## Returns
|
|
244
244
|
|
|
@@ -248,6 +248,24 @@ const stream = await agent.stream('message for agent')
|
|
|
248
248
|
|
|
249
249
|
**spanId** (`string`): The root span ID associated with this execution when Tracing is enabled. Use this for span-level lookup and correlation.
|
|
250
250
|
|
|
251
|
+
## `stopWhen` errors
|
|
252
|
+
|
|
253
|
+
If a `stopWhen` predicate throws, `fullStream` rejects with that error. The stream does not emit a `step-finish`, `finish`, or `error` chunk for the failure. Catch the rejection around stream consumption:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
async function consumeStream() {
|
|
257
|
+
try {
|
|
258
|
+
for await (const chunk of stream.fullStream) {
|
|
259
|
+
console.log(chunk)
|
|
260
|
+
}
|
|
261
|
+
} catch (error) {
|
|
262
|
+
console.error('stopWhen failed', error)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Durable transports reconstruct cross-process errors from their serialized name and message. The original stack, cause, and subclass identity are not available to the stream consumer.
|
|
268
|
+
|
|
251
269
|
## Signal visibility
|
|
252
270
|
|
|
253
271
|
Signals, including reactive reminders, appear in `fullStream` by default. Set `hideSignals` to omit selected signal chunks from your stream:
|
|
@@ -59,9 +59,9 @@ The first `execute` parameter is the validated value from `inputSchema`. Destruc
|
|
|
59
59
|
|
|
60
60
|
**resumeSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected structure of resumeData when the tool is resumed. Used by the agent to extract data from user messages when autoResumeSuspendedTools is enabled.
|
|
61
61
|
|
|
62
|
-
**requireApproval** (`boolean`): When true, the tool requires explicit approval before execution. The agent will emit a tool-call-approval chunk and pause until approved or declined.
|
|
62
|
+
**requireApproval** (`boolean`): When true, the tool requires explicit approval before execution. The agent will emit a tool-call-approval chunk and pause until approved or declined. Input is validated against inputSchema first: if it is invalid, the validation error is returned to the model and no approval is requested.
|
|
63
63
|
|
|
64
|
-
**beforeApproval** (`(input, context) => void | { proceed: false; output: unknown } | Promise<...>`): Runs before the approval gate for calls that require approval, receiving the input validated against inputSchema (defaults applied) and a context with toolCallId, toolName, requestContext, and workspace. Return { proceed: false, output } to reject the call: the agent does not pause for approval, execute is not called, and output is returned to the model as the tool result. Return nothing to continue to the approval gate. Not run when the input fails inputSchema validation (
|
|
64
|
+
**beforeApproval** (`(input, context) => void | { proceed: false; output: unknown } | Promise<...>`): Runs before the approval gate for calls that require approval, receiving the input validated against inputSchema (defaults applied) and a context with toolCallId, toolName, requestContext, and workspace. Return { proceed: false, output } to reject the call: the agent does not pause for approval, execute is not called, and output is returned to the model as the tool result. Return nothing to continue to the approval gate. Not run when the input fails inputSchema validation (the validation error is returned to the model without asking for approval) or when resuming after an approval decision. If the hook throws, the error is logged and the call proceeds to the approval gate, so keep validating inside execute as well.
|
|
65
65
|
|
|
66
66
|
**mcp** (`MCPToolProperties`): MCP-specific properties for tools exposed via Model Context Protocol. Includes annotations (tool behavior hints like title, readOnlyHint, destructiveHint, idempotentHint, openWorldHint) and \_meta (arbitrary metadata passed through to MCP clients).
|
|
67
67
|
|
|
@@ -38,7 +38,7 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
38
38
|
- If `command` is provided, it uses the Stdio transport.
|
|
39
39
|
- If `url` is provided, it uses the Streamable HTTP transport.
|
|
40
40
|
|
|
41
|
-
The client speaks the MCP `2026-07-28` revision. On connect it asks the server which revisions it offers (`server/discover`) and falls back to the pre-2026 `initialize` handshake for servers that haven't upgraded, so tools, resources and prompts keep working against either. Features the older revisions lack (`resources.subscribe()`, `inputRequests`) fail with an error naming the negotiated revision. Set `protocolVersion` to skip the probe.
|
|
41
|
+
The client speaks the MCP `2026-07-28` revision. On connect it asks the server which revisions it offers (`server/discover`) and falls back to the pre-2026 `initialize` handshake for servers that haven't upgraded, so tools, resources and prompts keep working against either. Features the older revisions lack (`resources.subscribe()`, `inputRequests`) fail with an error naming the negotiated revision. `onListChanged()` handlers work against either revision, since older servers send list-changed notifications without a `subscriptions/listen` stream. Set `protocolVersion` to skip the probe.
|
|
42
42
|
|
|
43
43
|
**command** (`string`): For Stdio servers: The command to execute.
|
|
44
44
|
|
|
@@ -84,7 +84,7 @@ The client speaks the MCP `2026-07-28` revision. On connect it asks the server w
|
|
|
84
84
|
|
|
85
85
|
**requireToolApproval** (`boolean | (params: RequireToolApprovalContext) => boolean | Promise<boolean>`): Require human approval before executing tools from this server. When set to true, all tools require approval. When set to a function, the function is called with the tool name, arguments, request context, and any tool annotations advertised by the server to dynamically decide whether approval is needed.
|
|
86
86
|
|
|
87
|
-
**onToolError** (`'throw' | 'return'`): How to handle tool execution failures the server reports in-band with isError: true. 'throw' raises a MastraError carrying the server's error text, so the failure reaches tool spans, stream chunks, scorers, and the model. 'return' resolves with the
|
|
87
|
+
**onToolError** (`'throw' | 'return'`): How to handle tool execution failures the server reports in-band with isError: true. 'throw' raises a MastraError carrying the server's error text, so the failure reaches tool spans, stream chunks, scorers, and the model. Any structuredContent is kept on error.details.structuredContent as a JSON string. 'return' resolves with the full CallToolResult (isError, content, and structuredContent) instead of throwing. (Default: `'throw'`)
|
|
88
88
|
|
|
89
89
|
**jsonSchemaValidator** (`JsonSchemaValidator`): Validator used for MCP tool schemas and structured results. The default supports JSON Schema 2020-12. Provide a compatible validator such as CfWorkerJsonSchemaValidator in runtimes that disallow dynamic code generation.
|
|
90
90
|
|
|
@@ -164,7 +164,7 @@ The classifier evaluates the complete entry input. Add a preceding `mapping` ent
|
|
|
164
164
|
|
|
165
165
|
Classifier output has two stable paths:
|
|
166
166
|
|
|
167
|
-
- `answers.<question>` contains the typed answer. Route on its `choice`, `score`, or `probability` field according to the question type. Choice and score answers may include distributions.
|
|
167
|
+
- `answers.<question>` contains the typed answer. Route on its `choice`, `score`, or `probability` field according to the question type. Choice and score answers may include distributions. A refused question is `{ "type": "refusal" }` with no `choice`, `score`, or `probability`, so it matches no condition on those fields. Compare `answers.<question>.type` with `"refusal"` to route refusals explicitly.
|
|
168
168
|
- `usage` contains normalized token usage.
|
|
169
169
|
|
|
170
170
|
Use an existing `conditional` entry to route on classifier output. For example, a following condition can compare `{ "path": "stepResults.classify-ticket.answers.route.choice" }` with `{ "literal": "billing" }`.
|
|
@@ -118,7 +118,7 @@ try {
|
|
|
118
118
|
|
|
119
119
|
Over HTTP, a losing resume returns `409 Conflict`.
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
[`timeTravel()`](https://mastra.ai/reference/workflows/run-methods/timeTravel) claims the run the same way and throws `WORKFLOW_TIME_TRAVEL_ALREADY_CLAIMED` when it loses.
|
|
122
122
|
|
|
123
123
|
> **Note:** The claim is enforced atomically by storage adapters that report `supportsConcurrentUpdates()`. Adapters without atomic read-modify-write support (such as ClickHouse, Cloudflare D1, Cloudflare KV, Cloudflare Durable Objects, LanceDB, and Redis) can't enforce it, and the claim is also skipped when `shouldPersistSnapshot` excludes the `running` status.
|
|
124
124
|
|
|
@@ -152,30 +152,29 @@ const result = await run.timeTravel({
|
|
|
152
152
|
|
|
153
153
|
## Concurrent time travel calls
|
|
154
154
|
|
|
155
|
-
`timeTravel()`
|
|
155
|
+
Only one `timeTravel()` call can run for a workflow run at a time. Before it runs anything, `timeTravel()` atomically claims the run by moving its stored status from the status it loaded (for example `suspended` or `success`) to `running`. If another caller already claimed it, this call throws `WORKFLOW_TIME_TRAVEL_ALREADY_CLAIMED` and executes no steps. A call that loads the run while it's already `running` throws `WORKFLOW_TIME_TRAVEL_RUN_RUNNING`.
|
|
156
156
|
|
|
157
|
-
This matters whenever time travel can be triggered more than once for the same run, such as a "retry from step" button pressed twice or a retried API request.
|
|
157
|
+
This matters whenever time travel can be triggered more than once for the same run, such as a "retry from step" button pressed twice or a retried API request.
|
|
158
158
|
|
|
159
159
|
```typescript
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return await run.timeTravel({ step })
|
|
170
|
-
} finally {
|
|
171
|
-
inFlight.delete(runId)
|
|
160
|
+
try {
|
|
161
|
+
await run.timeTravel({ step: 'step2' })
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (
|
|
164
|
+
error.id === 'WORKFLOW_TIME_TRAVEL_ALREADY_CLAIMED' ||
|
|
165
|
+
error.id === 'WORKFLOW_TIME_TRAVEL_RUN_RUNNING'
|
|
166
|
+
) {
|
|
167
|
+
// Another caller is already re-running this workflow. Re-read the run
|
|
168
|
+
// state instead of time travelling again.
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
```
|
|
175
172
|
|
|
176
|
-
|
|
173
|
+
Over HTTP, `POST /api/workflows/:workflowId/time-travel-async` returns `409 Conflict` for a losing call. The `time-travel` and `time-travel-stream` endpoints respond before the time travel finishes, so a losing call doesn't change their status code.
|
|
174
|
+
|
|
175
|
+
Calling `timeTravel()` again after the previous call finished is still allowed and re-runs the target step.
|
|
177
176
|
|
|
178
|
-
|
|
177
|
+
> **Note:** The claim is enforced atomically by storage adapters that report `supportsConcurrentUpdates()`. Adapters without atomic read-modify-write support (such as ClickHouse, Cloudflare D1, Cloudflare KV, Cloudflare Durable Objects, LanceDB, and Redis) can't enforce it, and the claim is also skipped when `shouldPersistSnapshot` excludes the `running` status. The Inngest workflow runner doesn't claim the run yet.
|
|
179
178
|
|
|
180
179
|
## Notes
|
|
181
180
|
|
|
@@ -185,6 +185,7 @@ The typed step output is JSON-safe:
|
|
|
185
185
|
- `answers.route.choice` is the selected choice literal.
|
|
186
186
|
- `answers.urgent.probability` is the probability that the boolean answer is `true`, not a thresholded boolean.
|
|
187
187
|
- Choice and score answers may include distributions.
|
|
188
|
+
- A question the decision model refused is `{ type: 'refusal' }` and has no `choice`, `score`, or `probability`.
|
|
188
189
|
- `usage` contains normalized token usage.
|
|
189
190
|
|
|
190
191
|
`maxRetries` controls classifier model-call retries. `retries` controls workflow step retries. Classifier warnings, response metadata, and raw provider data aren't included in workflow output.
|
|
@@ -58,6 +58,7 @@ Mappings use the same validated path grammar as other workflow steps and persist
|
|
|
58
58
|
- Choice answers expose `answers.<question>.choice` and may include `probabilities`.
|
|
59
59
|
- Score answers expose `answers.<question>.score` and may include `probabilities`.
|
|
60
60
|
- Boolean answers expose the raw `P(true)` value as `answers.<question>.probability`. Apply an explicit threshold when routing.
|
|
61
|
+
- Refused questions are `{ type: 'refusal' }` and have no `choice`, `score`, or `probability`.
|
|
61
62
|
- `usage` contains normalized token usage.
|
|
62
63
|
|
|
63
64
|
## Retries and errors
|
|
@@ -127,6 +127,8 @@ class MyFactorySandbox extends FactorySandbox<Settings> {
|
|
|
127
127
|
}
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
When a user recreates a stuck session's sandbox, Factory may call `create` with only `sessionId` and the persisted `sandboxId` (no repository access, empty settings) and then call the returned sandbox's `destroy()` without starting it. This happens when the server restarted or the session was opened on another replica. For recreate to work, `destroy()` must find and remove the session's VM from `sandboxId` or the session id alone. Factory doesn't offer recreate for `LocalFactorySandbox`, because its `destroy()` keeps the session directory.
|
|
131
|
+
|
|
130
132
|
## FactorySandboxContext
|
|
131
133
|
|
|
132
134
|
Everything Factory knows about the session, passed to `create`, `template` and the build methods.
|
|
@@ -283,6 +283,10 @@ const entries = await filesystem.walk?.('.', { maxDepth: 3 })
|
|
|
283
283
|
|
|
284
284
|
**options.includeHidden** (`boolean`): Include entries whose names start with ".". Defaults to false.
|
|
285
285
|
|
|
286
|
+
**options.includeGitignoreFiles** (`boolean`): Return .gitignore files even when hidden entries are excluded. list\_files sets this so it can apply each directory's .gitignore. Providers may ignore it.
|
|
287
|
+
|
|
288
|
+
**options.skipDirectoryNames** (`string[]`): Directory names not to descend into or return, such as node\_modules. list\_files filters the results as well, so providers may ignore it.
|
|
289
|
+
|
|
286
290
|
**Returns:** `Promise<WalkEntry[]>`
|
|
287
291
|
|
|
288
292
|
```typescript
|
|
@@ -471,16 +471,16 @@ A workspace provides tools to agents based on what's configured.
|
|
|
471
471
|
|
|
472
472
|
Added when a filesystem is configured:
|
|
473
473
|
|
|
474
|
-
| Tool | Description
|
|
475
|
-
| ----------------------------- |
|
|
476
|
-
| `mastra_workspace_read_file` | Read file contents. Text files return as text (with optional line range). Images and PDFs return as native media parts the model can view directly. Other binaries return metadata only unless an explicit `encoding` is passed.
|
|
477
|
-
| `mastra_workspace_write_file` | Create or overwrite a file with new content. Creates parent directories automatically.
|
|
478
|
-
| `mastra_workspace_edit_file` | Edit an existing file by finding and replacing text. Useful for targeted changes without rewriting the entire file.
|
|
479
|
-
| `mastra_workspace_list_files` | List directory contents as a tree structure. Supports recursive listing with depth limits, glob patterns, and `.gitignore` filtering (enabled by default).
|
|
480
|
-
| `mastra_workspace_delete` | Delete a file or directory. Supports recursive deletion for directories.
|
|
481
|
-
| `mastra_workspace_file_stat` | Get metadata about a file or directory including size, type, and modification time.
|
|
482
|
-
| `mastra_workspace_mkdir` | Create a directory. Creates parent directories automatically if they don't exist.
|
|
483
|
-
| `mastra_workspace_grep` | Search file contents using regex patterns. Supports glob filtering, context lines, and case-insensitive search.
|
|
474
|
+
| Tool | Description |
|
|
475
|
+
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
476
|
+
| `mastra_workspace_read_file` | Read file contents. Text files return as text (with optional line range). Images and PDFs return as native media parts the model can view directly. Other binaries return metadata only unless an explicit `encoding` is passed. |
|
|
477
|
+
| `mastra_workspace_write_file` | Create or overwrite a file with new content. Creates parent directories automatically. |
|
|
478
|
+
| `mastra_workspace_edit_file` | Edit an existing file by finding and replacing text. Useful for targeted changes without rewriting the entire file. |
|
|
479
|
+
| `mastra_workspace_list_files` | List directory contents as a tree structure. Supports recursive listing with depth limits, glob patterns, and `.gitignore` filtering (enabled by default: every `.gitignore` applies relative to its own directory, and `node_modules` is skipped unless the listed path is inside it). |
|
|
480
|
+
| `mastra_workspace_delete` | Delete a file or directory. Supports recursive deletion for directories. |
|
|
481
|
+
| `mastra_workspace_file_stat` | Get metadata about a file or directory including size, type, and modification time. |
|
|
482
|
+
| `mastra_workspace_mkdir` | Create a directory. Creates parent directories automatically if they don't exist. |
|
|
483
|
+
| `mastra_workspace_grep` | Search file contents using regex patterns. Supports glob filtering, context lines, and case-insensitive search. Applies `.gitignore` files the same way as `list_files` and skips `node_modules` unless the search path is inside it. |
|
|
484
484
|
|
|
485
485
|
With a static filesystem, write tools (`write_file`, `edit_file`, `delete`, `mkdir`) are excluded when the filesystem is in read-only mode. With a [runtime-defined filesystem](https://mastra.ai/docs/sandbox/filesystem), write tools are always included and read-only is enforced at runtime.
|
|
486
486
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.9-alpha.
|
|
3
|
+
"version": "1.3.9-alpha.10",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
|
|
27
27
|
"local-pkg": "^1.1.2",
|
|
28
|
-
"zod": "^4.6.
|
|
29
|
-
"@mastra/
|
|
30
|
-
"@mastra/
|
|
28
|
+
"zod": "^4.6.7",
|
|
29
|
+
"@mastra/mcp": "^2.5.0-alpha.1",
|
|
30
|
+
"@mastra/core": "1.79.0-alpha.7"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@hono/node-server": "^2.0.0",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"@vitest/ui": "4.1.11",
|
|
38
38
|
"@wong2/mcp-cli": "^2.0.0",
|
|
39
39
|
"cross-env": "^10.1.0",
|
|
40
|
-
"eslint": "^10.7.0",
|
|
41
40
|
"hono": "^4.13.7",
|
|
42
41
|
"tsdown": "0.22.9",
|
|
43
42
|
"tsx": "^4.23.1",
|
|
@@ -45,7 +44,7 @@
|
|
|
45
44
|
"vitest": "4.1.11",
|
|
46
45
|
"@internal/lint": "0.0.144",
|
|
47
46
|
"@internal/types-builder": "0.0.119",
|
|
48
|
-
"@mastra/core": "1.
|
|
47
|
+
"@mastra/core": "1.79.0-alpha.7"
|
|
49
48
|
},
|
|
50
49
|
"homepage": "https://mastra.ai",
|
|
51
50
|
"repository": {
|
|
@@ -64,8 +63,8 @@
|
|
|
64
63
|
"build:cli": "tsdown --silent --config tsdown.config.ts",
|
|
65
64
|
"pretest": "pnpm turbo build --filter @mastra/mcp-docs-server",
|
|
66
65
|
"test": "vitest run",
|
|
67
|
-
"lint": "oxlint
|
|
68
|
-
"lint:fix": "oxlint --
|
|
66
|
+
"lint": "oxlint --type-aware .",
|
|
67
|
+
"lint:fix": "oxlint --type-aware --fix ."
|
|
69
68
|
},
|
|
70
69
|
"bin": {
|
|
71
70
|
"mcp-docs-server": "dist/stdio.js"
|