@mastra/mcp-docs-server 1.2.13-alpha.1 → 1.2.13-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +2 -2
- package/.docs/docs/agents/using-tools.md +29 -0
- package/.docs/docs/{evals/datasets → datasets}/overview.md +3 -3
- package/.docs/docs/{evals/datasets → datasets}/running-experiments.md +27 -3
- package/.docs/docs/deployment/workers.md +14 -14
- package/.docs/docs/editor/overview.md +201 -206
- package/.docs/docs/evals/evals-with-memory.md +1 -1
- package/.docs/docs/getting-started/develop.md +196 -0
- package/.docs/docs/index.md +78 -1
- package/.docs/docs/long-running-agents/durable-agents.md +2 -2
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/workspaces.md +152 -0
- package/.docs/docs/memory/observational-memory.md +53 -13
- package/.docs/docs/memory/overview.md +14 -0
- package/.docs/docs/server/auth/workers.md +7 -5
- package/.docs/docs/server/mastra-client.md +60 -0
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/studio/observability.md +4 -0
- package/.docs/docs/studio/overview.md +2 -2
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +1 -0
- package/.docs/docs/workspace/search.md +1 -1
- package/.docs/guides/deployment/kubernetes.md +2 -0
- package/.docs/guides/deployment/mastra-workers.md +350 -6
- package/.docs/guides/deployment/vercel.md +2 -0
- package/.docs/guides/getting-started/quickstart.md +3 -3
- package/.docs/{docs → guides}/rag/chunking-and-embedding.md +1 -1
- package/.docs/{docs → guides}/rag/graph-rag.md +1 -1
- package/.docs/{docs → guides}/rag/overview.md +2 -2
- package/.docs/{docs → guides}/rag/retrieval.md +1 -1
- package/.docs/{docs → guides}/voice/overview.md +4 -4
- package/.docs/{docs → guides}/voice/realtime-voice.md +2 -2
- package/.docs/{docs → guides}/voice/speech-to-speech.md +1 -1
- package/.docs/{docs → guides}/voice/speech-to-text.md +1 -1
- package/.docs/{docs → guides}/voice/text-to-speech.md +2 -2
- package/.docs/models/embeddings.md +63 -65
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/openrouter.md +3 -6
- package/.docs/models/gateways/vercel.md +4 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/crof.md +2 -1
- package/.docs/models/providers/crossmodel.md +4 -3
- package/.docs/models/providers/empiriolabs.md +2 -1
- package/.docs/models/providers/huggingface.md +3 -1
- package/.docs/models/providers/hyper.md +10 -7
- package/.docs/models/providers/llmgateway.md +5 -4
- package/.docs/models/providers/minimax.md +1 -1
- package/.docs/models/providers/neuralwatt.md +3 -1
- package/.docs/models/providers/openai.md +2 -2
- package/.docs/models/providers/opencode-go.md +2 -1
- package/.docs/models/providers/opencode.md +1 -1
- package/.docs/models/providers/perplexity-agent.md +3 -1
- package/.docs/models/providers/scaleway.md +1 -3
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/zai-coding-plan.md +11 -13
- package/.docs/models/providers/zhipuai-coding-plan.md +12 -12
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/durable-agent.md +12 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/{docs/getting-started → reference}/build-with-ai.md +5 -110
- package/.docs/reference/cli/create-mastra.md +2 -0
- package/.docs/reference/cli/mastra.md +36 -16
- package/.docs/reference/client-js/agents.md +1 -1
- package/.docs/reference/configuration.md +2 -2
- package/.docs/reference/core/getEditor.md +1 -1
- package/.docs/reference/core/getVector.md +2 -2
- package/.docs/reference/core/listVectors.md +2 -2
- package/.docs/reference/core/mastra-class.md +2 -2
- package/.docs/reference/datasets/startExperiment.md +6 -0
- package/.docs/reference/datasets/startExperimentAsync.md +4 -0
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +1 -1
- package/.docs/reference/editor/mastra-editor.md +31 -18
- package/.docs/reference/editor/prompt-blocks.md +137 -0
- package/.docs/reference/editor/sandbox-provider.md +1 -1
- package/.docs/reference/editor/storage-browser-ref.md +3 -3
- package/.docs/reference/editor/storage-workspace-ref.md +3 -3
- package/.docs/reference/editor/tool-provider.md +44 -10
- package/.docs/reference/editor/tools.md +100 -0
- package/.docs/reference/editor/versioning.md +130 -0
- package/.docs/reference/evals/mastra-scorer.md +68 -8
- package/.docs/reference/evals/summarization.md +203 -0
- package/.docs/reference/file-based-agents/config.md +39 -1
- package/.docs/reference/index.md +4 -4
- package/.docs/reference/memory/observational-memory.md +76 -24
- package/.docs/reference/memory/serialized-memory-config.md +3 -3
- package/.docs/reference/observability/tracing/interfaces.md +6 -1
- package/.docs/reference/processors/processor-interface.md +14 -2
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +15 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/rag/database-config.md +1 -1
- package/.docs/reference/storage/composite.md +2 -0
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/vectors/mongodb.md +13 -13
- package/.docs/reference/voice/livekit.md +3 -3
- package/.docs/reference/workers/overview.md +10 -8
- package/.docs/reference/workspace/platform-filesystem.md +8 -5
- package/.docs/reference/workspace/platform-sandbox.md +83 -7
- package/CHANGELOG.md +44 -0
- package/README.md +1 -1
- package/package.json +5 -5
- package/.docs/docs/agent-builder/access-control.md +0 -99
- package/.docs/docs/agent-builder/browser.md +0 -63
- package/.docs/docs/agent-builder/channels.md +0 -78
- package/.docs/docs/agent-builder/configuration.md +0 -132
- package/.docs/docs/agent-builder/deploying.md +0 -124
- package/.docs/docs/agent-builder/integrations.md +0 -115
- package/.docs/docs/agent-builder/memory.md +0 -69
- package/.docs/docs/agent-builder/model-policy.md +0 -50
- package/.docs/docs/agent-builder/overview.md +0 -114
- package/.docs/docs/agent-builder/skill-registries.md +0 -31
- package/.docs/docs/agent-builder/workspace.md +0 -62
- package/.docs/docs/editor/prompts.md +0 -140
- package/.docs/docs/editor/tools.md +0 -148
- package/.docs/docs/getting-started/file-based-agents.md +0 -121
- package/.docs/docs/mastra-platform/workspace.md +0 -111
- package/.docs/docs/what-is-mastra.md +0 -161
- package/.docs/reference/client-js/agent-builder.md +0 -163
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +0 -76
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +0 -79
- package/.docs/reference/editor/agent-builder/builder-models.md +0 -66
- /package/.docs/{docs → guides}/getting-started/manual-install.md +0 -0
- /package/.docs/{docs → guides}/rag/vector-databases.md +0 -0
|
@@ -69,6 +69,66 @@ The Mastra Client SDK exposes all resources served by the Mastra Server.
|
|
|
69
69
|
- **[Logs](https://mastra.ai/reference/client-js/logs)**: View logs and debug system behavior.
|
|
70
70
|
- **[Telemetry](https://mastra.ai/reference/client-js/telemetry)**: View app performance and trace activity.
|
|
71
71
|
|
|
72
|
+
## Create and run stored workflows
|
|
73
|
+
|
|
74
|
+
Use `upsertStoredWorkflow()` to create or replace a persisted workflow definition. A successful upsert validates the complete definition, registers it with the running Mastra instance, and makes it available through the standard workflow execution API.
|
|
75
|
+
|
|
76
|
+
The following example creates a mapping workflow, reads the stored definition, runs it, and then deletes it:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { MastraClient } from '@mastra/client-js'
|
|
80
|
+
import type { UpsertStoredWorkflowParams } from '@mastra/client-js'
|
|
81
|
+
|
|
82
|
+
const client = new MastraClient({
|
|
83
|
+
baseUrl: process.env.MASTRA_API_URL || 'http://localhost:4111',
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const definition = {
|
|
87
|
+
id: 'greeting-workflow',
|
|
88
|
+
description: 'Returns a greeting for the supplied name',
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: { name: { type: 'string' } },
|
|
92
|
+
required: ['name'],
|
|
93
|
+
},
|
|
94
|
+
outputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: { message: { type: 'string' } },
|
|
97
|
+
required: ['message'],
|
|
98
|
+
},
|
|
99
|
+
graph: [
|
|
100
|
+
{
|
|
101
|
+
type: 'mapping',
|
|
102
|
+
id: 'create-greeting',
|
|
103
|
+
mapConfig: JSON.stringify({
|
|
104
|
+
message: { template: 'Hello, ${initData.name}!' },
|
|
105
|
+
}),
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
} satisfies UpsertStoredWorkflowParams
|
|
109
|
+
|
|
110
|
+
await client.upsertStoredWorkflow(definition)
|
|
111
|
+
|
|
112
|
+
const storedWorkflow = client.getStoredWorkflow(definition.id)
|
|
113
|
+
const storedDefinition = await storedWorkflow.details()
|
|
114
|
+
|
|
115
|
+
const workflow = client.getWorkflow(storedDefinition.id)
|
|
116
|
+
const run = await workflow.createRun()
|
|
117
|
+
const result = await run.startAsync({ inputData: { name: 'Ada' } })
|
|
118
|
+
|
|
119
|
+
console.log(result)
|
|
120
|
+
|
|
121
|
+
await storedWorkflow.delete()
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Use `listStoredWorkflows()` to list persisted definitions. Calling `upsertStoredWorkflow()` again with the same `id` replaces the stored definition and live workflow registration.
|
|
125
|
+
|
|
126
|
+
> **Warning:** Durable storage requires a configured storage adapter that supports the `workflowDefinitions` domain. Without that domain, Core can register a workflow in memory, but the server's stored-workflow API can't preserve it across restarts.
|
|
127
|
+
>
|
|
128
|
+
> Stored definitions support declarative agent, tool, mapping, nested workflow, parallel, foreach, sleep, sleep-until, conditional, and loop entries. They can't contain JavaScript closures. Conditional and loop logic must use the declarative predicate format, and referenced agents, tools, and nested workflows must already be registered.
|
|
129
|
+
>
|
|
130
|
+
> Authenticated servers require `stored-workflows:read` or `stored-workflows:write` for definition operations and `workflows:execute` to run the workflow.
|
|
131
|
+
|
|
72
132
|
## Generating responses
|
|
73
133
|
|
|
74
134
|
Call `.generate()` with a string prompt:
|
|
@@ -124,6 +124,6 @@ Visit the [PubSub reference](https://mastra.ai/reference/pubsub/base) for the fu
|
|
|
124
124
|
|
|
125
125
|
- [PubSub reference](https://mastra.ai/reference/pubsub/base)
|
|
126
126
|
- [Mastra class](https://mastra.ai/reference/core/mastra-class)
|
|
127
|
+
- [Workers](https://mastra.ai/docs/deployment/workers): Run workflow orchestration and background tasks in dedicated processes using PubSub
|
|
127
128
|
- [Background task streaming](https://mastra.ai/docs/long-running-agents/background-tasks)
|
|
128
|
-
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows)
|
|
129
|
-
- [Workers](https://mastra.ai/docs/deployment/workers): Run workflow orchestration and background tasks in dedicated processes using PubSub
|
|
129
|
+
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows)
|
|
@@ -96,6 +96,10 @@ Visit the [metrics overview](https://mastra.ai/docs/observability/metrics/overvi
|
|
|
96
96
|
|
|
97
97
|
When you run an agent or workflow, the Observability tab displays traces that highlight the key AI operations such as model calls, tool executions, and workflow steps. Follow these traces to see how data moves, where time is spent, and what's happening under the hood.
|
|
98
98
|
|
|
99
|
+
Above the trace list, open **Columns** to show or hide input, entity, duration, input token, output token, estimated cost, and custom metadata columns. To display custom metadata, add the top-level key used in `tracingOptions.metadata`. Studio saves the selection in browser storage for the current Mastra server and API prefix.
|
|
100
|
+
|
|
101
|
+
Token and estimated cost columns require an observability store that supports metrics. These columns stay hidden in the **Branches** view because several branch rows can belong to the same trace.
|
|
102
|
+
|
|
99
103
|
Tracing filters out low-level framework details so your traces stay focused and readable. Visit the [tracing overview](https://mastra.ai/docs/observability/tracing/overview) for more details.
|
|
100
104
|
|
|
101
105
|
To export a trace, select **Download trace JSON** in the trace panel header. This saves the entire trace as a `trace-<id>.json` file, with every span and its full input, output, metadata, and attributes. Use it to share a trace or attach it to a bug report, or alternatively build an evaluation dataset offline.
|
|
@@ -103,13 +103,13 @@ The Scorers tab displays the results of your agent's scorers as they run. When m
|
|
|
103
103
|
|
|
104
104
|
Create and manage collections of test cases to evaluate your agents and workflows. Import items from CSV or JSON and define input and ground-truth schemas, plus pin to specific versions so you can reproduce experiments exactly. Run experiments with [scorers](https://mastra.ai/docs/evals/overview) to compare quality across prompts, models, or code changes.
|
|
105
105
|
|
|
106
|
-
See [datasets overview](https://mastra.ai/docs/
|
|
106
|
+
See [datasets overview](https://mastra.ai/docs/datasets/overview) for the full API and versioning details.
|
|
107
107
|
|
|
108
108
|
### Experiments
|
|
109
109
|
|
|
110
110
|
Run all items in a dataset against an agent, workflow, or scorer and collect the results in one place. Select a target, optionally attach scorers, and trigger the experiment. The results view shows each item's input, output, status, and individual score breakdowns. Compare two experiments side by side to measure the impact of prompt, model, or code changes.
|
|
111
111
|
|
|
112
|
-
See [datasets overview](https://mastra.ai/docs/
|
|
112
|
+
See [datasets overview](https://mastra.ai/docs/datasets/overview) for setup details.
|
|
113
113
|
|
|
114
114
|
## Observability
|
|
115
115
|
|
|
@@ -545,5 +545,5 @@ For a closer look at workflows, see our [Workflow Guide](https://mastra.ai/guide
|
|
|
545
545
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
546
546
|
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
547
547
|
- [Error Handling](https://mastra.ai/docs/workflows/error-handling)
|
|
548
|
-
- [Workers](https://mastra.ai/docs/deployment/workers):
|
|
548
|
+
- [Workers](https://mastra.ai/docs/deployment/workers): Run workflow execution in dedicated background processes
|
|
549
549
|
- 📹 [Agentic workflows with Mastra workshop](https://www.youtube.com/watch?v=HGt8pVPpX9g)
|
|
@@ -181,4 +181,5 @@ Manage Inngest schedules from the [Inngest dashboard](https://www.inngest.com/do
|
|
|
181
181
|
|
|
182
182
|
- [Workflow overview](https://mastra.ai/docs/workflows/overview)
|
|
183
183
|
- [Suspend and resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
184
|
+
- [Workers](https://mastra.ai/docs/deployment/workers): The [scheduler worker](https://mastra.ai/docs/deployment/workers) runs cron schedules in a dedicated process
|
|
184
185
|
- [Agent schedules](https://mastra.ai/docs/long-running-agents/schedules): Run an agent rather than a workflow on a cron schedule, and manage both schedule types at runtime through `mastra.schedules`.
|
|
@@ -280,5 +280,5 @@ When you configure search on a workspace, agents receive tools for searching and
|
|
|
280
280
|
## Related
|
|
281
281
|
|
|
282
282
|
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
283
|
-
- [RAG overview](https://mastra.ai/
|
|
283
|
+
- [RAG overview](https://mastra.ai/guides/rag/overview)
|
|
284
284
|
- [Workspace class reference](https://mastra.ai/reference/workspace/workspace-class)
|
|
@@ -294,5 +294,7 @@ The pod that handles the approval loads the suspended run from Postgres. It then
|
|
|
294
294
|
|
|
295
295
|
- [PubSub](https://mastra.ai/docs/server/pubsub)
|
|
296
296
|
- [Durable agents](https://mastra.ai/docs/long-running-agents/durable-agents)
|
|
297
|
+
- [Workers](https://mastra.ai/docs/deployment/workers): Split background processing into separate containers on Kubernetes
|
|
298
|
+
- [Worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers): Full Kubernetes manifests for orchestration, scheduler, and background task workers
|
|
297
299
|
- [Mastra server](https://mastra.ai/docs/server/mastra-server)
|
|
298
300
|
- [Deployment overview](https://mastra.ai/docs/deployment/overview)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Deploy Mastra workers
|
|
4
4
|
|
|
5
|
-
Run [Mastra workers](https://mastra.ai/docs/deployment/workers) as separate processes so you can scale orchestration, scheduling, and background tasks independently from the API. This guide walks through a fully split deployment using Docker Compose.
|
|
5
|
+
Run [Mastra workers](https://mastra.ai/docs/deployment/workers) as separate processes so you can scale orchestration, scheduling, and background tasks independently from the API. This guide walks through a fully split deployment using Docker Compose or Kubernetes.
|
|
6
6
|
|
|
7
7
|
> **Info:** This guide covers splitting workers into their own containers. If you only need workers to run in-process alongside the API, see [Workers](https://mastra.ai/docs/deployment/workers). No extra setup is required.
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Run [Mastra workers](https://mastra.ai/docs/deployment/workers) as separate proc
|
|
|
11
11
|
You'll need:
|
|
12
12
|
|
|
13
13
|
- A [Mastra application](https://mastra.ai/guides/getting-started/quickstart)
|
|
14
|
-
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/)
|
|
14
|
+
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/), or a [Kubernetes](https://kubernetes.io/docs/setup/) cluster with [`kubectl`](https://kubernetes.io/docs/tasks/tools/)
|
|
15
15
|
- A distributed PubSub backend: [Redis](https://redis.io/) for [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), or a [Google Cloud](https://cloud.google.com/) project for [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)
|
|
16
16
|
- A shared database reachable from every container. See [supported storage backends](https://mastra.ai/reference/workers/overview) for the full list.
|
|
17
17
|
|
|
@@ -83,9 +83,13 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
83
83
|
CMD ["node", "index.mjs"]
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
3.
|
|
86
|
+
3. Define the fully split topology. The setup runs six services: a database, a PubSub backend, the API server, and three workers. Each worker runs the same image with a different `MASTRA_WORKERS` value to control which worker starts.
|
|
87
87
|
|
|
88
|
-
The API
|
|
88
|
+
The API sets `MASTRA_WORKERS: "false"` to disable all event processing. The orchestration worker sets `MASTRA_STEP_EXECUTION_URL` to point step execution requests at the API's internal URL. See [step execution URL](#step-execution-url) for details.
|
|
89
|
+
|
|
90
|
+
All services share a `MASTRA_WORKER_AUTH_TOKEN`. Workers include this token in requests to the API so the API can verify the caller is a trusted internal service. See [worker authentication](https://mastra.ai/docs/server/auth/workers) for details.
|
|
91
|
+
|
|
92
|
+
**Docker Compose**:
|
|
89
93
|
|
|
90
94
|
```yaml
|
|
91
95
|
services:
|
|
@@ -123,6 +127,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
123
127
|
DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
|
|
124
128
|
REDIS_URL: redis://redis:6379
|
|
125
129
|
MASTRA_WORKERS: 'false'
|
|
130
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
126
131
|
depends_on:
|
|
127
132
|
postgres:
|
|
128
133
|
condition: service_healthy
|
|
@@ -141,6 +146,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
141
146
|
REDIS_URL: redis://redis:6379
|
|
142
147
|
MASTRA_WORKERS: orchestration
|
|
143
148
|
MASTRA_STEP_EXECUTION_URL: http://api:4111/api
|
|
149
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
144
150
|
depends_on:
|
|
145
151
|
api:
|
|
146
152
|
condition: service_healthy
|
|
@@ -151,6 +157,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
151
157
|
DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
|
|
152
158
|
REDIS_URL: redis://redis:6379
|
|
153
159
|
MASTRA_WORKERS: scheduler
|
|
160
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
154
161
|
depends_on:
|
|
155
162
|
api:
|
|
156
163
|
condition: service_healthy
|
|
@@ -161,6 +168,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
161
168
|
DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
|
|
162
169
|
REDIS_URL: redis://redis:6379
|
|
163
170
|
MASTRA_WORKERS: backgroundTasks
|
|
171
|
+
MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
|
|
164
172
|
depends_on:
|
|
165
173
|
api:
|
|
166
174
|
condition: service_healthy
|
|
@@ -173,11 +181,296 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
173
181
|
|
|
174
182
|
```bash
|
|
175
183
|
POSTGRES_PASSWORD=your-secure-password
|
|
184
|
+
MASTRA_WORKER_AUTH_TOKEN=your-shared-secret-token
|
|
176
185
|
```
|
|
177
186
|
|
|
178
187
|
> **Note:** Remember to set any other environment variables your application needs (e.g., your [model provider](https://mastra.ai/models/providers) API key).
|
|
179
188
|
|
|
180
|
-
|
|
189
|
+
**Kubernetes**:
|
|
190
|
+
|
|
191
|
+
Create a namespace and a Secret with your connection strings:
|
|
192
|
+
|
|
193
|
+
```yaml
|
|
194
|
+
apiVersion: v1
|
|
195
|
+
kind: Namespace
|
|
196
|
+
metadata:
|
|
197
|
+
name: mastra-workers
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
kubectl apply -f k8s/namespace.yaml
|
|
202
|
+
kubectl create secret generic mastra-secrets -n mastra-workers \
|
|
203
|
+
--from-literal=POSTGRES_PASSWORD='your-password' \
|
|
204
|
+
--from-literal=DATABASE_URL='postgresql://mastra:your-password@postgres:5432/mastra' \
|
|
205
|
+
--from-literal=REDIS_URL='redis://redis:6379' \
|
|
206
|
+
--from-literal=MASTRA_WORKER_AUTH_TOKEN='your-shared-token'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
> **Note:** Add any other environment variables your application needs (e.g., your [model provider](https://mastra.ai/models/providers) API key) to the Secret or as additional `--from-literal` entries.
|
|
210
|
+
|
|
211
|
+
Build and push the Docker image to a registry your cluster can pull from:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
docker build -t your-registry/mastra-workers:latest ./app
|
|
215
|
+
docker push your-registry/mastra-workers:latest
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Apply Deployments and Services for the database, PubSub backend, API, and three workers. The example below uses in-cluster Postgres and Redis. In production, use managed services (e.g., Amazon RDS, Cloud SQL, ElastiCache, Memorystore).
|
|
219
|
+
|
|
220
|
+
```yaml
|
|
221
|
+
apiVersion: apps/v1
|
|
222
|
+
kind: Deployment
|
|
223
|
+
metadata:
|
|
224
|
+
name: postgres
|
|
225
|
+
namespace: mastra-workers
|
|
226
|
+
spec:
|
|
227
|
+
replicas: 1
|
|
228
|
+
selector:
|
|
229
|
+
matchLabels:
|
|
230
|
+
app: postgres
|
|
231
|
+
template:
|
|
232
|
+
metadata:
|
|
233
|
+
labels:
|
|
234
|
+
app: postgres
|
|
235
|
+
spec:
|
|
236
|
+
containers:
|
|
237
|
+
- name: postgres
|
|
238
|
+
image: postgres:16-alpine
|
|
239
|
+
ports:
|
|
240
|
+
- containerPort: 5432
|
|
241
|
+
env:
|
|
242
|
+
- name: POSTGRES_USER
|
|
243
|
+
value: mastra
|
|
244
|
+
- name: POSTGRES_PASSWORD
|
|
245
|
+
valueFrom:
|
|
246
|
+
secretKeyRef:
|
|
247
|
+
name: mastra-secrets
|
|
248
|
+
key: POSTGRES_PASSWORD
|
|
249
|
+
- name: POSTGRES_DB
|
|
250
|
+
value: mastra
|
|
251
|
+
volumeMounts:
|
|
252
|
+
- name: pgdata
|
|
253
|
+
mountPath: /var/lib/postgresql/data
|
|
254
|
+
volumes:
|
|
255
|
+
- name: pgdata
|
|
256
|
+
emptyDir: {}
|
|
257
|
+
---
|
|
258
|
+
apiVersion: v1
|
|
259
|
+
kind: Service
|
|
260
|
+
metadata:
|
|
261
|
+
name: postgres
|
|
262
|
+
namespace: mastra-workers
|
|
263
|
+
spec:
|
|
264
|
+
selector:
|
|
265
|
+
app: postgres
|
|
266
|
+
ports:
|
|
267
|
+
- port: 5432
|
|
268
|
+
targetPort: 5432
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
> **Caution:** The Postgres example above uses `emptyDir` for storage, which means data is lost when the pod restarts. In production, replace it with a `PersistentVolumeClaim` or use a managed database service.
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
apiVersion: apps/v1
|
|
275
|
+
kind: Deployment
|
|
276
|
+
metadata:
|
|
277
|
+
name: redis
|
|
278
|
+
namespace: mastra-workers
|
|
279
|
+
spec:
|
|
280
|
+
replicas: 1
|
|
281
|
+
selector:
|
|
282
|
+
matchLabels:
|
|
283
|
+
app: redis
|
|
284
|
+
template:
|
|
285
|
+
metadata:
|
|
286
|
+
labels:
|
|
287
|
+
app: redis
|
|
288
|
+
spec:
|
|
289
|
+
containers:
|
|
290
|
+
- name: redis
|
|
291
|
+
image: redis:7-alpine
|
|
292
|
+
args: ['--appendonly', 'yes']
|
|
293
|
+
ports:
|
|
294
|
+
- containerPort: 6379
|
|
295
|
+
---
|
|
296
|
+
apiVersion: v1
|
|
297
|
+
kind: Service
|
|
298
|
+
metadata:
|
|
299
|
+
name: redis
|
|
300
|
+
namespace: mastra-workers
|
|
301
|
+
spec:
|
|
302
|
+
selector:
|
|
303
|
+
app: redis
|
|
304
|
+
ports:
|
|
305
|
+
- port: 6379
|
|
306
|
+
targetPort: 6379
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
```yaml
|
|
310
|
+
apiVersion: apps/v1
|
|
311
|
+
kind: Deployment
|
|
312
|
+
metadata:
|
|
313
|
+
name: api
|
|
314
|
+
namespace: mastra-workers
|
|
315
|
+
spec:
|
|
316
|
+
replicas: 1
|
|
317
|
+
selector:
|
|
318
|
+
matchLabels:
|
|
319
|
+
app: api
|
|
320
|
+
template:
|
|
321
|
+
metadata:
|
|
322
|
+
labels:
|
|
323
|
+
app: api
|
|
324
|
+
spec:
|
|
325
|
+
containers:
|
|
326
|
+
- name: api
|
|
327
|
+
image: your-registry/mastra-workers:latest
|
|
328
|
+
ports:
|
|
329
|
+
- containerPort: 4111
|
|
330
|
+
env:
|
|
331
|
+
- name: MASTRA_WORKERS
|
|
332
|
+
value: 'false'
|
|
333
|
+
envFrom:
|
|
334
|
+
- secretRef:
|
|
335
|
+
name: mastra-secrets
|
|
336
|
+
readinessProbe:
|
|
337
|
+
httpGet:
|
|
338
|
+
path: /api/agents
|
|
339
|
+
port: 4111
|
|
340
|
+
initialDelaySeconds: 10
|
|
341
|
+
periodSeconds: 5
|
|
342
|
+
livenessProbe:
|
|
343
|
+
httpGet:
|
|
344
|
+
path: /api/agents
|
|
345
|
+
port: 4111
|
|
346
|
+
initialDelaySeconds: 15
|
|
347
|
+
periodSeconds: 10
|
|
348
|
+
resources:
|
|
349
|
+
requests:
|
|
350
|
+
cpu: 500m
|
|
351
|
+
memory: 512Mi
|
|
352
|
+
---
|
|
353
|
+
apiVersion: v1
|
|
354
|
+
kind: Service
|
|
355
|
+
metadata:
|
|
356
|
+
name: api
|
|
357
|
+
namespace: mastra-workers
|
|
358
|
+
spec:
|
|
359
|
+
selector:
|
|
360
|
+
app: api
|
|
361
|
+
ports:
|
|
362
|
+
- port: 4111
|
|
363
|
+
targetPort: 4111
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
```yaml
|
|
367
|
+
apiVersion: apps/v1
|
|
368
|
+
kind: Deployment
|
|
369
|
+
metadata:
|
|
370
|
+
name: orchestration-worker
|
|
371
|
+
namespace: mastra-workers
|
|
372
|
+
spec:
|
|
373
|
+
replicas: 1
|
|
374
|
+
selector:
|
|
375
|
+
matchLabels:
|
|
376
|
+
app: orchestration-worker
|
|
377
|
+
template:
|
|
378
|
+
metadata:
|
|
379
|
+
labels:
|
|
380
|
+
app: orchestration-worker
|
|
381
|
+
spec:
|
|
382
|
+
containers:
|
|
383
|
+
- name: worker
|
|
384
|
+
image: your-registry/mastra-workers:latest
|
|
385
|
+
env:
|
|
386
|
+
- name: MASTRA_WORKERS
|
|
387
|
+
value: orchestration
|
|
388
|
+
- name: MASTRA_STEP_EXECUTION_URL
|
|
389
|
+
value: http://api:4111/api
|
|
390
|
+
envFrom:
|
|
391
|
+
- secretRef:
|
|
392
|
+
name: mastra-secrets
|
|
393
|
+
resources:
|
|
394
|
+
requests:
|
|
395
|
+
cpu: 250m
|
|
396
|
+
memory: 256Mi
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
```yaml
|
|
400
|
+
apiVersion: apps/v1
|
|
401
|
+
kind: Deployment
|
|
402
|
+
metadata:
|
|
403
|
+
name: scheduler-worker
|
|
404
|
+
namespace: mastra-workers
|
|
405
|
+
spec:
|
|
406
|
+
replicas: 1
|
|
407
|
+
selector:
|
|
408
|
+
matchLabels:
|
|
409
|
+
app: scheduler-worker
|
|
410
|
+
template:
|
|
411
|
+
metadata:
|
|
412
|
+
labels:
|
|
413
|
+
app: scheduler-worker
|
|
414
|
+
spec:
|
|
415
|
+
containers:
|
|
416
|
+
- name: worker
|
|
417
|
+
image: your-registry/mastra-workers:latest
|
|
418
|
+
env:
|
|
419
|
+
- name: MASTRA_WORKERS
|
|
420
|
+
value: scheduler
|
|
421
|
+
envFrom:
|
|
422
|
+
- secretRef:
|
|
423
|
+
name: mastra-secrets
|
|
424
|
+
resources:
|
|
425
|
+
requests:
|
|
426
|
+
cpu: 250m
|
|
427
|
+
memory: 256Mi
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
```yaml
|
|
431
|
+
apiVersion: apps/v1
|
|
432
|
+
kind: Deployment
|
|
433
|
+
metadata:
|
|
434
|
+
name: background-task-worker
|
|
435
|
+
namespace: mastra-workers
|
|
436
|
+
spec:
|
|
437
|
+
replicas: 1
|
|
438
|
+
selector:
|
|
439
|
+
matchLabels:
|
|
440
|
+
app: background-task-worker
|
|
441
|
+
template:
|
|
442
|
+
metadata:
|
|
443
|
+
labels:
|
|
444
|
+
app: background-task-worker
|
|
445
|
+
spec:
|
|
446
|
+
containers:
|
|
447
|
+
- name: worker
|
|
448
|
+
image: your-registry/mastra-workers:latest
|
|
449
|
+
env:
|
|
450
|
+
- name: MASTRA_WORKERS
|
|
451
|
+
value: backgroundTasks
|
|
452
|
+
envFrom:
|
|
453
|
+
- secretRef:
|
|
454
|
+
name: mastra-secrets
|
|
455
|
+
resources:
|
|
456
|
+
requests:
|
|
457
|
+
cpu: 250m
|
|
458
|
+
memory: 256Mi
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Apply all manifests and wait for the API to become ready:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
kubectl apply -f k8s/
|
|
465
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=api --timeout=90s
|
|
466
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=orchestration-worker --timeout=60s
|
|
467
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=scheduler-worker --timeout=60s
|
|
468
|
+
kubectl wait -n mastra-workers --for=condition=ready pod -l app=background-task-worker --timeout=60s
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
4. Verify the stack is running and the API responds:
|
|
472
|
+
|
|
473
|
+
**Docker Compose**:
|
|
181
474
|
|
|
182
475
|
```bash
|
|
183
476
|
docker compose up -d
|
|
@@ -185,6 +478,21 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
|
|
|
185
478
|
curl http://localhost:4111/api/agents
|
|
186
479
|
```
|
|
187
480
|
|
|
481
|
+
**Kubernetes**:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
kubectl get pods -n mastra-workers
|
|
485
|
+
kubectl port-forward -n mastra-workers svc/api 4111:4111
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
In a separate terminal:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
curl http://localhost:4111/api/agents
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
A JSON list of your agents confirms the API and workers are running.
|
|
495
|
+
|
|
188
496
|
## Step execution URL
|
|
189
497
|
|
|
190
498
|
In a fully split deployment, the orchestration worker runs in a separate container from the API. When it processes a workflow event, it delegates step execution to the API over HTTP.
|
|
@@ -203,11 +511,46 @@ Without this variable, the orchestration worker attempts to execute steps in-pro
|
|
|
203
511
|
|
|
204
512
|
The orchestration and background task workers are safe to scale horizontally. PubSub consumer groups distribute events across instances, so each event is processed once:
|
|
205
513
|
|
|
514
|
+
**Docker Compose**:
|
|
515
|
+
|
|
206
516
|
```bash
|
|
207
517
|
docker compose up -d --scale orchestration-worker=3
|
|
208
518
|
docker compose up -d --scale background-task-worker=2
|
|
209
519
|
```
|
|
210
520
|
|
|
521
|
+
**Kubernetes**:
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
kubectl scale deployment/orchestration-worker -n mastra-workers --replicas=3
|
|
525
|
+
kubectl scale deployment/background-task-worker -n mastra-workers --replicas=2
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
For automatic scaling, add a HorizontalPodAutoscaler:
|
|
529
|
+
|
|
530
|
+
```yaml
|
|
531
|
+
apiVersion: autoscaling/v2
|
|
532
|
+
kind: HorizontalPodAutoscaler
|
|
533
|
+
metadata:
|
|
534
|
+
name: orchestration-worker
|
|
535
|
+
namespace: mastra-workers
|
|
536
|
+
spec:
|
|
537
|
+
scaleTargetRef:
|
|
538
|
+
apiVersion: apps/v1
|
|
539
|
+
kind: Deployment
|
|
540
|
+
name: orchestration-worker
|
|
541
|
+
minReplicas: 1
|
|
542
|
+
maxReplicas: 10
|
|
543
|
+
metrics:
|
|
544
|
+
- type: Resource
|
|
545
|
+
resource:
|
|
546
|
+
name: cpu
|
|
547
|
+
target:
|
|
548
|
+
type: Utilization
|
|
549
|
+
averageUtilization: 70
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
> **Note:** CPU-based autoscaling needs the [metrics-server](https://github.com/kubernetes-sigs/metrics-server) running in the cluster. Managed clusters like GKE, EKS, and AKS include it by default.
|
|
553
|
+
|
|
211
554
|
The API can also scale horizontally behind a load balancer.
|
|
212
555
|
|
|
213
556
|
**Don't scale the scheduler worker.** Run exactly one instance. Multiple schedulers polling the same storage fire duplicate events for the same schedule.
|
|
@@ -229,4 +572,5 @@ Workers recover from crashes because the distributed PubSub backend persists una
|
|
|
229
572
|
- [Workers reference](https://mastra.ai/reference/workers/overview): Configuration details for all worker types
|
|
230
573
|
- [CLI reference](https://mastra.ai/reference/cli/mastra): `mastra worker build` and `mastra worker start`
|
|
231
574
|
- [PubSub](https://mastra.ai/docs/server/pubsub): Event delivery backends
|
|
232
|
-
- [Deploy a Mastra server](https://mastra.ai/docs/deployment/mastra-server): Build output and server configuration
|
|
575
|
+
- [Deploy a Mastra server](https://mastra.ai/docs/deployment/mastra-server): Build output and server configuration
|
|
576
|
+
- [Deploy Mastra to Kubernetes](https://mastra.ai/guides/deployment/kubernetes): Multi-pod deployment with durable agents
|
|
@@ -86,6 +86,8 @@ export const mastra = new Mastra({
|
|
|
86
86
|
|
|
87
87
|
After deploying, Studio is available at the root URL (`https://<your-project>.vercel.app/`) and the API remains at `/api/*`. Studio automatically connects to the API on the same origin, so you don't need additional environment variables.
|
|
88
88
|
|
|
89
|
+
Studio serves its own pages from the CDN, and every other path goes to your server, so routes you add with [`registerApiRoute()`](https://mastra.ai/docs/server/custom-api-routes) stay reachable at their own paths. Avoid giving a custom route a path that Studio already uses (for example `/agents` or `/workflows`), since Studio claims those first.
|
|
90
|
+
|
|
89
91
|
> **Warning:** Once Studio is connected to your Mastra server, it has full access to your agents, workflows, and tools. Be sure to secure it properly in production (e.g. behind authentication, VPN, etc.) to prevent unauthorized access.
|
|
90
92
|
|
|
91
93
|
## Optional overrides
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# Mastra Quickstart
|
|
4
4
|
|
|
5
|
-
**For AI agents:** Create a new Mastra project non-interactively with `npm create mastra@latest <project-name> -- --llm <provider>`, replacing `<provider>` with `openai`, `anthropic`, `google`, or `xai`. For a minimal project without an agent or model provider, use `npm create mastra@latest <project-name> -- --empty`. To build a Mastra project from scratch, see the [manual installation guide](https://mastra.ai/
|
|
5
|
+
**For AI agents:** Create a new Mastra project non-interactively with `npm create mastra@latest <project-name> -- --llm <provider>`, replacing `<provider>` with `openai`, `anthropic`, `google`, or `xai`. For a minimal project without an agent or model provider, use `npm create mastra@latest <project-name> -- --empty`. To build a Mastra project from scratch, see the [manual installation guide](https://mastra.ai/guides/getting-started/manual-install).
|
|
6
6
|
|
|
7
7
|
The `create-mastra` CLI is the quickest way to start a Mastra project. It creates an agent harness with workspace tools, memory, task tracking, web access, schedules, storage, and observability.
|
|
8
8
|
|
|
9
|
-
For more control, see the [manual installation guide](https://mastra.ai/
|
|
9
|
+
For more control, see the [manual installation guide](https://mastra.ai/guides/getting-started/manual-install). To add Mastra to an existing project, use [`mastra init`](https://mastra.ai/reference/cli/mastra).
|
|
10
10
|
|
|
11
11
|
> **📹 Watch:** Watch the [Mastra AI agent course](https://www.youtube.com/watch?v=lCmf_qrGfGA) for a guided introduction to building agents with Mastra.
|
|
12
12
|
|
|
@@ -83,6 +83,6 @@ Open [Studio at localhost:4111](http://localhost:4111), select the agent, and se
|
|
|
83
83
|
## Next steps
|
|
84
84
|
|
|
85
85
|
- Integrate Mastra with [Next.js](https://mastra.ai/guides/getting-started/next-js), [React](https://mastra.ai/guides/getting-started/vite-react), or [Astro](https://mastra.ai/guides/getting-started/astro)
|
|
86
|
-
- Learn how to [build Mastra with AI](https://mastra.ai/
|
|
86
|
+
- Learn how to [build Mastra with AI](https://mastra.ai/reference/build-with-ai)
|
|
87
87
|
- Build an agent from scratch with a [guide](https://mastra.ai/guides)
|
|
88
88
|
- Watch the [Mastra YouTube channel](https://www.youtube.com/@mastra-ai)
|
|
@@ -181,5 +181,5 @@ For more examples of different chunking strategies and embedding configurations,
|
|
|
181
181
|
|
|
182
182
|
For more details on vector databases and embeddings, see:
|
|
183
183
|
|
|
184
|
-
- [Vector Databases](https://mastra.ai/
|
|
184
|
+
- [Vector Databases](https://mastra.ai/guides/rag/vector-databases)
|
|
185
185
|
- [Embedding API Reference](https://mastra.ai/reference/rag/embeddings)
|
|
@@ -14,7 +14,7 @@ GraphRAG is particularly effective when:
|
|
|
14
14
|
- Understanding connections between concepts is important
|
|
15
15
|
- Simple vector similarity misses important contextual relationships
|
|
16
16
|
|
|
17
|
-
For straightforward semantic search without relationship traversal, use [standard retrieval methods](https://mastra.ai/
|
|
17
|
+
For straightforward semantic search without relationship traversal, use [standard retrieval methods](https://mastra.ai/guides/rag/retrieval).
|
|
18
18
|
|
|
19
19
|
## How GraphRAG works
|
|
20
20
|
|
|
@@ -63,11 +63,11 @@ This example shows the essentials. Initialize a document and create chunks, then
|
|
|
63
63
|
|
|
64
64
|
## Document processing
|
|
65
65
|
|
|
66
|
-
The basic building block of RAG is document processing. Documents can be chunked using strategies (recursive, sliding window, etc.) and enriched with metadata. See the [chunking and embedding doc](https://mastra.ai/
|
|
66
|
+
The basic building block of RAG is document processing. Documents can be chunked using strategies (recursive, sliding window, etc.) and enriched with metadata. See the [chunking and embedding doc](https://mastra.ai/guides/rag/chunking-and-embedding).
|
|
67
67
|
|
|
68
68
|
## Vector storage
|
|
69
69
|
|
|
70
|
-
Mastra supports multiple vector stores for embedding persistence and similarity search, including pgvector, Pinecone, Qdrant, and MongoDB. See the [vector database doc](https://mastra.ai/
|
|
70
|
+
Mastra supports multiple vector stores for embedding persistence and similarity search, including pgvector, Pinecone, Qdrant, and MongoDB. See the [vector database doc](https://mastra.ai/guides/rag/vector-databases).
|
|
71
71
|
|
|
72
72
|
## More resources
|
|
73
73
|
|
|
@@ -517,4 +517,4 @@ The re-ranked results combine vector similarity with semantic understanding to i
|
|
|
517
517
|
|
|
518
518
|
For more details about re-ranking, see the [rerank()](https://mastra.ai/reference/rag/rerankWithScorer) method.
|
|
519
519
|
|
|
520
|
-
For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/
|
|
520
|
+
For graph-based retrieval that follows connections between chunks, see the [GraphRAG](https://mastra.ai/guides/rag/graph-rag) documentation.
|