@mastra/mcp-docs-server 1.3.6 → 1.3.7-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/.docs/docs/agents/guardrails.md +2 -2
  2. package/.docs/docs/auth/fga.md +0 -1
  3. package/.docs/docs/deployment/workers.md +1 -1
  4. package/.docs/docs/evals/datasets.md +5 -6
  5. package/.docs/docs/evals/gates-and-verdicts.md +3 -3
  6. package/.docs/docs/mastra-platform/deploy.md +8 -1
  7. package/.docs/docs/mastra-platform/system-environment-variables.md +1 -1
  8. package/.docs/docs/mastra-platform/trace-intelligence.md +1 -1
  9. package/.docs/docs/mastra-platform/workspaces.md +2 -2
  10. package/.docs/docs/memory/multi-user-threads.md +1 -1
  11. package/.docs/docs/memory/observational-memory.md +17 -15
  12. package/.docs/docs/observability/metrics/overview.md +1 -1
  13. package/.docs/docs/observability/tracing/overview.md +6 -0
  14. package/.docs/docs/sandbox/computer.md +13 -13
  15. package/.docs/docs/sandbox/overview.md +5 -5
  16. package/.docs/docs/server/custom-adapters.md +1 -1
  17. package/.docs/docs/server/server-adapters.md +1 -1
  18. package/.docs/docs/studio/auth.md +1 -1
  19. package/.docs/docs/workflows/control-flow.md +28 -0
  20. package/.docs/docs/workflows/time-travel.md +1 -1
  21. package/.docs/integrations/databases/clickhouse.md +13 -0
  22. package/.docs/integrations/observability/langfuse.md +8 -0
  23. package/.docs/integrations/observability/opentelemetry.md +2 -0
  24. package/.docs/models/gateways/vercel.md +1 -8
  25. package/.docs/models/index.md +1 -1
  26. package/.docs/models/providers/edenai.md +4 -3
  27. package/.docs/models/providers/kilo.md +6 -6
  28. package/.docs/models/providers/llmgateway-providers.md +1 -2
  29. package/.docs/models/providers/nano-gpt.md +24 -24
  30. package/.docs/models/providers/nearai.md +6 -1
  31. package/.docs/reference/auth/better-auth.md +1 -1
  32. package/.docs/reference/auth/clerk.md +1 -1
  33. package/.docs/reference/auth/neon.md +2 -2
  34. package/.docs/reference/datasets/compareExperiments.md +18 -9
  35. package/.docs/reference/datasets/dataset.md +3 -1
  36. package/.docs/reference/datasets/finalizeExperiment.md +2 -2
  37. package/.docs/reference/datasets/listExperiments.md +2 -2
  38. package/.docs/reference/datasets/submitExperimentResult.md +1 -1
  39. package/.docs/reference/editor/tools.md +11 -3
  40. package/.docs/reference/evals/completeness.md +3 -3
  41. package/.docs/reference/evals/context-precision.md +1 -1
  42. package/.docs/reference/evals/create-scorer.md +3 -7
  43. package/.docs/reference/evals/faithfulness.md +6 -4
  44. package/.docs/reference/evals/filter-run.md +2 -2
  45. package/.docs/reference/evals/trajectory-accuracy.md +3 -2
  46. package/.docs/reference/index.md +0 -1
  47. package/.docs/reference/memory/listThreads.md +1 -1
  48. package/.docs/reference/memory/observational-memory.md +3 -3
  49. package/.docs/reference/migrations/mcp-v2.md +2 -2
  50. package/.docs/reference/migrations/upgrade-to-v1/agent.md +1 -1
  51. package/.docs/reference/migrations/vnext-to-standard-apis.md +1 -1
  52. package/.docs/reference/observability/feedback.md +1 -1
  53. package/.docs/reference/observability/metrics/automatic-metrics.md +11 -1
  54. package/.docs/reference/observability/tracing/interfaces.md +26 -0
  55. package/.docs/reference/observability/tracing/spans.md +2 -0
  56. package/.docs/reference/processors/moderation-processor.md +1 -1
  57. package/.docs/reference/processors/prompt-injection-detector.md +2 -2
  58. package/.docs/reference/processors/provider-history-compat.md +12 -8
  59. package/.docs/reference/processors/regex-filter-processor.md +1 -1
  60. package/.docs/reference/processors/system-prompt-scrubber.md +3 -3
  61. package/.docs/reference/processors/token-limiter-processor.md +2 -2
  62. package/.docs/reference/rag/graph-rag.md +1 -1
  63. package/.docs/reference/server/create-route.md +1 -1
  64. package/.docs/reference/server/elysia-adapter.md +1 -1
  65. package/.docs/reference/server/express-adapter.md +1 -1
  66. package/.docs/reference/server/fastify-adapter.md +1 -1
  67. package/.docs/reference/server/hono-adapter.md +2 -2
  68. package/.docs/reference/server/koa-adapter.md +1 -1
  69. package/.docs/reference/server/nestjs-adapter.md +1 -1
  70. package/.docs/reference/server/routes.md +1 -1
  71. package/.docs/reference/storage/composite.md +34 -0
  72. package/.docs/reference/storage/overview.md +3 -3
  73. package/.docs/reference/streaming/agents/MastraModelOutput.md +1 -1
  74. package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
  75. package/.docs/reference/streaming/workflows/timeTravelStream.md +6 -4
  76. package/.docs/reference/tools/document-chunker-tool.md +8 -8
  77. package/.docs/reference/tools/mcp-client.md +1 -1
  78. package/.docs/reference/tools/mcp-server.md +17 -0
  79. package/.docs/reference/tools/submit-plan-tool.md +2 -0
  80. package/.docs/reference/tools/vector-query-tool.md +4 -4
  81. package/.docs/reference/vectors/astra.md +1 -1
  82. package/.docs/reference/vectors/azure-ai-search.md +1 -0
  83. package/.docs/reference/vectors/chroma.md +9 -5
  84. package/.docs/reference/vectors/convex.md +1 -3
  85. package/.docs/reference/vectors/couchbase.md +4 -9
  86. package/.docs/reference/vectors/duckdb.md +1 -1
  87. package/.docs/reference/vectors/libsql.md +1 -1
  88. package/.docs/reference/vectors/mongodb.md +2 -1
  89. package/.docs/reference/vectors/pg.md +16 -11
  90. package/.docs/reference/vectors/pinecone.md +8 -4
  91. package/.docs/reference/vectors/qdrant.md +8 -4
  92. package/.docs/reference/vectors/s3vectors.md +8 -4
  93. package/.docs/reference/vectors/turbopuffer.md +12 -6
  94. package/.docs/reference/vectors/upstash.md +10 -4
  95. package/.docs/reference/vectors/vectorize.md +7 -3
  96. package/.docs/reference/vectors/weaviate.md +1 -1
  97. package/.docs/reference/voice/composite-voice.md +15 -15
  98. package/.docs/reference/voice/mastra-voice.md +15 -11
  99. package/.docs/reference/voice/voice.addInstructions.md +1 -1
  100. package/.docs/reference/voice/voice.addTools.md +1 -1
  101. package/.docs/reference/voice/voice.answer.md +1 -1
  102. package/.docs/reference/voice/voice.close.md +1 -1
  103. package/.docs/reference/voice/voice.events.md +2 -2
  104. package/.docs/reference/voice/voice.listen.md +1 -1
  105. package/.docs/reference/voice/voice.off.md +1 -1
  106. package/.docs/reference/voice/voice.on.md +1 -1
  107. package/.docs/reference/voice/voice.send.md +2 -2
  108. package/.docs/reference/voice/voice.updateConfig.md +1 -1
  109. package/.docs/reference/workflows/dynamic-workflow-definition.md +3 -2
  110. package/.docs/reference/workflows/run-methods/cancel.md +1 -2
  111. package/.docs/reference/workflows/run-methods/resume.md +2 -0
  112. package/.docs/reference/workflows/run-methods/timeTravel.md +27 -0
  113. package/.docs/reference/workflows/run.md +14 -0
  114. package/.docs/reference/workflows/workflow-methods/agent.md +1 -1
  115. package/.docs/reference/workflows/workflow-methods/branch.md +4 -4
  116. package/.docs/reference/workflows/workflow-methods/classifier.md +1 -1
  117. package/.docs/reference/workflows/workflow-methods/create-run.md +2 -2
  118. package/.docs/reference/workflows/workflow-methods/dountil.md +1 -1
  119. package/.docs/reference/workflows/workflow-methods/dowhile.md +1 -1
  120. package/.docs/reference/workflows/workflow-methods/sleepUntil.md +1 -1
  121. package/.docs/reference/workspace/filesystem.md +10 -13
  122. package/.docs/reference/workspace/local-filesystem.md +5 -5
  123. package/.docs/reference/workspace/local-sandbox.md +1 -1
  124. package/.docs/reference/workspace/process-manager.md +2 -2
  125. package/.docs/reference/workspace/workspace-class.md +4 -4
  126. package/package.json +4 -4
  127. package/.docs/reference/agents/getTools.md +0 -31
