@mastra/mcp-docs-server 1.3.13-alpha.10 → 1.3.13-alpha.11
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/observability/feedback.md +5 -7
- package/.docs/integrations/sandboxes/docker.md +39 -0
- package/.docs/reference/client-js/observability.md +13 -5
- package/.docs/reference/observability/feedback.md +43 -14
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +19 -16
- package/.docs/reference/processors/processor-interface.md +23 -0
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@ Unlike metrics and scores, feedback is usually supplied by a person or review wo
|
|
|
16
16
|
|
|
17
17
|
## Add feedback
|
|
18
18
|
|
|
19
|
-
Use `mastra.observability.addFeedback()`
|
|
19
|
+
Use `mastra.observability.addFeedback()` to annotate a trace or span from app code. The helper is optional on the observability entrypoint, so check that the active observability implementation supports it. See the [client SDK observability reference](https://mastra.ai/reference/client-js/observability) for all client methods.
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
22
|
if (!mastra.observability.addFeedback) {
|
|
@@ -35,9 +35,9 @@ await mastra.observability.addFeedback({
|
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Feedback goes to each configured exporter that supports it. Each exporter handles its own destination independently. A trace missing from local storage doesn't prevent feedback from reaching Platform or another exporter.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
[`MastraStorageExporter`](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) looks up the trace or span in your configured storage before saving feedback. If the target remains unavailable after retries, it logs a warning and skips the local write. Call `mastra.observability.flush()` or `shutdown()` before your process exits to finish pending delivery.
|
|
41
41
|
|
|
42
42
|
## Find the trace for a message
|
|
43
43
|
|
|
@@ -185,11 +185,9 @@ The local runtime exposes the list route at `/api/observability/feedback` and an
|
|
|
185
185
|
|
|
186
186
|
## Export feedback to Mastra Platform
|
|
187
187
|
|
|
188
|
-
[`MastraPlatformExporter`](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter)
|
|
188
|
+
[`MastraPlatformExporter`](https://mastra.ai/reference/observability/tracing/exporters/mastra-platform-exporter) sends feedback to Mastra Platform, which looks up the target trace or span when needed. Local trace storage isn't required. Add `MastraStorageExporter` only if you also want a local copy.
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
See [Observability on Mastra Platform](https://mastra.ai/docs/mastra-platform/observability) for the combined exporter configuration.
|
|
190
|
+
Studio sends feedback to the backend serving its trace reads. For HTTP creates handled by your OSS server, the server saves feedback locally and notifies configured exporters. Because exporter delivery is asynchronous, a successful HTTP response doesn't guarantee that the record is already visible at a remote destination. Direct storage writes bypass exporters.
|
|
193
191
|
|
|
194
192
|
## Export feedback to external platforms
|
|
195
193
|
|
|
@@ -118,6 +118,45 @@ Markers tell a session what the image already ran: `.mastra-sandbox/repos/<repo>
|
|
|
118
118
|
|
|
119
119
|
If any entry's access or head can't be resolved, the whole resolution rejects and the sandbox falls back to its default template.
|
|
120
120
|
|
|
121
|
+
## Docker Cloud Sandboxes
|
|
122
|
+
|
|
123
|
+
`DockerSandboxesSandbox` runs commands in a Docker Cloud Sandboxes microVM instead of a local container. Supply an authenticated `@docker/sandboxes` client to access Docker Cloud Sandboxes.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { Sandboxes, pat } from '@docker/sandboxes'
|
|
127
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
128
|
+
import { DockerSandboxesSandbox } from '@mastra/docker'
|
|
129
|
+
|
|
130
|
+
const client = new Sandboxes({
|
|
131
|
+
auth: pat({
|
|
132
|
+
username: process.env.DOCKER_USERNAME!,
|
|
133
|
+
personalAccessToken: process.env.DOCKER_PAT!,
|
|
134
|
+
}),
|
|
135
|
+
})
|
|
136
|
+
const workspace = new Workspace({
|
|
137
|
+
sandbox: new DockerSandboxesSandbox({
|
|
138
|
+
id: sessionId,
|
|
139
|
+
image: 'ubuntu:24.04',
|
|
140
|
+
environment: { NODE_ENV: 'production' },
|
|
141
|
+
client,
|
|
142
|
+
}),
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The `id` is used as the remote sandbox display name for reconnection lookup, so a new instance with the same `id` reconnects to an existing microVM and restarts it if it was stopped. Each instance uses a separate creation idempotency key. Pass `sandboxId` to reconnect directly to a known remote sandbox.
|
|
147
|
+
|
|
148
|
+
Commands run through `sh -lc`, so command strings can use pipes, redirects and `&&`. Separate `args` are shell-quoted. `executeCommand` supports `timeout`, `abortSignal`, streaming `onStdout`/`onStderr` callbacks and `maxRetainedBytes` (default 1 MiB per stream). Calling `destroy()` deletes the remote sandbox.
|
|
149
|
+
|
|
150
|
+
**image** (`string`): Image used to create the cloud sandbox.
|
|
151
|
+
|
|
152
|
+
**id** (`string`): Stable logical identifier used as the remote display name for reconnection lookup. (Default: `Auto-generated`)
|
|
153
|
+
|
|
154
|
+
**sandboxId** (`string`): Remote sandbox name to reconnect to directly.
|
|
155
|
+
|
|
156
|
+
**environment** (`Record<string, string>`): Environment variables set on a newly created cloud sandbox.
|
|
157
|
+
|
|
158
|
+
**client** (`Sandboxes`): Authenticated Docker Cloud Sandboxes client. Supply one to access Docker Cloud Sandboxes; caller-owned clients are not closed on destroy().
|
|
159
|
+
|
|
121
160
|
## Constructor parameters
|
|
122
161
|
|
|
123
162
|
**id** (`string`): Unique identifier for this sandbox instance. Used for label-based reconnection. (Default: `Auto-generated`)
|
|
@@ -371,11 +371,17 @@ const result = await mastraClient.deleteTraces({
|
|
|
371
371
|
traceIds: ['trace-1', 'trace-2'],
|
|
372
372
|
})
|
|
373
373
|
|
|
374
|
-
|
|
374
|
+
if ('accepted' in result) {
|
|
375
|
+
console.log('Deletion requested')
|
|
376
|
+
} else {
|
|
377
|
+
console.log(result.success)
|
|
378
|
+
}
|
|
375
379
|
```
|
|
376
380
|
|
|
377
381
|
Each request accepts up to 1,000 trace IDs and no tenant scope fields. Signals that aren't linked to a trace are preserved. Traces created by experiments are deleted like any other trace.
|
|
378
382
|
|
|
383
|
+
The client supports two response shapes: OSS returns `{ success: true }` after its delete operation, while a Platform backend that supports queued batch deletion returns `202 { accepted: true }` after accepting cleanup. Acceptance doesn't mean records have disappeared from reads, so check the response before reporting deletion as complete. Using these client methods with Platform requires a deployment that supports the batch deletion endpoints.
|
|
384
|
+
|
|
379
385
|
## Scoring traces
|
|
380
386
|
|
|
381
387
|
Score specific traces using registered scorers for evaluation:
|
|
@@ -432,7 +438,7 @@ const response = await mastraClient.createScore({
|
|
|
432
438
|
|
|
433
439
|
## Feedback
|
|
434
440
|
|
|
435
|
-
Feedback methods create, list, and query human-in-the-loop signals such as ratings, thumbs, comments, and corrections through the configured API server. Create methods support OSS and Platform. Full replacement
|
|
441
|
+
Feedback methods create, list, and query human-in-the-loop signals such as ratings, thumbs, comments, and corrections through the configured API server. Create methods support OSS and Platform. Full replacement is supported by Platform and OSS servers with feedback replacement support. See the [feedback guide](https://mastra.ai/docs/observability/feedback) for examples and the [feedback reference](https://mastra.ai/reference/observability/feedback) for full schemas.
|
|
436
442
|
|
|
437
443
|
### Get feedback by ID
|
|
438
444
|
|
|
@@ -492,9 +498,9 @@ Create responses contain `success` and optional `data` with the generated or sup
|
|
|
492
498
|
|
|
493
499
|
Explicit modes require server support. Older servers may ignore `contextMode`. Deploy Platform's supplied-context support before sending `"provided"` there.
|
|
494
500
|
|
|
495
|
-
### Replacing feedback
|
|
501
|
+
### Replacing feedback
|
|
496
502
|
|
|
497
|
-
`replaceFeedback()` sends a full replacement to `PUT /api/observability/feedback/:feedbackId`. Include the original `feedbackId`, `traceId`, and normalized `timestamp`, along with all feedback fields to retain.
|
|
503
|
+
`replaceFeedback()` sends a full replacement to `PUT /api/observability/feedback/:feedbackId`. Include the original `feedbackId`, `traceId`, and normalized `timestamp`, along with all feedback fields to retain. Platform and OSS servers with feedback replacement support accept this method. OSS returns `501` when its storage adapter doesn't support replacement. For OSS, check `capabilities.feedbackReplacement` before offering edits. A missing capability means unavailable.
|
|
498
504
|
|
|
499
505
|
```typescript
|
|
500
506
|
await mastraClient.replaceFeedback({
|
|
@@ -509,7 +515,7 @@ await mastraClient.replaceFeedback({
|
|
|
509
515
|
})
|
|
510
516
|
```
|
|
511
517
|
|
|
512
|
-
Use the normalized timestamp from the create response's `data` when available.
|
|
518
|
+
Use the normalized timestamp from the create response's `data` when available. OSS rejects changes to the original trace or timestamp with `409`. Platform uses the timestamp as part of record identity, so preserve it there too. The client preserves the replacement body across retries, but each accepted PUT retry is a new replacement and can supersede another edit. Pass `{ retries: 0, anchorRetryTimeoutMs: 0 }` as the second argument to disable automatic retries.
|
|
513
519
|
|
|
514
520
|
### Deleting feedback and scores
|
|
515
521
|
|
|
@@ -529,6 +535,8 @@ await mastraClient.deleteScores({
|
|
|
529
535
|
})
|
|
530
536
|
```
|
|
531
537
|
|
|
538
|
+
Both methods return `{ success: boolean }` from OSS or `{ accepted: true }` from a Platform backend that supports queued batch deletion. See [Deleting traces](#deleting-traces) for response handling. Accepted records can remain readable until cleanup runs. Platform uses authenticated organization/project scope, which request-body scope fields can't override.
|
|
539
|
+
|
|
532
540
|
### Listing feedback
|
|
533
541
|
|
|
534
542
|
Retrieve paginated feedback records with optional filters:
|
|
@@ -33,7 +33,7 @@ await mastra.observability.addFeedback({
|
|
|
33
33
|
|
|
34
34
|
### `addFeedback(args)`
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Sends feedback about a trace or span to configured exporters.
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
39
|
await mastra.observability.addFeedback?.({
|
|
@@ -56,7 +56,9 @@ await mastra.observability.addFeedback?.({
|
|
|
56
56
|
|
|
57
57
|
**feedback** (`FeedbackInput`): Feedback payload to add.
|
|
58
58
|
|
|
59
|
-
Without `correlationContext`,
|
|
59
|
+
Without `correlationContext`, each exporter handles the target trace or span at its own destination. `MastraStorageExporter` resolves it from local storage. A failed local lookup doesn't block other exporters. `MastraPlatformExporter` doesn't require local storage. Use `flush()` or `shutdown()` to drain pending deliveries.
|
|
60
|
+
|
|
61
|
+
Local lookup requires the target span's parent chain through its root so feedback inherits the correct root tags. If any ancestor remains missing after retries, the storage exporter logs a warning and skips the local write. Other exporters still receive the feedback.
|
|
60
62
|
|
|
61
63
|
### `createFeedback(args)`
|
|
62
64
|
|
|
@@ -138,7 +140,7 @@ await mastraClient.deleteFeedback({
|
|
|
138
140
|
|
|
139
141
|
**resourceId** (`string`): Restricts the delete to records with this resource id.
|
|
140
142
|
|
|
141
|
-
|
|
143
|
+
The OSS HTTP route returns `{ success: boolean }`. `mastraClient.deleteFeedback()` returns `Promise<{ success: boolean } | { accepted: true }>` to also support Platform backends with queued batch deletion. An accepted response means cleanup is queued, and records can remain readable until cleanup runs. See [client deletion response handling](https://mastra.ai/reference/client-js/observability). The storage domain method returns `Promise<void>`. Requests with more than 1,000 ids return `400`, and a server running `@mastra/core` older than `1.66.0` returns `501`. ClickHouse vNext, PostgreSQL vNext, DuckDB, and the in-memory store implement deletion. Every other adapter, including LibSQL and MongoDB, throws `OBSERVABILITY_STORAGE_DELETE_FEEDBACK_NOT_IMPLEMENTED`.
|
|
142
144
|
|
|
143
145
|
On ClickHouse, deletion uses lightweight deletes on the main feedback events table to remove rows from reads, including OLAP queries, without guaranteeing immediate physical removal, so open-source deployments must configure an [observability retention period](https://mastra.ai/reference/storage/retention) to physically purge them. Each request is marked applied once its delete succeeds; if the delete fails, the request stays unapplied, doesn't block `updateFeedbackReviewStatus()` on the still-visible feedback, and you retry by calling `deleteFeedback()` again. `updateFeedbackReviewStatus()` also retries the delete and throws a not-found error if the retry succeeds, or saves the new status and throws the delete's error if it fails again. Open-source deployments have no background reconciler. ClickHouse applies a TTL to deletion requests only when all five signals have finite retention. See [ClickHouse native TTL](https://mastra.ai/reference/storage/retention). Delete APIs leave the separate delta cursor table untouched. Its rows contain identifiers rather than feedback payloads and expire within two days.
|
|
144
146
|
|
|
@@ -413,21 +415,48 @@ Use `FeedbackFilter` in `listFeedback()` and OLAP query `filters`.
|
|
|
413
415
|
|
|
414
416
|
**tags** (`string[]`): Filter by tags. Matching records must have all specified tags.
|
|
415
417
|
|
|
418
|
+
## Replace feedback
|
|
419
|
+
|
|
420
|
+
`PUT /api/observability/feedback/:feedbackId` accepts a full `{ feedback: { ... } }` replacement. Keep the original `feedbackId`, `traceId`, and `timestamp`, and include every field you want to retain. Omitted optional fields are cleared. The URL and body IDs must match. See [the client example](https://mastra.ai/reference/client-js/observability).
|
|
421
|
+
|
|
422
|
+
OSS writes to its configured storage before returning success and notifies supporting exporters independently. `contextMode` has the same meaning as on create. In `"resolve"` mode, the local trace or span must exist. A missing feedback record is created from the full replacement. Changing an existing record's trace or timestamp returns `409`.
|
|
423
|
+
|
|
424
|
+
In-memory, PostgreSQL vNext, DuckDB, and ClickHouse vNext storage support replacement. Check `capabilities.feedbackReplacement` on the server. Unsupported versions return `501`. Sequential retries of the original HTTP create don't undo a replacement. Direct storage `createFeedback()` calls retain upsert behavior. Pass `onConflict: 'ignore'` to keep an existing record.
|
|
425
|
+
|
|
426
|
+
ClickHouse support uses the existing schema without a migration. Concurrent writes from separate processes can race, so it doesn't guarantee ordering between overlapping creates and replacements. Serialize edits to the same feedback record when using this adapter.
|
|
427
|
+
|
|
428
|
+
To send a replacement to configured exporters without depending on local storage, use the observability entrypoint:
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
await mastra.observability.replaceFeedback?.({
|
|
432
|
+
traceId: 'trace-123',
|
|
433
|
+
feedback: {
|
|
434
|
+
feedbackId: 'feedback-1',
|
|
435
|
+
timestamp: new Date('2026-11-11T12:00:00.123Z'),
|
|
436
|
+
feedbackType: 'thumbs',
|
|
437
|
+
value: -1,
|
|
438
|
+
},
|
|
439
|
+
})
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Each exporter handles its destination independently. `MastraStorageExporter` resolves local span context when needed, and `MastraPlatformExporter` sends a PUT to Platform. Exporters without a replacement handler skip the event. `flush()` and `shutdown()` wait for pending deliveries.
|
|
443
|
+
|
|
416
444
|
## HTTP routes
|
|
417
445
|
|
|
418
446
|
These routes belong to a Mastra runtime and use its configured observability storage. They're separate from the [unversioned Mastra Platform Feedback API](https://mastra.ai/docs/mastra-platform/api), which doesn't provide a feedback creation route.
|
|
419
447
|
|
|
420
|
-
| Method | Path | Purpose
|
|
421
|
-
| -------- | ------------------------------------------------------- |
|
|
422
|
-
| `GET` | `/api/observability/feedback` | List feedback records
|
|
423
|
-
| `POST` | `/api/observability/feedback` | Create a feedback record
|
|
424
|
-
| `
|
|
425
|
-
| `DELETE` | `/api/observability/
|
|
426
|
-
| `
|
|
427
|
-
| `
|
|
428
|
-
| `POST` | `/api/observability/feedback/
|
|
429
|
-
| `POST` | `/api/observability/feedback/
|
|
430
|
-
| `POST` | `/api/observability/feedback/
|
|
448
|
+
| Method | Path | Purpose | Permission |
|
|
449
|
+
| -------- | ------------------------------------------------------- | ---------------------------------- | ---------------------- |
|
|
450
|
+
| `GET` | `/api/observability/feedback` | List feedback records | `observability:read` |
|
|
451
|
+
| `POST` | `/api/observability/feedback` | Create a feedback record | `observability:write` |
|
|
452
|
+
| `PUT` | `/api/observability/feedback/:feedbackId` | Replace a complete feedback record | `observability:write` |
|
|
453
|
+
| `DELETE` | `/api/observability/feedback` | Delete feedback records by id | `observability:delete` |
|
|
454
|
+
| `DELETE` | `/api/observability/scores` | Delete score records by id | `observability:delete` |
|
|
455
|
+
| `PATCH` | `/api/observability/feedback/:feedbackId/review-status` | Update review status | `observability:write` |
|
|
456
|
+
| `POST` | `/api/observability/feedback/aggregate` | Return one aggregate value | `observability:read` |
|
|
457
|
+
| `POST` | `/api/observability/feedback/breakdown` | Group feedback by dimensions | `observability:read` |
|
|
458
|
+
| `POST` | `/api/observability/feedback/timeseries` | Bucket feedback by interval | `observability:read` |
|
|
459
|
+
| `POST` | `/api/observability/feedback/percentiles` | Return percentile series | `observability:read` |
|
|
431
460
|
|
|
432
461
|
### List query parameters
|
|
433
462
|
|
|
@@ -37,7 +37,7 @@ interface MastraPlatformExporterConfig extends BaseExporterConfig {
|
|
|
37
37
|
uploadTimeoutMs?: number // Default: 30000
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/** Maximum retry attempts. Default: 3 */
|
|
40
|
+
/** Maximum retry attempts for collector batches. Default: 3 */
|
|
41
41
|
maxRetries?: number
|
|
42
42
|
|
|
43
43
|
/** Mastra Observability access token (from env or config) */
|
|
@@ -142,11 +142,9 @@ Every `MetricEvent` passed to this handler is buffered and exported to the metri
|
|
|
142
142
|
async onScoreEvent(event: ScoreEvent): Promise<void>
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
Schedules a score for export using the [feedback and score delivery](#feedback-and-score-delivery) behavior. Events are ignored when the exporter is disabled or shutdown has started. If Platform needs to look up the trace, a missing trace ID causes the record to be dropped.
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
**Returns:** `Promise<void>` after the score event has been accepted for buffering.
|
|
147
|
+
**Returns:** `Promise<void>` when the event has been scheduled or ignored. Call `flush()` to wait for pending deliveries, because this return value doesn't confirm delivery.
|
|
150
148
|
|
|
151
149
|
### `onFeedbackEvent`
|
|
152
150
|
|
|
@@ -154,11 +152,9 @@ Every `ScoreEvent` passed to this handler is buffered and exported to the scores
|
|
|
154
152
|
async onFeedbackEvent(event: FeedbackEvent): Promise<void>
|
|
155
153
|
```
|
|
156
154
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
Every `FeedbackEvent` passed to this handler is buffered and exported to the feedback endpoint derived from the configured base endpoint. No feedback-type filtering inside `MastraPlatformExporter` is performed. All feedback events received here are forwarded unless the exporter is disabled.
|
|
155
|
+
Schedules feedback for export using the [feedback and score delivery](#feedback-and-score-delivery) behavior. Events are ignored when the exporter is disabled or shutdown has started. If Platform needs to look up the trace, a missing trace ID causes the record to be dropped.
|
|
160
156
|
|
|
161
|
-
**Returns:** `Promise<void>`
|
|
157
|
+
**Returns:** `Promise<void>` when the event has been scheduled or ignored. Call `flush()` to wait for pending deliveries, because this return value doesn't confirm delivery.
|
|
162
158
|
|
|
163
159
|
### flush
|
|
164
160
|
|
|
@@ -187,12 +183,18 @@ If no access token is provided via config or environment variable, the exporter:
|
|
|
187
183
|
|
|
188
184
|
### Batching
|
|
189
185
|
|
|
190
|
-
The exporter batches
|
|
186
|
+
The exporter batches traces, logs, and metrics, along with feedback and scores that already include their trace details:
|
|
191
187
|
|
|
192
188
|
- Flushes when total buffered event count reaches `maxBatchSize`
|
|
193
189
|
- Flushes when `maxBatchWaitMs` elapsed since the first buffered signal in the batch
|
|
194
190
|
- Flushes on `shutdown()`
|
|
195
191
|
|
|
192
|
+
### Feedback and score delivery
|
|
193
|
+
|
|
194
|
+
Feedback and scores received by the exporter can reference a trace stored in Platform using its trace ID and an optional span ID. If the record needs details from that trace, the exporter sends it immediately instead of waiting for a batch.
|
|
195
|
+
|
|
196
|
+
Call `flush()` before ending a short-lived process, or `shutdown()` when stopping the exporter, to wait for pending deliveries and retries. These methods finish when records have been accepted or dropped after a failure. Accepted feedback and scores may take time to appear in Platform.
|
|
197
|
+
|
|
196
198
|
### Byte batching
|
|
197
199
|
|
|
198
200
|
Set `byteBatching` to flush by serialized byte size and control concurrent uploads:
|
|
@@ -212,7 +214,7 @@ const exporter = new MastraPlatformExporter({
|
|
|
212
214
|
Without `byteBatching`, the exporter keeps its existing count-based batching behavior.
|
|
213
215
|
|
|
214
216
|
- `maxBatchBytes` triggers an upload when a batch reaches 8 MiB by default. Larger records are sent intact, without truncation or size-based drops.
|
|
215
|
-
- `maxConcurrentUploads` controls concurrent
|
|
217
|
+
- `maxConcurrentUploads` controls concurrent collector batch uploads. The default is two.
|
|
216
218
|
- `uploadTimeoutMs` sets the upload deadline, including retries. The default is 30 seconds.
|
|
217
219
|
|
|
218
220
|
Record-count and timer-based flush triggers still apply. Queued records are retained when uploads fall behind, so queue memory can grow.
|
|
@@ -221,7 +223,7 @@ Inspect the current queue with `exporter.getByteBatchingStats()`.
|
|
|
221
223
|
|
|
222
224
|
### Error handling
|
|
223
225
|
|
|
224
|
-
- Uses exponential backoff retry with `maxRetries` attempts
|
|
226
|
+
- Uses exponential backoff retry for collector batches with `maxRetries` attempts
|
|
225
227
|
- Drops batches after all retries fail
|
|
226
228
|
- Logs errors but continues processing new events
|
|
227
229
|
|
|
@@ -232,14 +234,14 @@ Errors raised by `MastraPlatformExporter` use the `MASTRA_PLATFORM_EXPORTER_*` `
|
|
|
232
234
|
When an organization has exhausted its observability quota, the Mastra platform rejects publish requests with `402 Payment Required` plus the `x-mastra-observability: disabled` header. When the exporter sees a `402` (or the header) on any publish route, it:
|
|
233
235
|
|
|
234
236
|
- Drops the rejected batch without retrying it
|
|
235
|
-
- Pauses
|
|
237
|
+
- Pauses collector batches for traces, logs, metrics, scores, and feedback, dropping buffered and incoming batch records
|
|
236
238
|
- Logs a warning that telemetry is paused
|
|
237
239
|
- Probes the platform periodically with an empty batch, using the interval from the `x-mastra-observability-retry-after` header (seconds), or every 5 minutes if the header is absent
|
|
238
240
|
- Resumes exporting automatically and logs a warning once the platform stops rejecting with `402`
|
|
239
241
|
|
|
240
242
|
The probe timer doesn't keep the Node.js process alive, so short-lived and serverless processes exit normally while paused.
|
|
241
243
|
|
|
242
|
-
Every request
|
|
244
|
+
Every collector request (batch uploads and the traces recovery probe) includes the `x-mastra-observability-capabilities: quota-pause-v1` header. This tells the platform that the client understands the quota-pause contract, so it can safely respond with `402` instead of silently dropping telemetry for older clients that would retry it.
|
|
243
245
|
|
|
244
246
|
### Endpoint routing
|
|
245
247
|
|
|
@@ -248,10 +250,11 @@ Every request the exporter sends (batch uploads for all five signal types, plus
|
|
|
248
250
|
- With `projectId` or `MASTRA_PROJECT_ID`, derived routes use `/projects/:projectId/ai/{signal}/publish`
|
|
249
251
|
- Explicit full publish URLs are used as-is, even when `projectId` is configured
|
|
250
252
|
|
|
251
|
-
###
|
|
253
|
+
### Event processing
|
|
252
254
|
|
|
253
255
|
- `exportTracingEvent()` only exports `SPAN_ENDED` tracing events
|
|
254
|
-
- `onLogEvent()
|
|
256
|
+
- `onLogEvent()` and `onMetricEvent()` buffer events
|
|
257
|
+
- `onScoreEvent()` and `onFeedbackEvent()` deliver records as described in [Feedback and score delivery](#feedback-and-score-delivery)
|
|
255
258
|
- All supported signal batches are uploaded to their matching publish endpoints during `flush()` and `shutdown()`
|
|
256
259
|
|
|
257
260
|
## Span wire format
|
|
@@ -652,6 +652,29 @@ processOutputStream?(args: ProcessOutputStreamArgs): Promise<ChunkType | null |
|
|
|
652
652
|
|
|
653
653
|
Dropping a chunk only affects that single chunk. The stream continues and the next chunk is still processed. To stop the stream entirely, call `abort()`.
|
|
654
654
|
|
|
655
|
+
#### Emitting a second chunk
|
|
656
|
+
|
|
657
|
+
`processOutputStream` returns one chunk, but a processor sometimes needs to emit two for one input, such as text it held back followed by the chunk that released it. Return the first chunk and set the second on `state` under `REPROCESS_PART_KEY`. Mastra emits the stashed chunk right after the returned one.
|
|
658
|
+
|
|
659
|
+
The stashed chunk goes through the output processors again, including the one that stashed it, so that processor must pass it through unchanged on the second pass:
|
|
660
|
+
|
|
661
|
+
```typescript
|
|
662
|
+
import { REPROCESS_PART_KEY } from '@mastra/core/processors'
|
|
663
|
+
import type { ChunkType } from '@mastra/core/stream'
|
|
664
|
+
import type { ProcessOutputStreamArgs, Processor } from '@mastra/core/processors'
|
|
665
|
+
|
|
666
|
+
export class SignOff implements Processor<'sign-off'> {
|
|
667
|
+
readonly id = 'sign-off'
|
|
668
|
+
|
|
669
|
+
async processOutputStream({ part, state }: ProcessOutputStreamArgs): Promise<ChunkType> {
|
|
670
|
+
if (part.type !== 'text-end' || state.signed) return part
|
|
671
|
+
state.signed = true
|
|
672
|
+
state[REPROCESS_PART_KEY] = part
|
|
673
|
+
return { ...part, type: 'text-delta', payload: { id: part.payload.id, text: '\n\nCheers!' } }
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
655
678
|
***
|
|
656
679
|
|
|
657
680
|
### `processOutputResult`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.13-alpha.
|
|
3
|
+
"version": "1.3.13-alpha.11",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
|
|
27
27
|
"local-pkg": "^1.2.1",
|
|
28
28
|
"zod": "^4.6.7",
|
|
29
|
-
"@mastra/core": "1.83.0-alpha.
|
|
29
|
+
"@mastra/core": "1.83.0-alpha.8",
|
|
30
30
|
"@mastra/mcp": "^2.9.0-alpha.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|