@mastra/mcp-docs-server 1.2.15-alpha.1 → 1.2.15-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/a2a.md +75 -2
- package/.docs/docs/agents/processors.md +2 -0
- package/.docs/docs/agents/skills.md +15 -1
- package/.docs/docs/capabilities/channels/overview.md +19 -0
- package/.docs/docs/capabilities/subagents.md +23 -5
- package/.docs/docs/connections/overview.md +94 -0
- package/.docs/docs/datasets/running-experiments.md +18 -0
- package/.docs/docs/evals/overview.md +16 -4
- package/.docs/docs/harness/agent-controller.md +6 -0
- package/.docs/docs/harness/overview.md +26 -0
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/mcp/overview.md +10 -0
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +2 -1
- package/.docs/docs/memory/working-memory.md +1 -0
- package/.docs/docs/observability/feedback.md +16 -0
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -0
- package/.docs/docs/server/auth.md +2 -0
- package/.docs/docs/server/mastra-client.md +11 -11
- package/.docs/docs/storage/overview.md +1 -0
- package/.docs/docs/workflows/agents-and-tools.md +2 -2
- package/.docs/docs/workflows/{stored-workflows.md → dynamic-workflows.md} +23 -23
- package/.docs/docs/workflows/snapshots.md +3 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +25 -14
- package/.docs/guides/getting-started/quickstart.md +1 -1
- package/.docs/guides/rag/overview.md +1 -1
- package/.docs/guides/rag/retrieval.md +17 -0
- package/.docs/guides/rag/vector-databases.md +41 -0
- package/.docs/guides/voice/realtime-voice.md +28 -2
- package/.docs/models/gateways/custom-gateways.md +4 -0
- package/.docs/models/gateways/neon.md +15 -9
- package/.docs/models/gateways/netlify.md +1 -2
- package/.docs/models/gateways/openrouter.md +3 -2
- package/.docs/models/gateways/vercel.md +11 -3
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/baseten.md +1 -1
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/deepinfra.md +6 -3
- package/.docs/models/providers/digitalocean.md +6 -5
- package/.docs/models/providers/empiriolabs.md +6 -4
- package/.docs/models/providers/friendli.md +8 -9
- package/.docs/models/providers/huggingface.md +4 -1
- package/.docs/models/providers/hyper.md +5 -6
- package/.docs/models/providers/kilo.md +12 -10
- package/.docs/models/providers/llmgateway.md +3 -3
- package/.docs/models/providers/meta.md +7 -5
- package/.docs/models/providers/nano-gpt.md +7 -4
- package/.docs/models/providers/neuralwatt.md +2 -1
- package/.docs/models/providers/ofox.md +74 -16
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/opencode.md +2 -3
- package/.docs/models/providers/regolo-ai.md +25 -20
- package/.docs/models/providers/upstage.md +3 -2
- package/.docs/models/providers/vivgrid.md +4 -2
- package/.docs/models/providers/wandb.md +1 -1
- package/.docs/reference/agents/channels.md +22 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +2 -0
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +1 -1
- package/.docs/reference/channels/slack-provider.md +2 -0
- package/.docs/reference/client-js/observability.md +22 -0
- package/.docs/reference/client-js/workflows.md +32 -19
- package/.docs/reference/configuration.md +26 -1
- package/.docs/reference/core/{addStoredWorkflow.md → addDynamicWorkflow.md} +10 -10
- package/.docs/reference/core/{addStoredWorkflows.md → addDynamicWorkflows.md} +9 -9
- package/.docs/reference/editor/tool-provider.md +26 -1
- package/.docs/reference/file-based-agents/config.md +22 -21
- package/.docs/reference/file-based-agents/instructions.md +42 -17
- package/.docs/reference/index.md +6 -3
- package/.docs/reference/observability/metrics/automatic-metrics.md +10 -8
- package/.docs/reference/rag/metadata-filters.md +13 -4
- package/.docs/reference/server/register-api-route.md +2 -0
- package/.docs/reference/server/routes.md +38 -24
- package/.docs/reference/storage/composite.md +58 -0
- package/.docs/reference/storage/oracledb.md +239 -0
- package/.docs/reference/storage/overview.md +9 -9
- package/.docs/reference/storage/retention.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/bedrock-kb-tool.md +117 -0
- package/.docs/reference/tools/mcp-client.md +54 -0
- package/.docs/reference/vectors/oracledb.md +347 -0
- package/.docs/reference/voice/google.md +19 -3
- package/.docs/reference/workflows/{stored-workflow-definition.md → dynamic-workflow-definition.md} +7 -7
- package/.docs/reference/workflows/step.md +40 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +3 -3
- package/.docs/reference/workflows/workflow-methods/tool.md +3 -3
- package/.docs/reference/workspace/daytona-sandbox.md +21 -0
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +2 -0
- package/CHANGELOG.md +51 -0
- package/package.json +6 -6
|
@@ -69,32 +69,33 @@ Please note:
|
|
|
69
69
|
|
|
70
70
|
Keep `config.ts` focused on runtime options. Use sibling files for concerns that benefit from their own location.
|
|
71
71
|
|
|
72
|
-
| Setting | File or folder
|
|
73
|
-
| ------------ |
|
|
74
|
-
| Instructions | [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | Keeps the always-on prompt readable as markdown
|
|
75
|
-
| Tools | [`tools/`](https://mastra.ai/reference/file-based-agents/tools)
|
|
76
|
-
| Skills | [`skills/`](https://mastra.ai/reference/file-based-agents/skills)
|
|
77
|
-
| Memory | [`memory.ts`](https://mastra.ai/reference/file-based-agents/memory)
|
|
78
|
-
| Workspace | [`workspace.ts`](https://mastra.ai/reference/file-based-agents/workspace)
|
|
79
|
-
| Processors | [`processors/`](https://mastra.ai/reference/file-based-agents/processors)
|
|
80
|
-
| Subagents | [`subagents/`](https://mastra.ai/reference/file-based-agents/subagents)
|
|
72
|
+
| Setting | File or folder | Why it lives there |
|
|
73
|
+
| ------------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
74
|
+
| Instructions | [`instructions.md` or `instructions.ts`](https://mastra.ai/reference/file-based-agents/instructions) | Keeps the always-on prompt readable as markdown, or computed in TypeScript |
|
|
75
|
+
| Tools | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | Gives each callable action its own typed module |
|
|
76
|
+
| Skills | [`skills/`](https://mastra.ai/reference/file-based-agents/skills) | Keeps load-on-demand procedures separate from always-on instructions |
|
|
77
|
+
| Memory | [`memory.ts`](https://mastra.ai/reference/file-based-agents/memory) | Configures persistent memory without crowding runtime options |
|
|
78
|
+
| Workspace | [`workspace.ts`](https://mastra.ai/reference/file-based-agents/workspace) | Configures files and sandbox behavior separately from model settings |
|
|
79
|
+
| Processors | [`processors/`](https://mastra.ai/reference/file-based-agents/processors) | Separates input and output processing pipelines |
|
|
80
|
+
| Subagents | [`subagents/`](https://mastra.ai/reference/file-based-agents/subagents) | Gives each specialist child agent its own directory |
|
|
81
81
|
|
|
82
82
|
## Precedence
|
|
83
83
|
|
|
84
84
|
`config.ts` merges with the agent's other files according to these rules:
|
|
85
85
|
|
|
86
|
-
| Domain | Source A
|
|
87
|
-
| ------------ |
|
|
88
|
-
| Instructions | Dynamic `config.instructions`
|
|
89
|
-
| Instructions | Static `config.instructions`
|
|
90
|
-
|
|
|
91
|
-
| Tools |
|
|
92
|
-
|
|
|
93
|
-
| Skills |
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
| Domain | Source A | Source B | Winner |
|
|
87
|
+
| ------------ | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
88
|
+
| Instructions | Dynamic `config.instructions` | [`instructions.ts` or `instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | Dynamic `config.instructions` |
|
|
89
|
+
| Instructions | Static `config.instructions` | [`instructions.ts` or `instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | The instructions file |
|
|
90
|
+
| Instructions | [`instructions.ts`](https://mastra.ai/reference/file-based-agents/instructions) | [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions) | `instructions.ts` |
|
|
91
|
+
| Tools | `config.tools` | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | Both merge; `config.tools` wins on key collisions |
|
|
92
|
+
| Tools | Function `config.tools` | [`tools/`](https://mastra.ai/reference/file-based-agents/tools) | Function `config.tools`; discovered tools are ignored |
|
|
93
|
+
| Skills | `config.skills` | [`skills/`](https://mastra.ai/reference/file-based-agents/skills) | Both merge; `config.skills` wins on name collisions |
|
|
94
|
+
| Skills | Function `config.skills` | [`skills/`](https://mastra.ai/reference/file-based-agents/skills) | Function `config.skills`; discovered skills are ignored |
|
|
95
|
+
| Memory | `config.memory` | [`memory.ts`](https://mastra.ai/reference/file-based-agents/memory) | `config.memory` |
|
|
96
|
+
| Workspace | `config.workspace` | [`workspace.ts`](https://mastra.ai/reference/file-based-agents/workspace) | `config.workspace` |
|
|
97
|
+
|
|
98
|
+
Missing `instructions.md`, `instructions.ts`, and `config.instructions` fails the build. Missing both `config.memory` and `memory.ts` leaves the agent without memory.
|
|
98
99
|
|
|
99
100
|
## Discovery lifecycle
|
|
100
101
|
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# Instructions
|
|
4
4
|
|
|
5
|
-
An agent's
|
|
5
|
+
An agent's instructions hold its always-on system prompt: the model reads it on every turn. Use them to define the agent's identity, tone, role, and standing rules.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Write them in one of two files at the agent root. Use `instructions.md` when the prompt is fixed text. Use `instructions.ts` when the prompt needs code, for example when it's built from shared constants or resolved per request.
|
|
8
|
+
|
|
9
|
+
Instructions are always in context, so keep them for stable behavior that applies to every request. Move anything conditional, large, or action-oriented into [`tools/`](https://mastra.ai/reference/file-based-agents/tools) or [`skills/`](https://mastra.ai/reference/file-based-agents/skills), which the model uses only when relevant.
|
|
8
10
|
|
|
9
11
|
## Quickstart
|
|
10
12
|
|
|
@@ -25,30 +27,53 @@ Effective instructions cover the parts of an agent's behavior that don't change
|
|
|
25
27
|
|
|
26
28
|
Move conditional, large, or action-oriented guidance into [`tools/`](https://mastra.ai/reference/file-based-agents/tools) or [`skills/`](https://mastra.ai/reference/file-based-agents/skills), which the model uses only when relevant.
|
|
27
29
|
|
|
28
|
-
##
|
|
30
|
+
## Instructions in TypeScript
|
|
31
|
+
|
|
32
|
+
Use `instructions.ts` when markdown can't express the prompt. The file default-exports a string, a system message, or a function returning one, and `agentInstructions()` types the export without changing it.
|
|
33
|
+
|
|
34
|
+
Export a string when the prompt is assembled in code, for example from constants shared with the rest of your app:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { agentInstructions } from '@mastra/core/agent'
|
|
38
|
+
import { SUPPORTED_UNITS } from '../../constants'
|
|
39
|
+
|
|
40
|
+
export default agentInstructions(`
|
|
41
|
+
You are a helpful weather assistant.
|
|
42
|
+
Report conditions using one of these units: ${SUPPORTED_UNITS.join(', ')}.
|
|
43
|
+
`)
|
|
44
|
+
```
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
Export a function when the prompt depends on the request. Mastra calls it on every turn and passes the request context:
|
|
31
47
|
|
|
32
48
|
```typescript
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
export default
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const tier = runtimeContext.get('tier') ?? 'standard'
|
|
39
|
-
return `You are a support agent. Treat this as a ${tier}-tier customer.`
|
|
40
|
-
},
|
|
49
|
+
import { agentInstructions } from '@mastra/core/agent'
|
|
50
|
+
|
|
51
|
+
export default agentInstructions(({ requestContext }) => {
|
|
52
|
+
const tier = requestContext.get('tier') ?? 'standard'
|
|
53
|
+
return `You are a support agent. Treat this as a ${tier}-tier customer.`
|
|
41
54
|
})
|
|
42
55
|
```
|
|
43
56
|
|
|
57
|
+
The function can be `async` and receives `mastra` alongside `requestContext`, so it can read from storage or another registered primitive before returning the prompt.
|
|
58
|
+
|
|
59
|
+
Both files can also live in a [subagent](https://mastra.ai/reference/file-based-agents/subagents) directory, which follows the same rules.
|
|
60
|
+
|
|
44
61
|
## Build-time behavior
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
`instructions.md` and `instructions.ts` reach the deployed agent differently:
|
|
64
|
+
|
|
65
|
+
- `instructions.md`: Mastra reads the file and inlines its contents into the generated code at build time.
|
|
66
|
+
- `instructions.ts`: The generated code imports the module, so it's bundled like any other TypeScript file and can import from the rest of your project.
|
|
67
|
+
|
|
68
|
+
Under `mastra dev`, editing either file triggers a rebuild. In a deployed app neither file is read from disk at runtime, so changes take effect after the next build.
|
|
47
69
|
|
|
48
70
|
## Precedence with config
|
|
49
71
|
|
|
50
|
-
Instructions can come from `instructions.md
|
|
72
|
+
Instructions can come from `instructions.ts`, `instructions.md`, or the `instructions` field in [`config.ts`](https://mastra.ai/reference/file-based-agents/config):
|
|
73
|
+
|
|
74
|
+
- A runtime-defined (function) `instructions` in `config.ts` wins over both files.
|
|
75
|
+
- Otherwise `instructions.ts` wins over `instructions.md`.
|
|
76
|
+
- `instructions.md` wins over a static `instructions` string in `config.ts`.
|
|
77
|
+
- If none is present, the build fails and names the agent directory.
|
|
51
78
|
|
|
52
|
-
|
|
53
|
-
- Otherwise `instructions.md` wins over a static `instructions` string.
|
|
54
|
-
- If neither is present, the build fails and names the agent directory.
|
|
79
|
+
Defining instructions in more than one place logs a warning that names both sources and which one wins. Keep one source per agent.
|
package/.docs/reference/index.md
CHANGED
|
@@ -82,9 +82,9 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
82
82
|
- [createCodingAgent()](https://mastra.ai/reference/coding-agent/create-coding-agent)
|
|
83
83
|
- [Mastra Class](https://mastra.ai/reference/core/mastra-class)
|
|
84
84
|
- [MastraModelGateway](https://mastra.ai/reference/core/mastra-model-gateway)
|
|
85
|
+
- [.addDynamicWorkflow()](https://mastra.ai/reference/core/addDynamicWorkflow)
|
|
86
|
+
- [.addDynamicWorkflows()](https://mastra.ai/reference/core/addDynamicWorkflows)
|
|
85
87
|
- [.addGateway()](https://mastra.ai/reference/core/addGateway)
|
|
86
|
-
- [.addStoredWorkflow()](https://mastra.ai/reference/core/addStoredWorkflow)
|
|
87
|
-
- [.addStoredWorkflows()](https://mastra.ai/reference/core/addStoredWorkflows)
|
|
88
88
|
- [.getAgent()](https://mastra.ai/reference/core/getAgent)
|
|
89
89
|
- [.getAgentById()](https://mastra.ai/reference/core/getAgentById)
|
|
90
90
|
- [.getDeployer()](https://mastra.ai/reference/core/getDeployer)
|
|
@@ -285,6 +285,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
285
285
|
- [libSQL Storage](https://mastra.ai/reference/storage/libsql)
|
|
286
286
|
- [MongoDB Storage](https://mastra.ai/reference/storage/mongodb)
|
|
287
287
|
- [MSSQL Storage](https://mastra.ai/reference/storage/mssql)
|
|
288
|
+
- [OracleDB Storage](https://mastra.ai/reference/storage/oracledb)
|
|
288
289
|
- [PostgreSQL Storage](https://mastra.ai/reference/storage/postgresql)
|
|
289
290
|
- [Redis Storage](https://mastra.ai/reference/storage/redis)
|
|
290
291
|
- [Retention (prune)](https://mastra.ai/reference/storage/retention)
|
|
@@ -302,6 +303,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
302
303
|
- [Overview](https://mastra.ai/reference/templates/overview)
|
|
303
304
|
- [askUserTool](https://mastra.ai/reference/tools/ask-user-tool)
|
|
304
305
|
- [Bright Data Tools](https://mastra.ai/reference/tools/brightdata)
|
|
306
|
+
- [createBedrockKBTool()](https://mastra.ai/reference/tools/bedrock-kb-tool)
|
|
305
307
|
- [createCodeMode()](https://mastra.ai/reference/tools/create-code-mode)
|
|
306
308
|
- [createDocumentChunkerTool()](https://mastra.ai/reference/tools/document-chunker-tool)
|
|
307
309
|
- [createGraphRAGTool()](https://mastra.ai/reference/tools/graph-rag-tool)
|
|
@@ -326,6 +328,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
326
328
|
- [libSQL Vector Store](https://mastra.ai/reference/vectors/libsql)
|
|
327
329
|
- [MongoDB Vector Store](https://mastra.ai/reference/vectors/mongodb)
|
|
328
330
|
- [OpenSearch Vector Store](https://mastra.ai/reference/vectors/opensearch)
|
|
331
|
+
- [OracleDB Vector Store](https://mastra.ai/reference/vectors/oracledb)
|
|
329
332
|
- [PG Vector Store](https://mastra.ai/reference/vectors/pg)
|
|
330
333
|
- [Pinecone Vector Store](https://mastra.ai/reference/vectors/pinecone)
|
|
331
334
|
- [Qdrant Vector Store](https://mastra.ai/reference/vectors/qdrant)
|
|
@@ -365,9 +368,9 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
365
368
|
- [.speak()](https://mastra.ai/reference/voice/voice.speak)
|
|
366
369
|
- [.updateConfig()](https://mastra.ai/reference/voice/voice.updateConfig)
|
|
367
370
|
- [Overview](https://mastra.ai/reference/workers/overview)
|
|
371
|
+
- [Dynamic Workflow Definition](https://mastra.ai/reference/workflows/dynamic-workflow-definition)
|
|
368
372
|
- [Run Class](https://mastra.ai/reference/workflows/run)
|
|
369
373
|
- [Step Class](https://mastra.ai/reference/workflows/step)
|
|
370
|
-
- [Stored Workflow Definition](https://mastra.ai/reference/workflows/stored-workflow-definition)
|
|
371
374
|
- [Workflow Class](https://mastra.ai/reference/workflows/workflow)
|
|
372
375
|
- [Workflow State Reader](https://mastra.ai/reference/workflows/workflow-state-reader)
|
|
373
376
|
- [.agent()](https://mastra.ai/reference/workflows/workflow-methods/agent)
|
|
@@ -64,17 +64,19 @@ The detailed breakdown metrics (everything except `total_input` and `total_outpu
|
|
|
64
64
|
|
|
65
65
|
### When cost context is attached
|
|
66
66
|
|
|
67
|
-
Cost context is attached to token metrics when the embedded pricing registry has a matching entry for the provider and model. Mastra
|
|
67
|
+
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.
|
|
68
|
+
|
|
69
|
+
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.
|
|
68
70
|
|
|
69
71
|
### What cost fields may be included
|
|
70
72
|
|
|
71
|
-
| Field | Description
|
|
72
|
-
| --------------- |
|
|
73
|
-
| `provider` | Provider name (e.g. `openai`, `anthropic`)
|
|
74
|
-
| `model` | Model identifier (e.g. `gpt-4o`, `claude-sonnet-4-20250514`)
|
|
75
|
-
| `estimatedCost` | Estimated cost
|
|
76
|
-
| `costUnit` | Currency unit (e.g. `USD`)
|
|
77
|
-
| `costMetadata` | Additional pricing context
|
|
73
|
+
| Field | Description |
|
|
74
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
75
|
+
| `provider` | Provider name (e.g. `openai`, `anthropic`) |
|
|
76
|
+
| `model` | Model identifier (e.g. `gpt-4o`, `claude-sonnet-4-20250514`) |
|
|
77
|
+
| `estimatedCost` | Estimated cost from token count and pricing tier, or a total reported by the provider |
|
|
78
|
+
| `costUnit` | Currency unit (e.g. `USD`) |
|
|
79
|
+
| `costMetadata` | Additional pricing context, including tier information, error details, and provider-reported cost source and scope |
|
|
78
80
|
|
|
79
81
|
## Correlation with traces
|
|
80
82
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Metadata filters
|
|
4
4
|
|
|
5
|
-
Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax. Each vector store translates these filters into
|
|
5
|
+
Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax. Each vector store translates these filters into its native query format. For example, PgVector uses PostgreSQL JSONB predicates, while OracleDB stores metadata as Oracle JSON and compiles filters to `JSON_VALUE`, `JSON_EXISTS`, `REGEXP_LIKE`, and `LIKE` predicates with bound values.
|
|
6
6
|
|
|
7
7
|
## Basic example
|
|
8
8
|
|
|
@@ -34,11 +34,11 @@ const results = await store.query({
|
|
|
34
34
|
|
|
35
35
|
### Array Operators
|
|
36
36
|
|
|
37
|
-
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Upstash, MongoDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB
|
|
37
|
+
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Upstash, MongoDB, OracleDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB, OracleDB
|
|
38
38
|
|
|
39
39
|
### Logical Operators
|
|
40
40
|
|
|
41
|
-
`$and`Logical AND{ $and: \[{ price: { $gt: 100 } }, { stock: { $gt: 0 } }] }Supported by: All except Vectorize, Couchbase`$or`Logical OR{ $or: \[{ status: "active" }, { priority: "high" }] }Supported by: All except Vectorize, Couchbase`$not`Logical NOT{ price: { $not: { $lt: 100 } } }Supported by: Astra, Qdrant, Upstash, PgVector, libSQL, MongoDB`$nor`Logical NOR{ $nor: \[{ status: "deleted" }, { archived: true }] }Supported by: Qdrant, Upstash, PgVector, libSQL, MongoDB
|
|
41
|
+
`$and`Logical AND{ $and: \[{ price: { $gt: 100 } }, { stock: { $gt: 0 } }] }Supported by: All except Vectorize, Couchbase`$or`Logical OR{ $or: \[{ status: "active" }, { priority: "high" }] }Supported by: All except Vectorize, Couchbase`$not`Logical NOT{ price: { $not: { $lt: 100 } } }Supported by: Astra, Qdrant, Upstash, PgVector, libSQL, MongoDB, OracleDB`$nor`Logical NOR{ $nor: \[{ status: "deleted" }, { archived: true }] }Supported by: Qdrant, Upstash, PgVector, libSQL, MongoDB, OracleDB
|
|
42
42
|
|
|
43
43
|
### Element Operators
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ const results = await store.query({
|
|
|
46
46
|
|
|
47
47
|
### Custom Operators
|
|
48
48
|
|
|
49
|
-
`$contains`Text contains substring{ description: { $contains: "sale" } }Supported by: Upstash, libSQL, PgVector`$regex`Regular expression match{ name: { $regex: "^test" } }Supported by: Qdrant, PgVector, Upstash, MongoDB`$size`Array length check{ tags: { $size:
|
|
49
|
+
`$contains`Text contains substring{ description: { $contains: "sale" } }Supported by: Upstash, libSQL, PgVector, OracleDB`$regex`Regular expression match{ name: { $regex: "^test" } }Supported by: Qdrant, PgVector, Upstash, MongoDB, OracleDB`$size`Array length check{ tags: { $size: 3 } }Supported by: Astra, libSQL, PgVector, MongoDB, OracleDB`$geo`Geospatial query{ location: { $geo: { type: "radius", ... } } }Supported by: Qdrant`$datetime`Datetime range query{ created: { $datetime: { range: { gt: "2024-01-01" } } } }Supported by: Qdrant`$hasId`Vector ID existence check{ $hasId: \["id1", "id2"] }Supported by: Qdrant`$hasVector`Vector existence check{ $hasVector: true }Supported by: Qdrant
|
|
50
50
|
|
|
51
51
|
## Common rules and restrictions
|
|
52
52
|
|
|
@@ -124,6 +124,14 @@ const results = await store.query({
|
|
|
124
124
|
- Empty arrays in conditions are handled gracefully
|
|
125
125
|
- Metadata is stored in a JSONB column for efficient querying
|
|
126
126
|
|
|
127
|
+
### OracleDB
|
|
128
|
+
|
|
129
|
+
- Metadata is stored as Oracle JSON alongside each `VECTOR` row
|
|
130
|
+
- Scalar comparisons use `JSON_VALUE`, while array, existence, and element-match checks use `JSON_EXISTS`
|
|
131
|
+
- `$regex` uses Oracle `REGEXP_LIKE`; string `$contains` uses case-insensitive `LIKE`
|
|
132
|
+
- Nested fields are supported with dot notation and are converted to quoted Oracle JSON paths
|
|
133
|
+
- User-provided metadata values are bound as parameters instead of interpolated into SQL
|
|
134
|
+
|
|
127
135
|
### PgVector
|
|
128
136
|
|
|
129
137
|
- Full support for PostgreSQL's native JSON querying capabilities
|
|
@@ -211,6 +219,7 @@ const results = await store.query({
|
|
|
211
219
|
- [Cloudflare Vectorize](https://mastra.ai/reference/vectors/vectorize)
|
|
212
220
|
- [libSQL](https://mastra.ai/reference/vectors/libsql)
|
|
213
221
|
- [MongoDB](https://mastra.ai/reference/vectors/mongodb)
|
|
222
|
+
- [OracleDB](https://mastra.ai/reference/vectors/oracledb)
|
|
214
223
|
- [PgStore](https://mastra.ai/reference/vectors/pg)
|
|
215
224
|
- [Pinecone](https://mastra.ai/reference/vectors/pinecone)
|
|
216
225
|
- [Qdrant](https://mastra.ai/reference/vectors/qdrant)
|
|
@@ -22,6 +22,8 @@ registerApiRoute("/items/:itemId", { ... })
|
|
|
22
22
|
|
|
23
23
|
Custom route paths can't start with the server's configured `apiPrefix` (default: `/api`), as that prefix is reserved for built-in Mastra routes. If you set a custom `apiPrefix`, only that prefix is reserved. For example, with `apiPrefix: '/mastra/api'`, paths like `/api/my-endpoint` are allowed.
|
|
24
24
|
|
|
25
|
+
> **Warning:** The default auth configuration protects `/api/*` and treats `/api`, `/api/auth/*` as public. When you change `apiPrefix`, those defaults no longer match and built-in routes fall outside the protected pattern. Update `server.auth.protected` and `server.auth.public` to reference the new prefix, and update any client code (including `MastraClient` `apiPrefix`) that hits `/api/*`.
|
|
26
|
+
|
|
25
27
|
### options
|
|
26
28
|
|
|
27
29
|
**method** (`'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'ALL'`): HTTP method for the route
|
|
@@ -171,30 +171,44 @@ The route returns:
|
|
|
171
171
|
|
|
172
172
|
## Workflows
|
|
173
173
|
|
|
174
|
-
| Method | Path | Description
|
|
175
|
-
| ------ | ----------------------------------------- |
|
|
176
|
-
| `GET` | `/api/workflows` | List all workflows
|
|
177
|
-
| `GET` | `/api/workflows
|
|
178
|
-
| `
|
|
179
|
-
| `POST` | `/api/workflows/:workflowId/
|
|
180
|
-
| `POST` | `/api/workflows/:workflowId/
|
|
181
|
-
| `POST` | `/api/workflows/:workflowId/
|
|
182
|
-
| `POST` | `/api/workflows/:workflowId/resume
|
|
183
|
-
| `
|
|
184
|
-
| `GET` | `/api/workflows/:workflowId/runs
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
174
|
+
| Method | Path | Description |
|
|
175
|
+
| ------ | ----------------------------------------- | ----------------------------------------------------- |
|
|
176
|
+
| `GET` | `/api/workflows` | List all workflows |
|
|
177
|
+
| `GET` | `/api/workflows/run-counts` | Get per-workflow counts of running and suspended runs |
|
|
178
|
+
| `GET` | `/api/workflows/:workflowId` | Get workflow by ID |
|
|
179
|
+
| `POST` | `/api/workflows/:workflowId/create-run` | Create a new workflow run |
|
|
180
|
+
| `POST` | `/api/workflows/:workflowId/start-async` | Start workflow and await result |
|
|
181
|
+
| `POST` | `/api/workflows/:workflowId/stream` | Stream workflow execution |
|
|
182
|
+
| `POST` | `/api/workflows/:workflowId/resume` | Resume suspended workflow |
|
|
183
|
+
| `POST` | `/api/workflows/:workflowId/resume-async` | Resume asynchronously |
|
|
184
|
+
| `GET` | `/api/workflows/:workflowId/runs` | List workflow runs |
|
|
185
|
+
| `GET` | `/api/workflows/:workflowId/runs/:runId` | Get specific run |
|
|
186
|
+
|
|
187
|
+
### Run counts response
|
|
188
|
+
|
|
189
|
+
The `/api/workflows/run-counts` endpoint returns counts of `running` and [`suspended`](https://mastra.ai/docs/workflows/suspend-and-resume) runs for every registered workflow. The record is keyed by the workflow's registry key from the Mastra config, and the server may cache the response for a few seconds:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
{
|
|
193
|
+
[workflowRegistryKey: string]: {
|
|
194
|
+
running: number;
|
|
195
|
+
suspended: number;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Dynamic workflows
|
|
201
|
+
|
|
202
|
+
Dynamic workflow definitions (beta) are workflows expressed as JSON, persisted through the `workflowDefinitions` storage domain, and live-registered on the running instance. See [Dynamic workflows](https://mastra.ai/docs/workflows/dynamic-workflows).
|
|
203
|
+
|
|
204
|
+
| Method | Path | Description |
|
|
205
|
+
| -------- | ------------------------------------------ | ------------------------------------------------------------------------------ |
|
|
206
|
+
| `GET` | `/api/stored/workflows` | List dynamic workflow definitions, filterable by `status` and `authorId` |
|
|
207
|
+
| `GET` | `/api/stored/workflows/:dynamicWorkflowId` | Get a dynamic workflow definition by ID |
|
|
208
|
+
| `POST` | `/api/stored/workflows` | Upsert a definition (plus optional helper `dependencies`) and live-register it |
|
|
209
|
+
| `DELETE` | `/api/stored/workflows/:dynamicWorkflowId` | Delete a dynamic workflow definition and unregister the live workflow |
|
|
210
|
+
|
|
211
|
+
On authenticated servers, the read routes require the `stored-workflows:read` permission and the write routes require `stored-workflows:write`. Registered dynamic workflows are executed through the ordinary `/api/workflows/:workflowId` routes above.
|
|
198
212
|
|
|
199
213
|
### Create run request body
|
|
200
214
|
|
|
@@ -251,6 +251,64 @@ const memoryStore = await storage.getStore('memory')
|
|
|
251
251
|
const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
+
## Closing connections
|
|
255
|
+
|
|
256
|
+
`close()` releases the connections of the stores a composite was built from: the `default` and `editor` stores, plus any domain that owns its own client. Each store is closed once, even when it backs several domains. When passed to the Mastra class, `close()` is called by `shutdown()`:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
260
|
+
import { PostgresStore } from '@mastra/pg'
|
|
261
|
+
import { Mastra } from '@mastra/core'
|
|
262
|
+
|
|
263
|
+
const pgStore = new PostgresStore({
|
|
264
|
+
id: 'pg-storage',
|
|
265
|
+
connectionString: process.env.DATABASE_URL,
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
export const mastra = new Mastra({
|
|
269
|
+
storage: new MastraCompositeStore({ id: 'composite', default: pgStore }),
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
process.on('SIGTERM', async () => {
|
|
273
|
+
// Releases the Postgres pool, so the process can exit
|
|
274
|
+
await mastra.shutdown()
|
|
275
|
+
})
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
A store you construct only to supply a domain isn't reachable through the composite. Keep a reference to it and close it yourself:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
282
|
+
import { ClickhouseStore } from '@mastra/clickhouse'
|
|
283
|
+
import { PostgresStore } from '@mastra/pg'
|
|
284
|
+
import { Mastra } from '@mastra/core'
|
|
285
|
+
|
|
286
|
+
const pgStore = new PostgresStore({
|
|
287
|
+
id: 'pg-storage',
|
|
288
|
+
connectionString: process.env.DATABASE_URL,
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
const clickhouseStore = new ClickhouseStore({
|
|
292
|
+
id: 'clickhouse-storage',
|
|
293
|
+
url: process.env.CLICKHOUSE_URL,
|
|
294
|
+
username: process.env.CLICKHOUSE_USERNAME,
|
|
295
|
+
password: process.env.CLICKHOUSE_PASSWORD,
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
export const mastra = new Mastra({
|
|
299
|
+
storage: new MastraCompositeStore({
|
|
300
|
+
id: 'composite',
|
|
301
|
+
default: pgStore,
|
|
302
|
+
domains: { observability: clickhouseStore.stores?.observability },
|
|
303
|
+
}),
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
process.on('SIGTERM', async () => {
|
|
307
|
+
await mastra.shutdown()
|
|
308
|
+
await clickhouseStore.close()
|
|
309
|
+
})
|
|
310
|
+
```
|
|
311
|
+
|
|
254
312
|
## Use cases
|
|
255
313
|
|
|
256
314
|
### Separate databases for different workloads
|