@@ -66,10 +66,20 @@ The detailed breakdown metrics (everything except `total_input` and `total_outpu
66
66
 
67
67
  ### When cost context is attached
68
68
 
69
- Cost context is attached to token metrics when the provider reports a valid cost for every completed model step or when the embedded pricing registry has a matching entry for the provider and model. Mastra sums the per-step provider costs into one query total. If any completed step lacks a valid reported cost, Mastra uses the pricing registry instead of reporting a partial total. If neither source is available, token metrics are still emitted without cost fields.
69
+ Cost context is attached to token metrics when the provider reports a valid cost for every completed model step or when the pricing registry has a matching entry for the provider and model. Mastra sums the per-step provider costs into one query total. If any completed step lacks a valid reported cost, Mastra uses the pricing registry instead of reporting a partial total. If neither source is available, token metrics are still emitted without cost fields.
70
70
 
71
71
  A caller-supplied `costContext` takes precedence over provider-reported costs and pricing registry estimates. Provider-reported totals use `costMetadata.source: 'provider_reported'`, `costMetadata.scope: 'query_total'`, and `costMetadata.reportedStepCount` to identify the source, scope, and number of completed steps included in the total.
72
72
 
73
+ ### Where prices come from
74
+
75
+ The pricing registry uses model prices from [models.dev](https://models.dev). `@mastra/observability` includes a snapshot of these prices, and each new release of the package includes recent prices. Stored cost estimates aren't recalculated when prices change.
76
+
77
+ When you run `mastra dev`, Mastra also refreshes prices from models.dev in the background once a day, and when a model has no price. Cost estimates don't wait for a refresh, so the first call to a newly released model can still have no cost. In other environments, such as production, you can turn on the refresh with `MASTRA_AUTO_REFRESH_PRICING=true`.
78
+
79
+ Refreshed prices are cached in `~/.cache/mastra/pricing-data.json` and reused by later processes. If a refresh fails, Mastra keeps the prices it already has.
80
+
81
+ To use only the bundled snapshot, set `MASTRA_AUTO_REFRESH_PRICING=false`. Setting `MASTRA_OFFLINE=true` also turns off the refresh.
82
+
73
83
  ### What cost fields may be included
74
84
 
75
85
  | Field | Description |
@@ -216,6 +216,9 @@ interface Span<TType extends SpanType> {
216
216
  /** Tags for categorizing traces (only present on root spans) */
217
217
  tags?: string[]
218
218
 
219
+ /** Spans in other traces this span is related to */
220
+ links?: SpanLink[]
221
+
219
222
  /** End the span */
220
223
  end(options?: EndSpanOptions<TType>): void
221
224
 
@@ -778,6 +781,12 @@ interface MCPServerRequestAttributes {
778
781
 
779
782
  /** Client implementation version, when the client reported one */
780
783
  clientVersion?: string
784
+
785
+ /** W3C `traceparent` the caller sent, when it parses */
786
+ callerTraceparent?: string
787
+
788
+ /** W3C `tracestate` the caller sent with a valid `traceparent`, capped at 512 characters */
789
+ callerTracestate?: string
781
790
  }
782
791
  ```
783
792
 
@@ -998,6 +1007,23 @@ interface StartSpanOptions<TType extends SpanType> {
998
1007
 
999
1008
  /** Options passed when using a custom sampler strategy */
1000
1009
  customSamplerOptions?: CustomSamplerOptions
1010
+
1011
+ /** Spans in other traces this span is related to. Links with invalid IDs are ignored. */
1012
+ links?: SpanLink[]
1013
+ }
1014
+ ```
1015
+
1016
+ ### `SpanLink`
1017
+
1018
+ A reference to a span in another trace, such as the caller's span when an `MCPServer` serves a request. Unlike a parent, a link doesn't put the two spans in the same trace.
1019
+
1020
+ ```typescript
1021
+ interface SpanLink {
1022
+ /** Trace ID of the linked span (1-32 hexadecimal characters) */
1023
+ traceId: string
1024
+
1025
+ /** Span ID of the linked span (1-16 hexadecimal characters) */
1026
+ spanId: string
1001
1027
  }
1002
1028
  ```
1003
1029
 
@@ -207,6 +207,8 @@ When tracing is disabled (sampling returns false), NO-OP spans are returned:
207
207
  class NoOpSpan<TType extends SpanType> extends BaseSpan<TType>
208
208
  ```
209
209
 
210
+ `NoOpSpan` is exported from `@mastra/observability`. It extends that package's abstract `BaseSpan` class, which implements the `Span` interface. That class is different from the `BaseSpan` interface described on this page.
211
+
210
212
  A span that performs no operations. All methods are no-ops:
211
213
 
212
214
  - `id` returns `'no-op'`
@@ -48,7 +48,7 @@ const processor = new ModerationProcessor({
48
48
 
49
49
  **id** (`string`): Processor identifier set to 'moderation'
50
50
 
51
- **name** (`string`): Optional processor display name
51
+ **name** (`string`): Processor display name, always 'Moderation'
52
52
 
53
53
  **processInput** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise<MastraDBMessage[]>`): Processes input messages to moderate content before sending to LLM
54
54
 
@@ -48,9 +48,9 @@ const processor = new PromptInjectionDetector({
48
48
 
49
49
  **id** (`string`): Processor identifier set to 'prompt-injection-detector'
50
50
 
51
- **name** (`string`): Optional processor display name
51
+ **name** (`string`): Processor display name, always 'Prompt Injection Detector'
52
52
 
53
- **processInput** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise<MastraDBMessage[]>`): Processes input messages to detect prompt injection attempts before sending to LLM
53
+ **processInput** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never; requestContext?: RequestContext; tracingContext?: TracingContext }) => Promise<MastraDBMessage[]>`): Processes input messages to detect prompt injection attempts before sending to LLM
54
54
 
55
55
  ## Extended usage example
56
56
 
@@ -54,14 +54,18 @@ Registering in `errorProcessors` alone, as the example above does, covers both h
54
54
 
55
55
  `ProviderHistoryCompat` includes these built-in compatibility rules:
56
56
 
57
- | Rule | Provider | Timing | Behavior |
58
- | ------------------------------------------- | -------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59
- | `anthropic-tool-id-format` | Anthropic | Preemptive prompt rewrite | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` in the outbound prompt, on both the call and its result. A sanitized ID that would collide with one already in the prompt gets a `_2`, `_3`, … suffix. The provider's rejection never fires, and persisted history keeps the original IDs. A reactive fallback covers providers the preemptive check doesn't recognize, such as Vertex-hosted Claude. |
60
- | `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
61
- | `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
62
- | `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-4-6`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
63
- | `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
64
- | `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, and retries. The message then replays by value instead of as an unsatisfiable `item_reference`. The repair is applied to the in-memory list for the current turn. |
57
+ | Rule | Provider | Timing | Behavior |
58
+ | ------------------------------------------------ | ---------------------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59
+ | `strip-foreign-provider-executed-tools` | Anthropic, OpenAI, Azure OpenAI, Google/Vertex | Preemptive prompt rewrite | Removes provider-executed tool calls and their paired results from the outbound prompt when they came from a different provider family, since the receiving provider can't resolve another provider's tool IDs. Persisted history is left untouched. |
60
+ | `anthropic-tool-id-format` | Anthropic | Preemptive prompt rewrite | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` in the outbound prompt, on both the call and its result. A sanitized ID that would collide with one already in the prompt gets a `_2`, `_3`, … suffix. The provider's rejection never fires, and persisted history keeps the original IDs. A reactive fallback covers providers the preemptive check doesn't recognize, such as Vertex-hosted Claude. |
61
+ | `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
62
+ | `anthropic-strip-empty-signed-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes assistant `reasoning` parts that carry an Anthropic signature but have empty text, which legacy records can contain. Anthropic signs the exact thinking text, so the mismatched pair would be rejected. |
63
+ | `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
64
+ | `anthropic-strip-foreign-signed-reasoning` | Anthropic-compatible | Preemptive prompt rewrite | Drops signed thinking from the outbound prompt when its origin turn was stamped with a different provider (for example Kimi For Coding ↔ `anthropic/claude-sonnet-4-6`), since the receiving provider can't verify another provider's signature. Turns emptied of all content by the drop are removed from the prompt. Unstamped history is left untouched. |
65
+ | `azure-system-reminder-transform` | Azure OpenAI | Preemptive prompt rewrite | Renames `<system-reminder>` wrappers in user text and system instructions to `<memory-context>` for the outbound request. Stored history remains unchanged. |
66
+ | `openai-orphan-item-id` | OpenAI, Azure OpenAI (Responses) | Reactive API error recovery | Recovers history that OpenAI rejects with `Item 'msg_…' of type 'message' was provided without its required 'reasoning' item`. Drops the Responses `itemId` from every item-bearing part of an assistant message that carries one but has no `reasoning` part, and retries. The message then replays by value instead of as an unsatisfiable `item_reference`. The repair is applied to the in-memory list for the current turn. |
67
+ | `anthropic-orphaned-thinking-step` | Anthropic | Reactive API error recovery | Recovers history that Anthropic rejects because `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. Removes steps that contain only reasoning when more assistant content follows them, and retries. Covers history saved by older `@mastra/memory` releases ([#22798](https://github.com/mastra-ai/mastra/issues/22798)). |
68
+ | `ensure-user-first-turn` | Amazon Bedrock, Google/Vertex Gemini | Preemptive prompt rewrite | Inserts a minimal user turn (`.`) before a leading assistant turn, because these providers reject conversations whose first non-system turn is the assistant's. This happens when an agent greets first or `lastMessages` cuts into a thread. Runs last, so it sees the prompt after other rules have dropped emptied turns. |
65
69
 
66
70
  Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call. Persisted history is never changed, so the IDs and content in memory and in the Studio stay exactly as written.
67
71
 
@@ -108,7 +108,7 @@ const agent = new Agent({
108
108
 
109
109
  **name** (`'Regex Filter'`): Processor display name.
110
110
 
111
- **processInput** (`(args: ProcessInputArgs) => ProcessInputResult`): Checks input messages against all configured rules. Blocks, redacts, or warns depending on strategy. Skipped when phase is output.
111
+ **processInput** (`(args: ProcessInputArgs) => ProcessInputResult | Promise<ProcessInputResult>`): Checks input messages against all configured rules. Blocks, redacts, or warns depending on strategy. Skipped when phase is output. Returns a promise when redaction reporting is pending.
112
112
 
113
113
  **processOutputStream** (`(args: ProcessOutputStreamArgs) => Promise<ChunkType | null | undefined>`): Checks streaming text-delta chunks against all configured rules. Skipped when phase is input.
114
114
 
@@ -46,11 +46,11 @@ const processor = new SystemPromptScrubber({
46
46
 
47
47
  **id** (`string`): Processor identifier set to 'system-prompt-scrubber'
48
48
 
49
- **name** (`string`): Optional processor display name
49
+ **name** (`string`): Processor display name, always 'System Prompt Scrubber'
50
50
 
51
- **processOutputStream** (`(args: { part: ChunkType; streamParts: ChunkType[]; state: Record<string, any>; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise<ChunkType | null>`): Processes streaming output parts to detect and handle system prompts during streaming
51
+ **processOutputStream** (`(args: { part: ChunkType; streamParts: ChunkType[]; state: Record<string, any>; abort: (reason?: string) => never; requestContext?: RequestContext; tracingContext?: TracingContext }) => Promise<ChunkType | null>`): Processes streaming output parts to detect and handle system prompts during streaming
52
52
 
53
- **processOutputResult** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never }) => Promise<MastraDBMessage[]>`): Processes final output results to detect and handle system prompts in non-streaming scenarios
53
+ **processOutputResult** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never; requestContext?: RequestContext; tracingContext?: TracingContext }) => Promise<MastraDBMessage[]>`): Processes final output results to detect and handle system prompts in non-streaming scenarios
54
54
 
55
55
  ## Extended usage example
56
56
 
@@ -28,7 +28,7 @@ const processor = new TokenLimiterProcessor({
28
28
 
29
29
  **options.limit** (`number`): Maximum number of tokens to allow in the response
30
30
 
31
- **options.encoding** (`TiktokenBPE`): Optional encoding to use. Defaults to o200k\_base which is used by gpt-5.1
31
+ **options.encoding** (`unknown`): Deprecated. Accepted for backwards compatibility but ignored. Token counts are estimated with tokenx, so no encoder is needed.
32
32
 
33
33
  **options.strategy** (`'truncate' | 'abort'`): Strategy when token limit is reached: 'truncate' stops emitting chunks, 'abort' calls abort() to stop the stream
34
34
 
@@ -40,7 +40,7 @@ const processor = new TokenLimiterProcessor({
40
40
 
41
41
  **id** (`string`): Processor identifier set to 'token-limiter'
42
42
 
43
- **name** (`string`): Optional processor display name
43
+ **name** (`string`): Processor display name set to 'Token Limiter'
44
44
 
45
45
  **processInput** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never }) => Promise<MastraDBMessage[]>`): Trims stored history to fit within the token limit before the agentic loop starts in 'memory-only' trim mode, prioritizing recent messages while preserving system messages and the current turn
