@mastra/mcp-docs-server 1.3.5-alpha.5 → 1.3.5-alpha.8
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/harness/durable-agents.md +2 -0
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/edenai.md +4 -1
- package/.docs/models/providers/kilo.md +11 -11
- package/.docs/models/providers/nano-gpt.md +1 -1
- package/.docs/reference/agents/durable-agent.md +8 -3
- package/.docs/reference/memory/observational-memory.md +2 -2
- package/.docs/reference/observability/tracing/trace-query.md +50 -0
- package/package.json +4 -4
|
@@ -170,6 +170,8 @@ for await (const chunk of output.fullStream) {
|
|
|
170
170
|
}
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
+
Calling `observe(runId)` without an offset is the supported general reconnect flow. It replays all available cached events before delivering live events. The optional `offset` is an inclusive, zero-based PubSub event index, not a chunk number, and the public stream doesn't expose it. If an offset skips earlier text deltas, aggregated text is partial and structured output may be invalid. On transports with numeric offset support, an offset beyond the highest retained index also skips live events with lower indexes. Events arrive only when the published index reaches the requested offset. If the index counter restarts below that offset and never reaches it, observation remains pending indefinitely. See [`observe(runId, options?)`](https://mastra.ai/reference/agents/durable-agent) for the full offset and transport behavior.
|
|
174
|
+
|
|
173
175
|
Observing doesn't own the run. When the loop ends, or you leave it early with `break`, `return`, or an error, the observer unsubscribes and the run keeps going for anyone else watching it. To stop observing from outside the loop, for example when the client disconnects, call `detach()`:
|
|
174
176
|
|
|
175
177
|
```typescript
|
|
@@ -765,7 +765,7 @@ When message tokens reach the `messageTokens` threshold, buffered chunks activat
|
|
|
765
765
|
|
|
766
766
|
Async buffered Observer calls don't generate continuation hints because delayed hints can be stale by activation time. When buffered chunks activate, any previously stored suggested response and current task are cleared. The main agent receives the compressed observations without those hints.
|
|
767
767
|
|
|
768
|
-
When message production outpaces the Observer, the `blockAfter` safety threshold allows activation to overshoot the retention target instead of using fewer chunks. Activation still uses no more chunks than needed to reach the target, and the default settings remain unaffected. A synchronous observation runs when the `messageTokens` threshold is reached and buffered
|
|
768
|
+
When message production outpaces the Observer, the `blockAfter` safety threshold allows activation to overshoot the retention target instead of using fewer chunks. Activation still uses no more chunks than needed to reach the target, and the default settings remain unaffected. A synchronous observation runs when the `messageTokens` threshold is reached and activating buffered chunks doesn't bring pending tokens back under it. For example, this happens when a large tool result arrives after buffering has stopped. Buffered activation usually preserves a minimum remaining context (the smaller of \~1k tokens or the configured retention floor), but a single buffered chunk that covers the whole pending window still activates and can leave less.
|
|
769
769
|
|
|
770
770
|
Reflection works similarly: the Reflector runs in the background when observations reach a fraction of the reflection threshold.
|
|
771
771
|
|
package/.docs/models/index.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Model Providers
|
|
6
6
|
|
|
7
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
7
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 7766 models from 213 providers through a single API.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Eden AI
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 290 Eden AI models through Mastra's model router. Authentication is handled automatically using the `EDENAI_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Eden AI documentation](https://docs.edenai.co).
|
|
10
10
|
|
|
@@ -138,6 +138,7 @@ for await (const chunk of stream) {
|
|
|
138
138
|
| `edenai/fireworks_ai/accounts/fireworks/models/inkling` | 1.0M | | | | | | $1 | $4 |
|
|
139
139
|
| `edenai/fireworks_ai/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 |
|
|
140
140
|
| `edenai/flexai/DeepSeek-V4-Flash-0731` | 1.0M | | | | | | $0.06 | $0.18 |
|
|
141
|
+
| `edenai/flexai/DeepSeek-V4.1-Flash` | 1.0M | | | | | | $0.14 | $0.42 |
|
|
141
142
|
| `edenai/flexai/gpt-oss-120b` | 131K | | | | | | $0.03 | $0.17 |
|
|
142
143
|
| `edenai/flexai/gpt-oss-20b` | 131K | | | | | | $0.02 | $0.10 |
|
|
143
144
|
| `edenai/google/gemini-2.5-flash-image` | 33K | | | | | | $0.30 | $3 |
|
|
@@ -158,6 +159,7 @@ for await (const chunk of stream) {
|
|
|
158
159
|
| `edenai/google/gemini-3.8-flash` | 1.0M | | | | | | $0.75 | $4 |
|
|
159
160
|
| `edenai/google/gemini-flash-latest` | 1.0M | | | | | | $0.75 | $4 |
|
|
160
161
|
| `edenai/google/gemini-pro-latest` | 1.0M | | | | | | $2 | $12 |
|
|
162
|
+
| `edenai/greenference/gpt-oss-20b` | 131K | | | | | | $0.01 | $0.04 |
|
|
161
163
|
| `edenai/groq/openai/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 |
|
|
162
164
|
| `edenai/groq/openai/gpt-oss-20b` | 131K | | | | | | $0.07 | $0.30 |
|
|
163
165
|
| `edenai/groq/openai/gpt-oss-safeguard-20b` | 131K | | | | | | $0.07 | $0.30 |
|
|
@@ -271,6 +273,7 @@ for await (const chunk of stream) {
|
|
|
271
273
|
| `edenai/tencent/deepseek-v4-pro-0813` | 1.0M | | | | | | $0.66 | $2 |
|
|
272
274
|
| `edenai/tencent/hy3` | 256K | | | | | | $0.13 | $0.53 |
|
|
273
275
|
| `edenai/tencent/hy4-preview` | 1.0M | | | | | | $0.83 | $3 |
|
|
276
|
+
| `edenai/tencent/step-5-preview` | 1.0M | | | | | | $1 | $3 |
|
|
274
277
|
| `edenai/tensorx/deepseek/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.25 | $0.30 |
|
|
275
278
|
| `edenai/tensorx/deepseek/deepseek-v4-pro-0813` | 1.0M | | | | | | $2 | $4 |
|
|
276
279
|
| `edenai/tensorx/deepseek/deepseek-v4.1-flash` | 1.0M | | | | | | $0.50 | $2 |
|
|
@@ -42,20 +42,20 @@ for await (const chunk of stream) {
|
|
|
42
42
|
| `kilo/~anthropic/claude-haiku-latest` | 200K | | | | | | $1 | $5 |
|
|
43
43
|
| `kilo/~anthropic/claude-opus-latest` | 1.0M | | | | | | $4 | $20 |
|
|
44
44
|
| `kilo/~anthropic/claude-sonnet-latest` | 1.0M | | | | | | $2 | $10 |
|
|
45
|
-
| `kilo/~deepseek/deepseek-flash-latest` | 1.0M | | | | | | $0.
|
|
46
|
-
| `kilo/~deepseek/deepseek-pro-latest` | 1.0M | | | | | | $0.
|
|
47
|
-
| `kilo/~deepseek/deepseek-v4-flash-latest` | 1.0M | | | | | | $0.
|
|
45
|
+
| `kilo/~deepseek/deepseek-flash-latest` | 1.0M | | | | | | $0.00 | $2 |
|
|
46
|
+
| `kilo/~deepseek/deepseek-pro-latest` | 1.0M | | | | | | $0.18 | $4 |
|
|
47
|
+
| `kilo/~deepseek/deepseek-v4-flash-latest` | 1.0M | | | | | | $0.02 | $1 |
|
|
48
48
|
| `kilo/~google/gemini-flash-latest` | 1.0M | | | | | | $0.75 | $4 |
|
|
49
49
|
| `kilo/~google/gemini-pro-latest` | 1.0M | | | | | | $2 | $12 |
|
|
50
|
-
| `kilo/~moonshotai/kimi-latest` | 1.0M | | | | | | $
|
|
50
|
+
| `kilo/~moonshotai/kimi-latest` | 1.0M | | | | | | $0.40 | $13 |
|
|
51
51
|
| `kilo/~openai/gpt-astra-latest` | 1.1M | | | | | | $10 | $50 |
|
|
52
52
|
| `kilo/~openai/gpt-luna-latest` | 1.1M | | | | | | $0.10 | $0.50 |
|
|
53
53
|
| `kilo/~openai/gpt-mini-latest` | 400K | | | | | | $0.75 | $5 |
|
|
54
54
|
| `kilo/~openai/gpt-sol-latest` | 1.1M | | | | | | $2 | $10 |
|
|
55
55
|
| `kilo/~openai/gpt-terra-latest` | 1.1M | | | | | | $2 | $12 |
|
|
56
56
|
| `kilo/~x-ai/grok-latest` | 500K | | | | | | $2 | $6 |
|
|
57
|
-
| `kilo/~z-ai/glm-flash-latest` | 1.0M | | | | | | $0.
|
|
58
|
-
| `kilo/~z-ai/glm-latest` | 1.0M | | | | | | $0.
|
|
57
|
+
| `kilo/~z-ai/glm-flash-latest` | 1.0M | | | | | | $0.02 | $0.50 |
|
|
58
|
+
| `kilo/~z-ai/glm-latest` | 1.0M | | | | | | $0.06 | $8 |
|
|
59
59
|
| `kilo/aion-labs/aion-2.0` | 131K | | | | | | $0.80 | $2 |
|
|
60
60
|
| `kilo/aion-labs/aion-3.0` | 131K | | | | | | $3 | $6 |
|
|
61
61
|
| `kilo/aion-labs/aion-3.0-mini` | 131K | | | | | | $0.70 | $1 |
|
|
@@ -101,7 +101,7 @@ for await (const chunk of stream) {
|
|
|
101
101
|
| `kilo/cohere/command-r7b-12-2024` | 128K | | | | | | $0.04 | $0.15 |
|
|
102
102
|
| `kilo/cohere/north-mini-code:free` | 256K | | | | | | — | — |
|
|
103
103
|
| `kilo/deepseek/deepseek-chat` | 128K | | | | | | $0.26 | $1 |
|
|
104
|
-
| `kilo/deepseek/deepseek-chat-v3-0324` |
|
|
104
|
+
| `kilo/deepseek/deepseek-chat-v3-0324` | 164K | | | | | | $0.25 | $1 |
|
|
105
105
|
| `kilo/deepseek/deepseek-chat-v3.1` | 164K | | | | | | $0.25 | $0.95 |
|
|
106
106
|
| `kilo/deepseek/deepseek-r1` | 64K | | | | | | $0.70 | $3 |
|
|
107
107
|
| `kilo/deepseek/deepseek-r1-0528` | 164K | | | | | | $0.70 | $3 |
|
|
@@ -212,9 +212,9 @@ for await (const chunk of stream) {
|
|
|
212
212
|
| `kilo/moonshotai/kimi-k2-0905` | 262K | | | | | | $0.60 | $3 |
|
|
213
213
|
| `kilo/moonshotai/kimi-k2-thinking` | 262K | | | | | | $0.60 | $3 |
|
|
214
214
|
| `kilo/moonshotai/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
215
|
-
| `kilo/moonshotai/kimi-k2.6` | 262K | | | | | | $0.
|
|
215
|
+
| `kilo/moonshotai/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
216
216
|
| `kilo/moonshotai/kimi-k2.7-code` | 262K | | | | | | $0.67 | $3 |
|
|
217
|
-
| `kilo/moonshotai/kimi-k3` | 1.0M | | | | | | $3 | $
|
|
217
|
+
| `kilo/moonshotai/kimi-k3` | 1.0M | | | | | | $3 | $15 |
|
|
218
218
|
| `kilo/morph/morph-v3-fast` | 82K | | | | | | $0.80 | $1 |
|
|
219
219
|
| `kilo/morph/morph-v3-large` | 262K | | | | | | $0.90 | $2 |
|
|
220
220
|
| `kilo/nex-agi/nex-n2.5-mini` | 262K | | | | | | $0.03 | $0.10 |
|
|
@@ -336,7 +336,7 @@ for await (const chunk of stream) {
|
|
|
336
336
|
| `kilo/qwen/qwen3-max` | 262K | | | | | | $0.78 | $4 |
|
|
337
337
|
| `kilo/qwen/qwen3-max-thinking` | 262K | | | | | | $0.78 | $4 |
|
|
338
338
|
| `kilo/qwen/qwen3-next-80b-a3b-instruct` | 262K | | | | | | $0.10 | $0.78 |
|
|
339
|
-
| `kilo/qwen/qwen3-next-80b-a3b-thinking` |
|
|
339
|
+
| `kilo/qwen/qwen3-next-80b-a3b-thinking` | 131K | | | | | | $0.15 | $1 |
|
|
340
340
|
| `kilo/qwen/qwen3-vl-235b-a22b-instruct` | 131K | | | | | | $0.26 | $1 |
|
|
341
341
|
| `kilo/qwen/qwen3-vl-235b-a22b-thinking` | 131K | | | | | | $0.40 | $4 |
|
|
342
342
|
| `kilo/qwen/qwen3-vl-30b-a3b-instruct` | 262K | | | | | | $0.13 | $0.52 |
|
|
@@ -416,7 +416,7 @@ for await (const chunk of stream) {
|
|
|
416
416
|
| `kilo/x-ai/grok-build-0.1` | 256K | | | | | | $1 | $2 |
|
|
417
417
|
| `kilo/xiaomi/mimo-v2.5` | 1.0M | | | | | | $0.14 | $0.28 |
|
|
418
418
|
| `kilo/xiaomi/mimo-v2.5-pro` | 1.0M | | | | | | $0.43 | $0.87 |
|
|
419
|
-
| `kilo/xiaomi/mimo-v2.6-flash` | 1.0M | | | | | | $0.
|
|
419
|
+
| `kilo/xiaomi/mimo-v2.6-flash` | 1.0M | | | | | | $0.11 | $0.28 |
|
|
420
420
|
| `kilo/xiaomi/mimo-v2.6-pro` | 1.0M | | | | | | $0.43 | $0.87 |
|
|
421
421
|
| `kilo/xiaomi/mimo-v2.6-pro-ultraspeed` | 1.0M | | | | | | $4 | $9 |
|
|
422
422
|
| `kilo/z-ai/glm-4.5` | 131K | | | | | | $0.60 | $2 |
|
|
@@ -265,7 +265,6 @@ for await (const chunk of stream) {
|
|
|
265
265
|
| `nano-gpt/inference-net/schematron-v2-turbo` | 128K | | | | | | $0.03 | $0.15 |
|
|
266
266
|
| `nano-gpt/inflatebot/MN-12B-Mag-Mell-R1` | 16K | | | | | | $0.49 | $0.49 |
|
|
267
267
|
| `nano-gpt/kimi-k2-instruct-fast` | 131K | | | | | | $0.40 | $2 |
|
|
268
|
-
| `nano-gpt/kitani/clover-1-150b` | 200K | | | | | | $0.15 | $0.80 |
|
|
269
268
|
| `nano-gpt/LatitudeGames/Wayfarer-Large-70B-Llama-3.3` | 33K | | | | | | $0.70 | $0.70 |
|
|
270
269
|
| `nano-gpt/lightonai/LightOnOCR-2-1B` | 33K | | | | | | $0.18 | $0.35 |
|
|
271
270
|
| `nano-gpt/liquid/lfm-2.5-2.6b` | 128K | | | | | | $0.10 | $0.20 |
|
|
@@ -504,6 +503,7 @@ for await (const chunk of stream) {
|
|
|
504
503
|
| `nano-gpt/sakana/fugu-max` | 1.0M | | | | | | $2 | $6 |
|
|
505
504
|
| `nano-gpt/sakana/fugu-ultra` | 1.0M | | | | | | $5 | $30 |
|
|
506
505
|
| `nano-gpt/sakana/fugu-ultra-v1.1` | 1.0M | | | | | | $5 | $30 |
|
|
506
|
+
| `nano-gpt/sakana/sakana-namazu` | 262K | | | | | | $0.95 | $4 |
|
|
507
507
|
| `nano-gpt/Salesforce/Llama-xLAM-2-70b-fc-r` | 128K | | | | | | $3 | $3 |
|
|
508
508
|
| `nano-gpt/Sao10K/L3-8B-Stheno-v3.2` | 16K | | | | | | $0.20 | $0.20 |
|
|
509
509
|
| `nano-gpt/Sao10K/L3.1-70B-Euryale-v2.2` | 20K | | | | | | $0.31 | $0.36 |
|
|
@@ -179,17 +179,22 @@ Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
|
179
179
|
|
|
180
180
|
#### `observe(runId, options?)`
|
|
181
181
|
|
|
182
|
-
Reconnects to an existing run
|
|
182
|
+
Reconnects to an existing run. Use this after a network disconnection. For the supported general reconnect flow, omit `offset` to replay all available cached events before receiving live events.
|
|
183
183
|
|
|
184
184
|
```typescript
|
|
185
|
-
const { output
|
|
186
|
-
offset: 0,
|
|
185
|
+
const { output } = await durableAgent.observe(runId, {
|
|
187
186
|
onChunk: chunk => console.log(chunk),
|
|
188
187
|
})
|
|
189
188
|
|
|
190
189
|
await output.text
|
|
191
190
|
```
|
|
192
191
|
|
|
192
|
+
The `offset` option is an inclusive, zero-based PubSub event index. It counts every cached event published to the run topic, including lifecycle events, so it isn't a chunk count. Public stream chunks and callbacks don't expose the PubSub index. Only pass an offset when another integration already tracks the transport position.
|
|
193
|
+
|
|
194
|
+
A non-zero offset can skip earlier events. Aggregated values are built only from chunks delivered to that observer. If the offset skips earlier text deltas, `output.text` is partial and structured output may be incomplete or fail validation or parsing.
|
|
195
|
+
|
|
196
|
+
When the PubSub transport supports numeric offsets, an offset beyond the highest retained index replays nothing and also skips live events with lower indexes. The observer receives events only when the published index reaches the requested offset. If the index counter restarts below that offset, the observer can wait indefinitely. On a transport without numeric offset support, providing an offset starts with new live events and doesn't replay cached events. Replay is limited to events still available in the configured cache. Events can't be replayed when caching is disabled, `shouldCache` excludes the run topic, a cache write fails, or retained events have been cleared.
|
|
197
|
+
|
|
193
198
|
By default `observe()` waits indefinitely for events. If the process running the run stops unexpectedly, the run stops producing events but never emits a completion event, so the observed stream would wait forever. Pass `idleTimeoutMs` to end the stream after a bounded period of silence. Before timing out, `observe()` can consult an optional `isAlive` check. Return `true` while work continues, such as during a long-running tool call or a pause for human input. A `false` result ends the stream with an error, as does omitting `isAlive`. A transient throw from `isAlive` is treated as "still alive", so a momentary check failure never ends a live stream.
|
|
194
199
|
|
|
195
200
|
```typescript
|
|
@@ -95,7 +95,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
95
95
|
|
|
96
96
|
**observation.activateOnProviderChange** (`boolean`): Force buffered observations to activate when the actor provider or model changes. If unset, the top-level activateOnProviderChange value is used for observations. Currently only applied when using the standalone ObservationalMemory class; new Memory(...) applies the top-level activateOnProviderChange only.
|
|
97
97
|
|
|
98
|
-
**observation.blockAfter** (`number`): Safety net for when background buffering can't keep up. Values from 1 up to (but not including) 100 are multipliers of messageTokens: 1.2 resolves to 120% of the threshold (36k tokens with the default 30k). Values of 100 or more are absolute token counts and must be greater than messageTokens. Above this point, activation uses the smallest set of buffered chunks that reaches the retention target, even when that overshoots the target by more than the usual safeguard allows. It never activates more chunks than are needed to reach the retention target, so it removes only slightly more history than a normal activation. It changes the result only when the retention floor is above roughly 20,000 tokens; with the default bufferActivation (a 6k floor) it has no observable effect. Activation usually keeps a minimum remaining context (the smaller of 1000 tokens or the retention floor), but a single buffered chunk that covers the whole pending window still activates and can leave less. Crossing blockAfter does not trigger a blocking observation. A synchronous (blocking) observation runs when the messageTokens threshold is reached and buffered
|
|
98
|
+
**observation.blockAfter** (`number`): Safety net for when background buffering can't keep up. Values from 1 up to (but not including) 100 are multipliers of messageTokens: 1.2 resolves to 120% of the threshold (36k tokens with the default 30k). Values of 100 or more are absolute token counts and must be greater than messageTokens. Above this point, activation uses the smallest set of buffered chunks that reaches the retention target, even when that overshoots the target by more than the usual safeguard allows. It never activates more chunks than are needed to reach the retention target, so it removes only slightly more history than a normal activation. It changes the result only when the retention floor is above roughly 20,000 tokens; with the default bufferActivation (a 6k floor) it has no observable effect. Activation usually keeps a minimum remaining context (the smaller of 1000 tokens or the retention floor), but a single buffered chunk that covers the whole pending window still activates and can leave less. Crossing blockAfter does not trigger a blocking observation. A synchronous (blocking) observation runs when the messageTokens threshold is reached and activating buffered chunks doesn't bring pending tokens back under it, for example when a large tool result arrives after buffering has stopped. All remaining buffered chunks are activated first, so the synchronous observation only covers messages no chunk has observed. Only relevant when bufferTokens is set. Defaults to 1.2 when async buffering is enabled.
|
|
99
99
|
|
|
100
100
|
**observation.previousObserverTokens** (`number | false`): Optional token budget for the observer's previous-observations context. When set to a number, the observations passed to the Observer agent are tail-truncated to fit within this budget while keeping the newest observations and preserving highlighted 🔴 items when possible. When a buffered reflection is pending, the already-reflected observation lines are automatically replaced with the reflection summary before truncation. Set to 0 to omit previous observations entirely, or false to disable truncation explicitly.
|
|
101
101
|
|
|
@@ -367,7 +367,7 @@ export const agent = new Agent({
|
|
|
367
367
|
|
|
368
368
|
Async buffering is **enabled by default**. It pre-computes observations in the background as the conversation grows: when the `messageTokens` threshold is reached, buffered observations activate instantly with no blocking LLM call.
|
|
369
369
|
|
|
370
|
-
The lifecycle follows **buffer → activate → remove messages → repeat**. Background Observer calls run at `bufferTokens` intervals and produce chunks of observations. At the threshold, activation moves observations into the log and removes raw messages from context. Above `blockAfter`, activation may overshoot the retention target instead of activating fewer chunks. A synchronous observation runs if the threshold
|
|
370
|
+
The lifecycle follows **buffer → activate → remove messages → repeat**. Background Observer calls run at `bufferTokens` intervals and produce chunks of observations. At the threshold, activation moves observations into the log and removes raw messages from context. Above `blockAfter`, activation may overshoot the retention target instead of activating fewer chunks. A synchronous observation runs if pending tokens are still at or above the threshold after all buffered chunks have been activated.
|
|
371
371
|
|
|
372
372
|
Default settings:
|
|
373
373
|
|
|
@@ -10,6 +10,56 @@ Both endpoints use the same authentication as other observability routes and req
|
|
|
10
10
|
|
|
11
11
|
> **Thread grouping is deprecated:** The `group` option remains supported until the next major release. Use [`queryTraceThreads()`](https://mastra.ai/reference/client-js/observability) to retrieve matching thread identities in new code.
|
|
12
12
|
|
|
13
|
+
## Query individual spans through storage
|
|
14
|
+
|
|
15
|
+
The observability domain in DuckDB and the PostgreSQL and ClickHouse v-next stores supports `querySpans(plan)`. It returns individual completed spans across traces, including matching child spans. Check `storage.getFeatures()?.includes('span-query')` before using this optional storage method. Server routes and client SDK support are separate from this storage API.
|
|
16
|
+
|
|
17
|
+
Build the plan in trusted backend code:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { planSpanQuery } from '@mastra/core/storage'
|
|
21
|
+
|
|
22
|
+
const storage = await mastra.getStorage()?.getStore('observability')
|
|
23
|
+
if (!storage?.getFeatures()?.includes('span-query')) {
|
|
24
|
+
throw new Error('This store does not support span queries')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const plan = planSpanQuery({
|
|
28
|
+
timeRange: {
|
|
29
|
+
from: '2026-10-01T00:00:00.000Z',
|
|
30
|
+
to: '2026-10-02T00:00:00.000Z',
|
|
31
|
+
},
|
|
32
|
+
where: {
|
|
33
|
+
op: 'eq',
|
|
34
|
+
left: { path: 'spanType' },
|
|
35
|
+
right: { literal: 'tool_call' },
|
|
36
|
+
},
|
|
37
|
+
page: { limit: 50 },
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const { spans, page } = await storage.querySpans(plan)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This example uses local, unscoped storage. For a shared database, pass `{ scope: { organizationId, resourceId } }` as the second argument to `planSpanQuery()`, using identifiers resolved by your backend's authorization. The request body can't supply trusted scope. Apply the same authorization when loading full span details with `getSpan({ traceId, spanId })`.
|
|
44
|
+
|
|
45
|
+
Span queries use the scalar fields and operators available inside `queryTraces()`'s `spans.some` predicate. They don't accept related-record clauses. Nested attributes require support in the shared predicate contract and each store.
|
|
46
|
+
|
|
47
|
+
The `timeRange` applies to each span's `startedAt`, includes `from`, excludes `to`, and can cover at most 31 days. Sort by `startedAt` or `endedAt`, in either direction. The default is `startedAt` descending. A page contains up to 1,000 rows, with a default of 100. Pass `page.next` back as `page.after` with the same filters, time range, scope, and ordering. Cursors use scope and span identifiers to break timestamp ties. They aren't a snapshot across requests. New completions can appear when the view is refreshed.
|
|
48
|
+
|
|
49
|
+
Each row contains span and trace identifiers, display fields, duration, status, and input/output previews of at most 256 Unicode characters. Truncation flags indicate when a preview is incomplete. Stores select the page before loading previews and cost. Full payloads remain available through the existing span detail method.
|
|
50
|
+
|
|
51
|
+
The `cost` field describes only that span's model-token cost:
|
|
52
|
+
|
|
53
|
+
- `available` includes `amount` and `currency`. Zero is a valid amount.
|
|
54
|
+
- `missing` means no matching model metrics were found.
|
|
55
|
+
- `unavailable` means metrics exist but a complete, unambiguous cost can't be established.
|
|
56
|
+
|
|
57
|
+
Directional token totals supply the cost. Overlapping detail metrics aren't added again. A provider-supplied `query_total` cost is counted once. Partial pricing, conflicting currencies, and ambiguous totals produce `unavailable`.
|
|
58
|
+
|
|
59
|
+
Current-record selection runs before mutable filters. PostgreSQL and ClickHouse select the greatest completed `endedAt`. PostgreSQL breaks ties with its ingestion cursor. DuckDB reconstructs the earliest start event and selects the latest ingested completed event, matching its existing span-predicate behavior. Time bounds are checked again after reconstruction. ClickHouse uses its existing completion-only, insert-only model, where equal-version retries must contain identical records. Querying spans doesn't add a table or materialized view.
|
|
60
|
+
|
|
61
|
+
Queries have a 15-second default execution deadline. PostgreSQL and ClickHouse use their existing `traceQuery.timeoutMs` setting. ClickHouse also caps each query at 512 MiB. A page with more than 50,000 matching model metrics fails with a resource-limit error instead of returning partial cost. A small page size limits returned rows, but doesn't limit the number of records the database must examine.
|
|
62
|
+
|
|
13
63
|
## Query traces with the client SDK
|
|
14
64
|
|
|
15
65
|
Pass the query to `queryTraces()`:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.5-alpha.
|
|
3
|
+
"version": "1.3.5-alpha.8",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"local-pkg": "^1.1.2",
|
|
28
28
|
"zod": "^4.6.4",
|
|
29
29
|
"@mastra/mcp": "^2.2.0-alpha.0",
|
|
30
|
-
"@mastra/core": "1.75.0-alpha.
|
|
30
|
+
"@mastra/core": "1.75.0-alpha.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@hono/node-server": "^2.0.0",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
45
|
"vitest": "4.1.11",
|
|
46
46
|
"@internal/lint": "0.0.140",
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
47
|
+
"@internal/types-builder": "0.0.115",
|
|
48
|
+
"@mastra/core": "1.75.0-alpha.3"
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://mastra.ai",
|
|
51
51
|
"repository": {
|