@mastra/mcp-docs-server 1.3.7-alpha.1 → 1.3.7-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/guardrails.md +2 -2
- package/.docs/docs/auth/fga.md +0 -1
- package/.docs/docs/deployment/workers.md +1 -1
- package/.docs/docs/evals/datasets.md +5 -6
- package/.docs/docs/evals/gates-and-verdicts.md +3 -3
- package/.docs/docs/mastra-platform/deploy.md +8 -1
- package/.docs/docs/mastra-platform/observability.md +25 -19
- package/.docs/docs/mastra-platform/system-environment-variables.md +1 -1
- package/.docs/docs/mastra-platform/trace-intelligence.md +1 -1
- package/.docs/docs/mastra-platform/workspaces.md +2 -2
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +6 -0
- package/.docs/docs/sandbox/computer.md +13 -13
- package/.docs/docs/sandbox/overview.md +5 -5
- package/.docs/docs/server/custom-adapters.md +1 -1
- package/.docs/docs/server/server-adapters.md +1 -1
- package/.docs/docs/studio/auth.md +1 -1
- package/.docs/docs/workflows/control-flow.md +28 -0
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/integrations/databases/clickhouse.md +13 -0
- package/.docs/integrations/observability/langfuse.md +8 -0
- package/.docs/integrations/observability/opentelemetry.md +2 -0
- package/.docs/models/environment-variables.md +2 -1
- package/.docs/models/gateways/merge-gateway.md +2 -1
- package/.docs/models/gateways/netlify.md +5 -1
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/gateways/vercel.md +3 -10
- package/.docs/models/index.md +3 -2
- package/.docs/models/providers/aixy.md +14 -8
- package/.docs/models/providers/chutes.md +4 -4
- package/.docs/models/providers/cloudferro-sherlock.md +2 -2
- package/.docs/models/providers/edenai.md +10 -4
- package/.docs/models/providers/kenari.md +5 -1
- package/.docs/models/providers/kilo.md +10 -9
- package/.docs/models/providers/llmgateway-providers.md +7 -7
- package/.docs/models/providers/llmgateway.md +6 -5
- package/.docs/models/providers/lowrouter.md +16 -12
- package/.docs/models/providers/meta.md +3 -2
- package/.docs/models/providers/nano-gpt.md +21 -21
- package/.docs/models/providers/opencode-go.md +3 -3
- package/.docs/models/providers/opencode.md +5 -5
- package/.docs/models/providers/prime.md +136 -0
- package/.docs/models/providers.md +2 -1
- package/.docs/reference/agent-controller/session.md +30 -8
- package/.docs/reference/auth/better-auth.md +1 -1
- package/.docs/reference/auth/clerk.md +1 -1
- package/.docs/reference/auth/neon.md +2 -2
- package/.docs/reference/cli/mastra.md +15 -15
- package/.docs/reference/datasets/compareExperiments.md +18 -9
- package/.docs/reference/datasets/dataset.md +3 -1
- package/.docs/reference/datasets/finalizeExperiment.md +2 -2
- package/.docs/reference/datasets/listExperiments.md +2 -2
- package/.docs/reference/datasets/submitExperimentResult.md +1 -1
- package/.docs/reference/editor/tools.md +11 -3
- package/.docs/reference/evals/completeness.md +3 -3
- package/.docs/reference/evals/context-precision.md +1 -1
- package/.docs/reference/evals/create-scorer.md +3 -7
- package/.docs/reference/evals/faithfulness.md +6 -4
- package/.docs/reference/evals/filter-run.md +2 -2
- package/.docs/reference/evals/trajectory-accuracy.md +3 -2
- package/.docs/reference/index.md +0 -1
- package/.docs/reference/memory/listThreads.md +1 -1
- package/.docs/reference/migrations/mcp-v2.md +2 -2
- package/.docs/reference/migrations/upgrade-to-v1/agent.md +1 -1
- package/.docs/reference/migrations/vnext-to-standard-apis.md +1 -1
- package/.docs/reference/observability/feedback.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +11 -1
- package/.docs/reference/observability/tracing/interfaces.md +26 -0
- package/.docs/reference/observability/tracing/spans.md +2 -0
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/prompt-injection-detector.md +2 -2
- package/.docs/reference/processors/provider-history-compat.md +12 -8
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +3 -3
- package/.docs/reference/processors/token-limiter-processor.md +2 -2
- package/.docs/reference/rag/graph-rag.md +1 -1
- package/.docs/reference/server/create-route.md +1 -1
- package/.docs/reference/server/elysia-adapter.md +1 -1
- package/.docs/reference/server/express-adapter.md +1 -1
- package/.docs/reference/server/fastify-adapter.md +1 -1
- package/.docs/reference/server/hono-adapter.md +2 -2
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/server/routes.md +1 -1
- package/.docs/reference/storage/composite.md +34 -0
- package/.docs/reference/storage/overview.md +3 -3
- package/.docs/reference/streaming/agents/MastraModelOutput.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/timeTravelStream.md +6 -4
- package/.docs/reference/tools/document-chunker-tool.md +8 -8
- package/.docs/reference/tools/mcp-client.md +1 -1
- package/.docs/reference/tools/mcp-server.md +17 -0
- package/.docs/reference/tools/submit-plan-tool.md +2 -0
- package/.docs/reference/tools/vector-query-tool.md +4 -4
- package/.docs/reference/vectors/astra.md +1 -1
- package/.docs/reference/vectors/azure-ai-search.md +1 -0
- package/.docs/reference/vectors/chroma.md +9 -5
- package/.docs/reference/vectors/convex.md +1 -3
- package/.docs/reference/vectors/couchbase.md +4 -9
- package/.docs/reference/vectors/duckdb.md +1 -1
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +2 -1
- package/.docs/reference/vectors/pg.md +16 -11
- package/.docs/reference/vectors/pinecone.md +8 -4
- package/.docs/reference/vectors/qdrant.md +8 -4
- package/.docs/reference/vectors/s3vectors.md +8 -4
- package/.docs/reference/vectors/turbopuffer.md +12 -6
- package/.docs/reference/vectors/upstash.md +10 -4
- package/.docs/reference/vectors/vectorize.md +7 -3
- package/.docs/reference/vectors/weaviate.md +1 -1
- package/.docs/reference/voice/composite-voice.md +15 -15
- package/.docs/reference/voice/mastra-voice.md +15 -11
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.answer.md +1 -1
- package/.docs/reference/voice/voice.close.md +1 -1
- package/.docs/reference/voice/voice.events.md +2 -2
- package/.docs/reference/voice/voice.listen.md +1 -1
- package/.docs/reference/voice/voice.off.md +1 -1
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/voice/voice.send.md +2 -2
- package/.docs/reference/voice/voice.updateConfig.md +1 -1
- package/.docs/reference/workflows/dynamic-workflow-definition.md +3 -2
- package/.docs/reference/workflows/run-methods/cancel.md +1 -2
- package/.docs/reference/workflows/run-methods/resume.md +2 -0
- package/.docs/reference/workflows/run-methods/timeTravel.md +27 -0
- package/.docs/reference/workflows/run.md +14 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +1 -1
- package/.docs/reference/workflows/workflow-methods/branch.md +4 -4
- package/.docs/reference/workflows/workflow-methods/classifier.md +1 -1
- package/.docs/reference/workflows/workflow-methods/create-run.md +2 -2
- package/.docs/reference/workflows/workflow-methods/dountil.md +1 -1
- package/.docs/reference/workflows/workflow-methods/dowhile.md +1 -1
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +1 -1
- package/.docs/reference/workspace/filesystem.md +10 -13
- package/.docs/reference/workspace/local-filesystem.md +5 -5
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/process-manager.md +2 -2
- package/.docs/reference/workspace/workspace-class.md +4 -4
- package/package.json +5 -5
- package/.docs/reference/agents/getTools.md +0 -31
|
@@ -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
|
-
|
|
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
|
-
|
|
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\
|
|
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** (`
|
|
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.
|
|
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-
|
|
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-
|
|
70
|
-
console.log(`Completed step: ${event.payload.
|
|
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
|
-
|
|
23
|
+
maxSize: 512,
|
|
24
24
|
overlap: 50,
|
|
25
|
-
|
|
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
|
-
**
|
|
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
|
-
**
|
|
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
|
-
|
|
67
|
+
maxSize: 1024, // Larger chunks
|
|
68
68
|
overlap: 100, // More overlap
|
|
69
|
-
|
|
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} {
|
|
86
|
-
- **Description**: `Chunks document using {strategy} strategy with
|
|
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 `
|
|
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. (
|
|
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) // '
|
|
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
|
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
|
260
|
-
console.log(error.
|
|
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
|
}
|
|
@@ -387,7 +387,6 @@ const results = await vectorStore.query({
|
|
|
387
387
|
|
|
388
388
|
| Operator | Description |
|
|
389
389
|
| -------- | --------------------- |
|
|
390
|
-
| `$eq` | Equal to |
|
|
391
390
|
| `$ne` | Not equal to |
|
|
392
391
|
| `$gt` | Greater than |
|
|
393
392
|
| `$gte` | Greater than or equal |
|
|
@@ -400,10 +399,9 @@ const results = await vectorStore.query({
|
|
|
400
399
|
|
|
401
400
|
## Architecture
|
|
402
401
|
|
|
403
|
-
`ConvexVector` stores
|
|
402
|
+
`ConvexVector` stores each index in its own table named `mastra_vector_{indexName}`. Each record has the following structure:
|
|
404
403
|
|
|
405
404
|
- `id`: Unique vector identifier
|
|
406
|
-
- `indexName`: Name of the index
|
|
407
405
|
- `embedding`: The vector data (array of floats)
|
|
408
406
|
- `metadata`: Optional JSON metadata
|
|
409
407
|
|
|
@@ -69,8 +69,6 @@ const store = new CouchbaseVector({
|
|
|
69
69
|
|
|
70
70
|
**collectionName** (`string`): Name of the Couchbase collection to use
|
|
71
71
|
|
|
72
|
-
**options** (`CouchbaseClientOptions`): Optional Couchbase client options
|
|
73
|
-
|
|
74
72
|
## Methods
|
|
75
73
|
|
|
76
74
|
### `createIndex()`
|
|
@@ -83,7 +81,7 @@ Creates a new vector index in Couchbase.
|
|
|
83
81
|
|
|
84
82
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
85
83
|
|
|
86
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `
|
|
84
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `dotproduct`)
|
|
87
85
|
|
|
88
86
|
### `upsert()`
|
|
89
87
|
|
|
@@ -111,11 +109,9 @@ Searches for similar vectors.
|
|
|
111
109
|
|
|
112
110
|
**topK** (`number`): Number of results to return (Default: `10`)
|
|
113
111
|
|
|
114
|
-
**filter** (`Record<string, any>`):
|
|
115
|
-
|
|
116
|
-
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
112
|
+
**filter** (`Record<string, any>`): Not supported. Filters passed here are ignored.
|
|
117
113
|
|
|
118
|
-
**
|
|
114
|
+
**includeVector** (`boolean`): Not supported. Setting this to true throws an error. (Default: `false`)
|
|
119
115
|
|
|
120
116
|
### `describeIndex()`
|
|
121
117
|
|
|
@@ -135,7 +131,7 @@ interface IndexStats {
|
|
|
135
131
|
|
|
136
132
|
### `deleteIndex()`
|
|
137
133
|
|
|
138
|
-
Deletes
|
|
134
|
+
Deletes the Search index. Documents stored in the collection aren't deleted.
|
|
139
135
|
|
|
140
136
|
**indexName** (`string`): Name of the index to delete
|
|
141
137
|
|
|
@@ -184,7 +180,6 @@ interface QueryResult {
|
|
|
184
180
|
id: string
|
|
185
181
|
score: number
|
|
186
182
|
metadata: Record<string, any>
|
|
187
|
-
vector?: number[] // Only included if includeVector is true
|
|
188
183
|
}
|
|
189
184
|
```
|
|
190
185
|
|
|
@@ -216,7 +216,7 @@ DuckDB vector store supports MongoDB-like filter operators:
|
|
|
216
216
|
| ---------- | ------------------------------------------ |
|
|
217
217
|
| Comparison | `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte` |
|
|
218
218
|
| Logical | `$and`, `$or`, `$not`, `$nor` |
|
|
219
|
-
| Array | `$in`, `$nin`
|
|
219
|
+
| Array | `$in`, `$nin`, `$all` |
|
|
220
220
|
| Element | `$exists` |
|
|
221
221
|
| Text | `$contains` |
|
|
222
222
|
|
|
@@ -121,7 +121,7 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
121
121
|
|
|
122
122
|
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
123
123
|
|
|
124
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `
|
|
124
|
+
**minScore** (`number`): Minimum similarity score threshold (cosine similarity ranges from -1 to 1) (Default: `-1`)
|
|
125
125
|
|
|
126
126
|
### `describeIndex()`
|
|
127
127
|
|
|
@@ -352,6 +352,7 @@ interface QueryResult {
|
|
|
352
352
|
score: number
|
|
353
353
|
metadata: Record<string, any>
|
|
354
354
|
vector?: number[] // Only included if includeVector is true
|
|
355
|
+
document?: string // Source text stored with the vector, when available
|
|
355
356
|
}
|
|
356
357
|
```
|
|
357
358
|
|
|
@@ -429,7 +430,7 @@ const results = await store.query({
|
|
|
429
430
|
|
|
430
431
|
**similarity** (`'cosine' | 'dotProduct' | 'euclidean'`): Vector similarity function. Defaults to MongoDB's own default when omitted.
|
|
431
432
|
|
|
432
|
-
**numDimensions** (`
|
|
433
|
+
**numDimensions** (`number`): Length of the generated embeddings. Common values are 256, 512, 1024, and 2048. (Default: `1024`)
|
|
433
434
|
|
|
434
435
|
**quantization** (`'float' | 'scalar' | 'binary' | 'binaryNoRescore'`): Storage format for the generated vectors. (Default: `scalar`)
|
|
435
436
|
|
|
@@ -82,7 +82,9 @@ const vectorStore = new PgVector({
|
|
|
82
82
|
|
|
83
83
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
84
84
|
|
|
85
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
85
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search. 'hamming' and 'jaccard' are only valid with vectorType 'bit', and 'jaccard' requires an HNSW index. (Default: `'cosine' ('hamming' when vectorType is 'bit')`)
|
|
86
|
+
|
|
87
|
+
**vectorType** (`'vector' | 'halfvec' | 'bit' | 'sparsevec'`): pgvector storage type for the embeddings (Default: `vector`)
|
|
86
88
|
|
|
87
89
|
**indexConfig** (`IndexConfig`): Index configuration (Default: `{ type: 'ivfflat' }`)
|
|
88
90
|
|
|
@@ -142,13 +144,11 @@ Higher M values or efConstruction values will increase memory requirements subst
|
|
|
142
144
|
|
|
143
145
|
**includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
|
|
144
146
|
|
|
145
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `
|
|
146
|
-
|
|
147
|
-
**options** (`{ ef?: number; probes?: number }`): Additional options for HNSW and IVF indexes
|
|
147
|
+
**minScore** (`number`): Minimum similarity score threshold (Default: `-1`)
|
|
148
148
|
|
|
149
|
-
**
|
|
149
|
+
**ef** (`number`): HNSW search parameter. Higher values improve accuracy at the cost of speed.
|
|
150
150
|
|
|
151
|
-
**
|
|
151
|
+
**probes** (`number`): IVFFlat search parameter. Number of lists to visit during search.
|
|
152
152
|
|
|
153
153
|
### `listIndexes()`
|
|
154
154
|
|
|
@@ -164,8 +164,9 @@ Returns:
|
|
|
164
164
|
interface PGIndexStats {
|
|
165
165
|
dimension: number
|
|
166
166
|
count: number
|
|
167
|
-
metric: 'cosine' | 'euclidean' | 'dotproduct'
|
|
167
|
+
metric: 'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'
|
|
168
168
|
type: 'flat' | 'hnsw' | 'ivfflat'
|
|
169
|
+
vectorType: 'vector' | 'halfvec' | 'bit' | 'sparsevec'
|
|
169
170
|
config: {
|
|
170
171
|
m?: number
|
|
171
172
|
efConstruction?: number
|
|
@@ -246,7 +247,7 @@ Closes the database connection pool. Should be called when done using the store.
|
|
|
246
247
|
|
|
247
248
|
**indexName** (`string`): Name of the index to define
|
|
248
249
|
|
|
249
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
250
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search (Default: `cosine`)
|
|
250
251
|
|
|
251
252
|
**indexConfig** (`IndexConfig`): Configuration for the index type and parameters
|
|
252
253
|
|
|
@@ -291,17 +292,21 @@ interface QueryResult {
|
|
|
291
292
|
|
|
292
293
|
## Error handling
|
|
293
294
|
|
|
294
|
-
The store throws
|
|
295
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
295
296
|
|
|
296
297
|
```typescript
|
|
298
|
+
import { MastraError } from '@mastra/core/error'
|
|
299
|
+
|
|
297
300
|
try {
|
|
298
301
|
await store.query({
|
|
299
302
|
indexName: 'index_name',
|
|
300
303
|
queryVector: queryVector,
|
|
301
304
|
})
|
|
302
305
|
} catch (error) {
|
|
303
|
-
if (error instanceof
|
|
304
|
-
console.log(error.
|
|
306
|
+
if (error instanceof MastraError) {
|
|
307
|
+
console.log(error.id) // 'MASTRA_VECTOR_PG_QUERY_FAILED'
|
|
308
|
+
console.log(error.domain) // 'MASTRA_VECTOR'
|
|
309
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
305
310
|
console.log(error.details) // Additional error context
|
|
306
311
|
}
|
|
307
312
|
}
|
|
@@ -130,24 +130,28 @@ Query results are returned in this format:
|
|
|
130
130
|
interface QueryResult {
|
|
131
131
|
id: string
|
|
132
132
|
score: number
|
|
133
|
-
metadata
|
|
133
|
+
metadata?: Record<string, any>
|
|
134
134
|
vector?: number[] // Only included if includeVector is true
|
|
135
135
|
}
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
## Error handling
|
|
139
139
|
|
|
140
|
-
The store throws
|
|
140
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
141
141
|
|
|
142
142
|
```typescript
|
|
143
|
+
import { MastraError } from '@mastra/core/error'
|
|
144
|
+
|
|
143
145
|
try {
|
|
144
146
|
await store.query({
|
|
145
147
|
indexName: 'index_name',
|
|
146
148
|
queryVector: queryVector,
|
|
147
149
|
})
|
|
148
150
|
} catch (error) {
|
|
149
|
-
if (error instanceof
|
|
150
|
-
console.log(error.
|
|
151
|
+
if (error instanceof MastraError) {
|
|
152
|
+
console.log(error.id) // 'MASTRA_VECTOR_PINECONE_QUERY_FAILED'
|
|
153
|
+
console.log(error.domain) // 'STORAGE'
|
|
154
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
151
155
|
console.log(error.details) // Additional error context
|
|
152
156
|
}
|
|
153
157
|
}
|
|
@@ -198,24 +198,28 @@ Query results are returned in this format:
|
|
|
198
198
|
interface QueryResult {
|
|
199
199
|
id: string
|
|
200
200
|
score: number
|
|
201
|
-
metadata
|
|
201
|
+
metadata?: Record<string, any>
|
|
202
202
|
vector?: number[] // Only included if includeVector is true
|
|
203
203
|
}
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
## Error handling
|
|
207
207
|
|
|
208
|
-
The store throws
|
|
208
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
209
209
|
|
|
210
210
|
```typescript
|
|
211
|
+
import { MastraError } from '@mastra/core/error'
|
|
212
|
+
|
|
211
213
|
try {
|
|
212
214
|
await store.query({
|
|
213
215
|
indexName: 'index_name',
|
|
214
216
|
queryVector: queryVector,
|
|
215
217
|
})
|
|
216
218
|
} catch (error) {
|
|
217
|
-
if (error instanceof
|
|
218
|
-
console.log(error.
|
|
219
|
+
if (error instanceof MastraError) {
|
|
220
|
+
console.log(error.id) // 'MASTRA_VECTOR_QDRANT_QUERY_FAILED'
|
|
221
|
+
console.log(error.domain) // 'STORAGE'
|
|
222
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
219
223
|
console.log(error.details) // Additional error context
|
|
220
224
|
}
|
|
221
225
|
}
|
|
@@ -196,7 +196,7 @@ Query results are returned in this format:
|
|
|
196
196
|
interface QueryResult {
|
|
197
197
|
id: string
|
|
198
198
|
score: number // 1/(1 + distance)
|
|
199
|
-
metadata
|
|
199
|
+
metadata?: Record<string, any>
|
|
200
200
|
vector?: number[] // Only included if includeVector is true
|
|
201
201
|
}
|
|
202
202
|
```
|
|
@@ -244,17 +244,21 @@ S3 Vectors supports a strict subset of operators and value types. The Mastra fil
|
|
|
244
244
|
|
|
245
245
|
## Error handling
|
|
246
246
|
|
|
247
|
-
The store throws
|
|
247
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
248
248
|
|
|
249
249
|
```typescript
|
|
250
|
+
import { MastraError } from '@mastra/core/error'
|
|
251
|
+
|
|
250
252
|
try {
|
|
251
253
|
await store.query({
|
|
252
254
|
indexName: 'index-name',
|
|
253
255
|
queryVector: queryVector,
|
|
254
256
|
})
|
|
255
257
|
} catch (error) {
|
|
256
|
-
if (error instanceof
|
|
257
|
-
console.log(error.
|
|
258
|
+
if (error instanceof MastraError) {
|
|
259
|
+
console.log(error.id) // 'MASTRA_VECTOR_S3VECTORS_QUERY_FAILED'
|
|
260
|
+
console.log(error.domain) // 'STORAGE'
|
|
261
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
258
262
|
console.log(error.details) // Additional error context
|
|
259
263
|
}
|
|
260
264
|
}
|