46
46
 
@@ -83,7 +83,7 @@ Returns an array of `RankedNode` objects, where each node contains:
83
83
 
84
84
  **content** (`string`): Text content of the document chunk
85
85
 
86
- **metadata** (`Record<string, any>`): Additional metadata associated with the chunk
86
+ **metadata** (`Record<string, any>`): Additional metadata associated with the chunk, when present
87
87
 
88
88
  **score** (`number`): Combined relevance score from graph traversal
89
89
 
@@ -50,7 +50,7 @@ function createRoute<TPath, TQuery, TBody, TResponse, TResponseType>(
50
50
 
51
51
  **deprecated** (`boolean`): Mark route as deprecated
52
52
 
53
- **onValidationError** (`(error: ZodError, context: 'query' | 'body' | 'path') => { status: number; body: unknown } | undefined`): Custom validation error handler for this route. Overrides the server-level onValidationError hook. Return { status, body } to customize the response, or undefined to use the default.
53
+ **onValidationError** (`(error: ZodError, context: 'query' | 'body' | 'path') => { status: number; body: unknown } | undefined | void`): Custom validation error handler for this route. Overrides the server-level onValidationError hook. Return { status, body } to customize the response, or return nothing (undefined) to use the default.
54
54
 
55
55
  ## Handler parameters
56
56
 
@@ -61,7 +61,7 @@ console.log('Server running on http://localhost:3000')
61
61
 
62
62
  **mastra** (`Mastra`): Mastra instance
63
63
 
64
- **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
64
+ **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `'/api'`)
65
65
 
66
66
  **openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
67
67
 
@@ -60,7 +60,7 @@ Express requires `express.json()` middleware for JSON body parsing. Add it befor
60
60
 
61
61
  **mastra** (`Mastra`): Mastra instance
62
62
 
63
- **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
63
+ **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `'/api'`)
64
64
 
65
65
  **openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
66
66
 
@@ -63,7 +63,7 @@ app.listen({ port: 3000 }, (err, address) => {
63
63
 
64
64
  **mastra** (`Mastra`): Mastra instance
65
65
 
66
- **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
66
+ **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `'/api'`)
67
67
 
68
68
  **openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
69
69
 
@@ -57,7 +57,7 @@ export default app
57
57
 
58
58
  **mastra** (`Mastra`): Mastra instance
59
59
 
60
- **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
60
+ **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `'/api'`)
61
61
 
62
62
  **openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
63
63
 
@@ -142,7 +142,7 @@ Available context keys:
142
142
  | `mastra` | Mastra instance |
143
143
  | `requestContext` | Request context map |
144
144
  | `abortSignal` | Request cancellation signal |
145
- | `tools` | Available tools |
145
+ | `registeredTools` | Tools registered with the adapter |
146
146
  | `taskStore` | Task store for A2A operations |
147
147
  | `customRouteAuthConfig` | Per-route auth overrides |
148
148
  | `user` | Authenticated user (if auth configured) |
@@ -62,7 +62,7 @@ app.listen(3000, () => {
62
62
 
63
63
  **mastra** (`Mastra`): Mastra instance
64
64
 
65
- **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `''`)
65
+ **prefix** (`string`): Route path prefix (e.g., /api/v2) (Default: `'/api'`)
66
66
 
67
67
  **openapiPath** (`string`): Path to serve OpenAPI spec (e.g., /openapi.json) (Default: `''`)
68
68
 
@@ -89,7 +89,7 @@ By default, Mastra routes mount under `/api`. Use `prefix` to change it.
89
89
 
90
90
  **customRouteAuthConfig** (`Map<string, boolean>`): Per-route auth overrides. Keys are METHOD:PATH. Custom routes from server.apiRoutes (registerApiRoute()) are added automatically based on their requiresAuth setting.
91
91
 
92
- **tools** (`Record<string, Tool>`): Registered tools for the server
92
+ **tools** (`ToolsInput`): Additional tools to register. Accepts Mastra tools, Vercel AI SDK tools, provider-defined tools, and web search tools.
93
93
 
94
94
  **taskStore** (`InMemoryTaskStore`): Task store for A2A (Agent-to-Agent) operations
95
95
 
@@ -416,7 +416,7 @@ On authenticated servers, the read routes require the `stored-workflows:read` pe
416
416
  | `PATCH` | `/api/datasets/:datasetId/experiments/:experimentId` | Update an experiment's name, description or metadata |
417
417
  | `DELETE` | `/api/datasets/:datasetId/experiments/:experimentId` | Delete an experiment that belongs to the dataset |
418
418
  | `GET` | `/api/datasets/:datasetId/experiments/:experimentId/results` | List experiment results |
419
- | `POST` | `/api/datasets/:datasetId/compare` | Compare two experiments |
419
+ | `POST` | `/api/datasets/:datasetId/compare` | Compare two to ten experiments |
420
420
 
421
421
  ### Delete an experiment
422
422
 
@@ -210,6 +210,40 @@ export const mastra = new Mastra({
210
210
 
211
211
  **domains.experiments** (`ExperimentsStorage`): Storage for experiment runs and per-item experiment results.
212
212
 
213
+ **domains.workflowDefinitions** (`WorkflowDefinitionsStorage`): Storage for persisted workflow definitions.
214
+
215
+ **domains.promptBlocks** (`PromptBlocksStorage`): Storage for stored prompt blocks and their versions.
216
+
217
+ **domains.scorerDefinitions** (`ScorerDefinitionsStorage`): Storage for stored scorer definitions and their versions.
218
+
219
+ **domains.mcpClients** (`MCPClientsStorage`): Storage for stored MCP client configurations and their versions.
220
+
221
+ **domains.mcpServers** (`MCPServersStorage`): Storage for stored MCP server configurations and their versions.
222
+
223
+ **domains.workspaces** (`WorkspacesStorage`): Storage for stored workspace configurations and their versions.
224
+
225
+ **domains.skills** (`SkillsStorage`): Storage for stored skill definitions and their versions.
226
+
227
+ **domains.favorites** (`FavoritesStorage`): Storage for user favorites on stored entities.
228
+
229
+ **domains.blobs** (`BlobStore`): Content-addressable storage for file contents used by skill versioning.
230
+
231
+ **domains.backgroundTasks** (`BackgroundTasksStorage`): Storage for background task state.
232
+
233
+ **domains.schedules** (`SchedulesStorage`): Storage for schedules that the scheduler fires.
234
+
235
+ **domains.channels** (`ChannelsStorage`): Storage for channel installations and configuration.
236
+
237
+ **domains.harness** (`HarnessStorage`): Storage for harness sessions.
238
+
239
+ **domains.toolProviderConnections** (`ToolProviderConnectionsStorage`): Storage for authorized tool provider connections.
240
+
241
+ **domains.notifications** (`NotificationsStorage`): Storage for notifications and their delivery state.
242
+
243
+ **domains.threadState** (`ThreadStateStorage`): Storage for per-thread agent state, such as task lists and goals.
244
+
245
+ **domains.knowledge** (`KnowledgeStorage`): Storage for knowledge nodes and records. Experimental.
246
+
213
247
  ## Initialization
214
248
 
215
249
  `MastraCompositeStore` initializes each configured domain independently. When passed to the Mastra class, `init()` is called automatically:
@@ -30,7 +30,7 @@ The schema definitions below cover the built-in database-backed tables documente
30
30
 
31
31
  Stores conversation messages and their metadata. Each message belongs to a thread and contains the actual content along with metadata about the sender role and message type.
32
32
 
33
- iduuidv4PRIMARYKEYNOT NULLUnique identifier for the message (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)thread\_iduuidv4FK → threads.idNOT NULLParent thread referenceresourceIduuidv4CAN BE NULLID of the resource that owns this messagecontenttextNOT NULLJSON of the message content in V2 format. Example: `{ format: 2, parts: [...] }`roletextNOT NULLEnum of `user | assistant`createdAttimestampNOT NULLUsed for thread message ordering
33
+ idtextPRIMARYKEYNOT NULLUnique identifier for the messagethread\_idtextFK → threads.idNOT NULLParent thread referenceresourceIdtextCAN BE NULLID of the resource that owns this messagecontenttextNOT NULLJSON of the message content in V2 format. Example: `{ format: 2, parts: [...] }`roletextNOT NULLEnum of `user | assistant`createdAttimestampNOT NULLUsed for thread message ordering
34
34
 
35
35
  The message `content` column contains a JSON object conforming to the `MastraMessageContentV2` type, which is designed to align closely with the AI SDK `UIMessage` message shape.
36
36
 
@@ -40,7 +40,7 @@ formatintegerNOT NULLMessage format version (currently 2)partsarray (JSON)NOT NU
40
40
 
41
41
  Groups related messages together and associates them with a resource. Contains metadata about the conversation.
42
42
 
43
- iduuidv4PRIMARYKEYNOT NULLUnique identifier for the thread (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)resourceIdtextNOT NULLPrimary identifier of the external resource this thread is associated with. Used to group and retrieve related threads.titletextNOT NULLTitle of the conversation threadmetadatatextCustom thread metadata as stringified JSON. Example:
43
+ idtextPRIMARYKEYNOT NULLUnique identifier for the threadresourceIdtextNOT NULLPrimary identifier of the external resource this thread is associated with. Used to group and retrieve related threads.titletextNOT NULLTitle of the conversation threadmetadatajsonbCAN BE NULLCustom thread metadata as JSON. Example:
44
44
 
45
45
  ```json
46
46
  {
@@ -76,7 +76,7 @@ createdAttimestampNOT NULLWhen the resource record was first createdupdatedAttim
76
76
 
77
77
  When `suspend()` is called on a workflow, its state is saved in the following format. When `resume()` is called, that state is rehydrated.
78
78
 
79
- workflow\_nametextNOT NULLName of the workflowrun\_iduuidv4NOT NULLUnique identifier for the workflow execution. Used to track state across suspend/resume cycles (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)snapshottextNOT NULLSerialized workflow state as JSON. Example:
79
+ workflow\_nametextNOT NULLName of the workflowrun\_idtextNOT NULLUnique identifier for the workflow execution. Used to track state across suspend/resume cyclessnapshotjsonbNOT NULLWorkflow state as JSON. Example:
80
80
 
81
81
  ```json
82
82
  {
@@ -101,7 +101,7 @@ These properties resolve to final values after the stream completes:
101
101
 
102
102
  ## Error properties
103
103
 
104
- **error** (`string | Error | { message: string; stack: string; } | undefined`): Error information if the stream encountered an error. Undefined if no errors occurred. Can be a string message, Error object, or serialized error with stack trace.
104
+ **error** (`Error | undefined`): Error object if the stream encountered an error. Undefined if no errors occurred.
105
105
 
106
106
  ## Methods
107
107
 
@@ -66,7 +66,7 @@ Internally, `streamUntilIdle()`:
66
66
 
67
67
  1. Runs the initial turn via `agent.stream(...)` and pipes its `fullStream` into the outer stream.
68
68
  2. Subscribes to background-task completion events for the resolved memory scope.
69
- 3. Queues each terminal event (`background-task-completed`, `background-task-failed`, `background-task-cancelled`) and, when the outer wrapper is idle between turns, re-invokes `agent.stream([], ...)` with a directive listing the completed `toolCallId`s. The continuation turn flows into the same outer stream.
69
+ 3. Queues each terminal event (`background-task-completed`, `background-task-failed`, `background-task-cancelled`, `background-task-suspended`) and, when the outer wrapper is idle between turns, re-invokes `agent.stream([], ...)` with a directive listing the completed `toolCallId`s. The continuation turn flows into the same outer stream.
70
70
  4. Closes the outer stream once no tasks are running and no completions are queued.
71
71
 
72
72
  ## Extended usage example
@@ -37,14 +37,16 @@ All parameters are the same as [`Run.timeTravel()`](https://mastra.ai/reference/
37
37
 
38
38
  **output.result** (`Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>`): A promise that resolves to the final workflow execution result
39
39
 
40
- **output.traceId** (`string`): The trace ID associated with this execution when Tracing is enabled
40
+ **output.runId** (`string`): The ID of the workflow run
41
+
42
+ **output.workflowId** (`string`): The ID of the workflow
41
43
 
42
44
  ## Stream events
43
45
 
44
46
  The stream emits workflow events during execution:
45
47
 
46
48
  - `workflow-step-start`: Emitted when a step begins execution
47
- - `workflow-step-finish`: Emitted when a step completes successfully
49
+ - `workflow-step-result`: Emitted when a step produces a result
48
50
  - `workflow-step-error`: Emitted when a step encounters an error
49
51
  - `workflow-step-suspended`: Emitted when a step suspends
50
52
  - Additional events depending on step types (agents, tools, etc.)
@@ -66,8 +68,8 @@ for await (const event of output.fullStream) {
66
68
  case 'workflow-step-start':
67
69
  console.log(`Starting step: ${event.payload.stepName}`)
68
70
  break
69
- case 'workflow-step-finish':
70
- console.log(`Completed step: ${event.payload.stepName}`)
71
+ case 'workflow-step-result':
72
+ console.log(`Completed step: ${event.payload.id}`)
71
73
  break
72
74
  case 'workflow-step-error':
73
75
  console.error(`Error in step: ${event.payload.stepName}`, event.payload.error)
@@ -20,9 +20,9 @@ const chunker = createDocumentChunkerTool({
20
20
  doc: document,
21
21
  params: {
22
22
  strategy: 'recursive',
23
- size: 512,
23
+ maxSize: 512,
24
24
  overlap: 50,
25
- separator: '\n',
25
+ separators: ['\n'],
26
26
  },
27
27
  })
28
28
 
@@ -39,11 +39,11 @@ const { chunks } = await chunker.execute()
39
39
 
40
40
  **strategy** (`'recursive'`): The chunking strategy to use (Default: `'recursive'`)
41
41
 
42
- **size** (`number`): Target size of each chunk in tokens/characters (Default: `512`)
42
+ **maxSize** (`number`): Maximum size of each chunk in tokens/characters (Default: `512`)
43
43
 
44
44
  **overlap** (`number`): Number of overlapping tokens/characters between chunks (Default: `50`)
45
45
 
46
- **separator** (`string`): Character(s) to use as chunk separator (Default: `'\n'`)
46
+ **separators** (`string[]`): Separators to split on, in order of priority (recursive strategy) (Default: `['\n']`)
47
47
 
48
48
  ## Returns
49
49
 
@@ -64,9 +64,9 @@ const chunker = createDocumentChunkerTool({
64
64
  doc: technicalDoc,
65
65
  params: {
66
66
  strategy: 'recursive',
67
- size: 1024, // Larger chunks
67
+ maxSize: 1024, // Larger chunks
68
68
  overlap: 100, // More overlap
69
- separator: '\n\n', // Split on double newlines
69
+ separators: ['\n\n'], // Split on double newlines
70
70
  },
71
71
  })
72
72
 
@@ -82,8 +82,8 @@ chunks.forEach((chunk, index) => {
82
82
 
83
83
  The chunker is created as a Mastra tool with the following properties:
84
84
 
85
- - **Tool ID**: `Document Chunker {strategy} {size}`
86
- - **Description**: `Chunks document using {strategy} strategy with size {size} and {overlap} overlap`
85
+ - **Tool ID**: `Document Chunker {strategy} {maxSize}`
86
+ - **Description**: `Chunks document using {strategy} strategy with maxSize {maxSize} and {overlap} overlap`
87
87
  - **Input Schema**: Empty object (no additional inputs required)
88
88
  - **Output Schema**: Object containing the chunks array
89
89
 
@@ -76,7 +76,7 @@ The client speaks the MCP `2026-07-28` revision. On connect it asks the server w
76
76
 
77
77
  **enableProgressTracking** (`boolean`): Whether to send a progressToken with tool calls so the server can report progress. See the progress property. (Default: `false`)
78
78
 
79
- **traceContext** (`() => MCPTraceContext | undefined`): Returns the W3C traceparent, optional tracestate and baggage to send as request \_meta on every call to this server. Called when each request is sent so it can read a request-local carrier. Explicit \_meta keys on a tool call take precedence. Servers built with MCPServer expose the received values to tools as requestContext.get("traceContext"); they are observability data and are never used for authorization.
79
+ **traceContext** (`() => MCPTraceContext | undefined`): Returns the W3C traceparent, optional tracestate and baggage to send as request \_meta on every call to this server. Called when each request is sent so it can read a request-local carrier. Without this option, a tool call made by a traced agent or workflow sends the traceparent of its tool call span. When the reply names the server span that handled the call, as MCPServer does, the tool call span links to it. Set this option to send your own trace context, or return undefined to send none. Explicit \_meta keys on a tool call take precedence. Servers built with MCPServer link their request span to the span the traceparent names and expose the received values to tools as requestContext.get("traceContext"); they are observability data and are never used for authorization.
80
80
 
81
81
  **forwardInstructions** (`boolean`): Whether to append instructions advertised by this MCP server to an agent's system prompt when the agent uses this server's tools. Disabled by default; enable it only for servers you trust, since the instructions are injected into the agent's system prompt. (Default: `false`)
82
82
 
@@ -856,6 +856,23 @@ The span is named after the method and target (for example `tools/call lookupOrd
856
856
 
857
857
  A standalone `MCPServer` with no `mastra` instance produces no spans.
858
858
 
859
+ ### Linking to the caller's trace
860
+
861
+ A request that carries a W3C `traceparent` keeps its own trace, root span, and trace summary. Its request span links to the caller's span, so you can follow a tool call from the caller's trace to the request it started.
862
+
863
+ With a tracing bridge, the request span starts under the span that's active when the request arrives. If HTTP instrumentation on the server continues the caller's trace from the `traceparent` header, the request joins the caller's trace instead of starting its own. Its link then points to a span in the same trace.
864
+
865
+ The server reads `traceparent` and `tracestate` from two places, in this order:
866
+
867
+ 1. The request `_meta`. `MCPClient` sends `traceparent` there for every traced tool call an agent or workflow makes, over HTTP and stdio.
868
+ 2. The HTTP headers. OpenTelemetry HTTP instrumentation in a non-Mastra caller sends them there.
869
+
870
+ The request span also records a valid `traceparent` as the `callerTraceparent` attribute, and the `tracestate` sent with it as `callerTracestate`, capped at 512 characters. Exporters without span link support still carry these attributes. A request without a valid `traceparent` gets no link and no caller attributes. The trace fields are left out of the span input.
871
+
872
+ The link also works in the other direction. When a `tools/call` request carried a `traceparent`, the reply's `_meta.mastra.traceparent` names the request span, and `MCPClient` adds a link from its tool call span to it. Callers that sent no trace context get nothing back.
873
+
874
+ Mastra storage saves the links with the spans. The OpenTelemetry exporter, [`OtelBridge`](https://mastra.ai/integrations/observability/opentelemetry), `DatadogBridge`, `DatadogExporter`, and `SentryExporter` send them as span links. `DatadogExporter` and `SentryExporter` give spans their own IDs, so a link between two Mastra spans doesn't resolve in those backends.
875
+
859
876
  ## Notification delivery
860
877
 
861
878
  Request-scoped notifications (`context.mcp.log()`, `context.mcp.progress()`) stream inside the request that triggered them, so they reach exactly the caller. Notifications that outlive a request (`resources.notifyListChanged()`, `prompts.notifyListChanged()`, `toolActions.notifyListChanged()`, `resources.notifyUpdated()`) are delivered on the `subscriptions/listen` stream each interested client keeps open. `resources.notifyUpdated()` only reaches clients whose stream includes that resource URI. List-changed notifications reach every client listening for that list. Over stdio the connection itself carries the stream.
@@ -66,6 +66,8 @@ The model calls this tool with the following parameters:
66
66
 
67
67
  The `tool-call-suspended` event carries a `suspendPayload`:
68
68
 
69
+ **toolId** (`'submit_plan'`): ID of the tool that suspended the run.
70
+
69
71
  **path** (`string`): Path to the plan file the agent wrote.
70
72
 
71
73
  **title** (`string`): Plan title, filled by the host after reading the file.
@@ -21,13 +21,13 @@ const queryTool = createVectorQueryTool({
21
21
 
22
22
  ## Parameters
23
23
 
24
- > **Note:** **Parameter Requirements:** Most fields can be set at creation as defaults. Some fields can be overridden at runtime via the request context or input. If a required field is missing from both creation and runtime, an error will be thrown. Note that `model`, `id`, and `description` can only be set at creation time.
24
+ > **Note:** **Parameter Requirements:** Most fields can be set at creation as defaults. Some fields can be overridden at runtime via the request context or input. If a required field is missing from both creation and runtime, an error will be thrown. Note that `id` and `description` can only be set at creation time.
25
25
 
26
- **id** (`string`): Custom ID for the tool. By default: 'VectorQuery {vectorStoreName} {indexName} Tool'. (Set at creation only.)
26
+ **id** (`string`): Custom ID for the tool. By default: 'VectorQuery {vectorStoreName} {indexName} Tool', where {vectorStoreName} is 'DirectVectorStore' when a vectorStore instance is passed without a vectorStoreName. (Set at creation only.)
27
27
 
28
28
  **description** (`string`): Custom description for the tool. By default: 'Access the knowledge base to find information needed to answer user questions' (Set at creation only.)
29
29
 
30
- **model** (`EmbeddingModel`): Embedding model to use for vector search. (Set at creation only.)
30
+ **model** (`EmbeddingModel`): Embedding model to use for vector search. (Can be set at creation or overridden at runtime via the request context.)
31
31
 
32
32
  **vectorStoreName** (`string`): Name of the vector store to query. (Can be set at creation or overridden at runtime.)
33
33
 
@@ -47,7 +47,7 @@ const queryTool = createVectorQueryTool({
47
47
 
48
48
  **reranker.options.weights** (`WeightConfig`): Weights for scoring components (semantic: 0.4, vector: 0.4, position: 0.2)
49
49
 
50
- **reranker.options.topK** (`number`): Number of top results to return
50
+ **reranker.options.topK** (`number`): Number of top results to return after reranking. Falls back to the query's topK (from the request context, the tool input, or 10) when unset or 0.
51
51
 
52
52
  **databaseConfig** (`DatabaseConfig`): Database-specific configuration options for optimizing queries. (Can be set at creation or overridden at runtime.)
53
53
 
@@ -110,7 +110,7 @@ try {
110
110
  })
111
111
  } catch (error) {
112
112
  if (error instanceof MastraError) {
113
- console.log(error.id) // 'MASTRA_VECTOR_ASTRA_QUERY_FAILED'
113
+ console.log(error.id) // 'MASTRA_VECTOR_ASTRA_QUERY_DB_ERROR'
114
114
  console.log(error.domain) // 'MASTRA_VECTOR'
115
115
  console.log(error.category) // 'USER' | 'THIRD_PARTY'
116
116
  console.log(error.details) // Additional error context
@@ -141,6 +141,7 @@ interface QueryResult {
141
141
  id: string
142
142
  score: number
143
143
  metadata: Record<string, any>
144
+ document?: string // Matched document content
144
145
  vector?: number[] // Only included if includeVector is true
145
146
  }
146
147
  ```
@@ -86,7 +86,7 @@ Query an index using a `queryVector`. Returns an array of semantically similar r
86
86
  score: number;
87
87
  document?: string;
88
88
  metadata?: Record<string, string | number | boolean>;
89
- embedding?: number[]
89
+ vector?: number[] // Only included if includeVector is true
90
90
  }
91
91
  ```
92
92
 
@@ -147,7 +147,7 @@ Returns:
147
147
  interface IndexStats {
148
148
  dimension: number
149
149
  count: number
150
- metric: 'cosine' | 'euclidean' | 'dotproduct'
150
+ metric?: 'cosine' | 'euclidean' | 'dotproduct'
151
151
  }
152
152
  ```
153
153
 
@@ -247,17 +247,21 @@ interface QueryResult {
247
247
 
248
248
  ## Error handling
249
249
 
250
- The store throws typed errors that can be caught:
250
+ The store throws `MastraError` instances from `@mastra/core/error`:
251
251
 
252
252
  ```typescript
253
+ import { MastraError } from '@mastra/core/error'
254
+
253
255
  try {
254
256
  await store.query({
255
257
  indexName: 'index_name',
256
258
  queryVector: queryVector,
257
259
  })
258
260
  } catch (error) {
259
- if (error instanceof VectorStoreError) {
260
- console.log(error.code) // 'connection_failed' | 'invalid_dimension' | etc
261
+ if (error instanceof MastraError) {
262
+ console.log(error.id) // 'MASTRA_VECTOR_CHROMA_QUERY_FAILED'
263
+ console.log(error.domain) // 'MASTRA_VECTOR'
264
+ console.log(error.category) // 'USER' | 'THIRD_PARTY'
261
265
  console.log(error.details) // Additional error context
262
266
  }
263
267
  }