@mastra/mcp-docs-server 1.2.15 → 1.2.16-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/.docs/docs/agents/agent-approval.md +5 -5
  2. package/.docs/docs/agents/overview.md +4 -4
  3. package/.docs/docs/browser/overview.md +1 -1
  4. package/.docs/docs/capabilities/channels.md +5 -5
  5. package/.docs/docs/capabilities/subagents.md +1 -1
  6. package/.docs/docs/connections/overview.md +1 -1
  7. package/.docs/docs/datasets/overview.md +1 -1
  8. package/.docs/docs/deployment/cloud-providers.md +4 -2
  9. package/.docs/docs/deployment/mastra-server.md +1 -1
  10. package/.docs/docs/deployment/monorepo.md +1 -1
  11. package/.docs/docs/deployment/overview.md +4 -1
  12. package/.docs/docs/deployment/sandbox.md +1 -1
  13. package/.docs/docs/deployment/web-framework.md +1 -1
  14. package/.docs/docs/deployment/workers.md +248 -2
  15. package/.docs/docs/evals/overview.md +1 -1
  16. package/.docs/docs/evals/quick-checks.md +1 -1
  17. package/.docs/docs/guides/multi-agent-systems.md +1 -1
  18. package/.docs/docs/harness/agent-controller.md +5 -5
  19. package/.docs/docs/harness/overview.md +1 -1
  20. package/.docs/docs/index.md +3 -3
  21. package/.docs/docs/long-running-agents/signal-providers.md +2 -2
  22. package/.docs/docs/mastra-platform/deploy.md +1 -1
  23. package/.docs/docs/mastra-platform/observability.md +63 -18
  24. package/.docs/docs/mastra-platform/overview.md +1 -1
  25. package/.docs/docs/mcp/overview.md +1 -1
  26. package/.docs/docs/memory/working-memory.md +1 -1
  27. package/.docs/docs/observability/integrations/exporters/mastra-storage.md +2 -2
  28. package/.docs/docs/observability/logging.md +1 -1
  29. package/.docs/docs/observability/metrics/overview.md +1 -1
  30. package/.docs/docs/observability/overview.md +1 -5
  31. package/.docs/docs/observability/tracing/overview.md +3 -6
  32. package/.docs/docs/server/auth/workers.md +1 -1
  33. package/.docs/docs/server/auth.md +5 -5
  34. package/.docs/docs/server/mastra-client.md +1 -1
  35. package/.docs/docs/server/mastra-server.md +1 -1
  36. package/.docs/docs/storage/overview.md +7 -6
  37. package/.docs/docs/workflows/human-in-the-loop.md +2 -2
  38. package/.docs/docs/workflows/overview.md +2 -2
  39. package/.docs/docs/workspace/lsp.md +27 -0
  40. package/.docs/docs/workspace/sandbox.md +11 -12
  41. package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
  42. package/.docs/integrations/agentic-ui/assistant-ui.md +1 -1
  43. package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
  44. package/.docs/integrations/agentic-ui/openui.md +1 -1
  45. package/.docs/integrations/databases/postgresql.md +8 -8
  46. package/.docs/integrations/deploy/amazon-ec2.md +2 -2
  47. package/.docs/integrations/deploy/aws-bedrock-agentcore.md +1 -1
  48. package/.docs/integrations/deploy/aws-lambda.md +2 -2
  49. package/.docs/integrations/deploy/azure-app-services.md +2 -2
  50. package/.docs/integrations/deploy/cloudflare.md +2 -2
  51. package/.docs/integrations/deploy/digital-ocean.md +2 -2
  52. package/.docs/integrations/deploy/inngest.md +1 -1
  53. package/.docs/integrations/deploy/kubernetes.md +2 -3
  54. package/.docs/integrations/deploy/netlify.md +2 -2
  55. package/.docs/integrations/deploy/temporal.md +1 -1
  56. package/.docs/integrations/deploy/vercel.md +2 -2
  57. package/.docs/integrations/file-storage/agentfs.md +1 -1
  58. package/.docs/integrations/file-storage/amazon-s3.md +1 -1
  59. package/.docs/integrations/file-storage/archil.md +1 -1
  60. package/.docs/integrations/file-storage/azure-blob.md +1 -1
  61. package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
  62. package/.docs/integrations/file-storage/google-drive.md +1 -1
  63. package/.docs/integrations/file-storage/mesa.md +1 -1
  64. package/.docs/integrations/file-storage/vercel-files.md +1 -1
  65. package/.docs/integrations/frameworks/astro.md +1 -1
  66. package/.docs/integrations/frameworks/electron.md +1 -1
  67. package/.docs/integrations/frameworks/express.md +1 -1
  68. package/.docs/integrations/frameworks/hono.md +1 -1
  69. package/.docs/integrations/frameworks/nestjs.md +1 -1
  70. package/.docs/integrations/frameworks/next-js.md +1 -1
  71. package/.docs/integrations/frameworks/nuxt.md +1 -1
  72. package/.docs/integrations/frameworks/sveltekit.md +1 -1
  73. package/.docs/integrations/frameworks/vite-react.md +1 -1
  74. package/.docs/integrations/sandboxes/agentcore.md +1 -1
  75. package/.docs/integrations/sandboxes/apple-container.md +1 -1
  76. package/.docs/integrations/sandboxes/blaxel.md +1 -1
  77. package/.docs/integrations/sandboxes/daytona.md +1 -1
  78. package/.docs/integrations/sandboxes/docker.md +1 -1
  79. package/.docs/integrations/sandboxes/e2b.md +1 -1
  80. package/.docs/integrations/sandboxes/modal.md +1 -1
  81. package/.docs/integrations/sandboxes/railway.md +1 -1
  82. package/.docs/integrations/sandboxes/vercel.md +3 -1
  83. package/.docs/integrations/tools/firecrawl.md +2 -2
  84. package/.docs/integrations/voice/livekit.md +3 -3
  85. package/.docs/integrations.md +108 -108
  86. package/.docs/models/environment-variables.md +2 -0
  87. package/.docs/models/gateways/openrouter.md +5 -1
  88. package/.docs/models/gateways/vercel.md +3 -2
  89. package/.docs/models/index.md +1 -1
  90. package/.docs/models/providers/aiand.md +3 -2
  91. package/.docs/models/providers/digitalocean.md +3 -2
  92. package/.docs/models/providers/edenai.md +88 -0
  93. package/.docs/models/providers/hyper.md +3 -3
  94. package/.docs/models/providers/inceptron.md +8 -9
  95. package/.docs/models/providers/kilo.md +11 -6
  96. package/.docs/models/providers/llmgateway.md +3 -1
  97. package/.docs/models/providers/merge-gateway.md +262 -0
  98. package/.docs/models/providers/nano-gpt.md +13 -37
  99. package/.docs/models/providers/opencode.md +2 -2
  100. package/.docs/models/providers/tinfoil.md +9 -8
  101. package/.docs/models/providers/xai.md +2 -1
  102. package/.docs/models/providers.md +2 -0
  103. package/.docs/reference/agents/getVoice.md +1 -1
  104. package/.docs/reference/configuration.md +1 -1
  105. package/.docs/reference/index.md +5 -1
  106. package/.docs/reference/manual-install.md +1 -1
  107. package/.docs/reference/migrations/network-to-supervisor.md +1 -1
  108. package/.docs/reference/migrations/upgrade-to-v1/tracing.md +1 -3
  109. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +0 -1
  110. package/.docs/reference/observability/tracing/exporters/console-exporter.md +0 -1
  111. package/.docs/reference/observability/tracing/exporters/default-exporter.md +0 -1
  112. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +0 -1
  113. package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +0 -1
  114. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +111 -99
  115. package/.docs/reference/observability/tracing/span-filtering.md +1 -1
  116. package/.docs/reference/storage/overview.md +1 -1
  117. package/.docs/reference/templates/overview.md +1 -1
  118. package/.docs/{guides → reference}/voice/overview.md +3 -3
  119. package/.docs/{guides → reference}/voice/speech-to-speech.md +1 -1
  120. package/.docs/{guides → reference}/voice/speech-to-text.md +1 -1
  121. package/.docs/{guides → reference}/voice/text-to-speech.md +2 -2
  122. package/CHANGELOG.md +14 -0
  123. package/package.json +4 -4
  124. package/.docs/docs/observability/integrations/exporters/mastra-platform.md +0 -201
  125. package/.docs/docs/observability/integrations/overview.md +0 -47
  126. package/.docs/docs/observability/integrations/processors/sensitive-data-filter.md +0 -302
  127. package/.docs/guides/deployment/mastra-workers.md +0 -578
  128. package/.docs/guides/getting-started/quickstart.md +0 -88
  129. package/.docs/guides/guide/ai-recruiter.md +0 -228
  130. package/.docs/guides/guide/code-review-bot.md +0 -228
  131. package/.docs/guides/guide/coding-agent.md +0 -392
  132. package/.docs/guides/guide/dev-assistant.md +0 -309
  133. package/.docs/guides/guide/docs-manager.md +0 -240
  134. package/.docs/guides/guide/github-actions-pr-description.md +0 -238
  135. package/.docs/guides/guide/notes-mcp-server.md +0 -418
  136. package/.docs/guides/guide/research-assistant.md +0 -350
  137. package/.docs/guides/guide/research-coordinator.md +0 -418
  138. package/.docs/guides/guide/signal-provider.md +0 -221
  139. package/.docs/guides/index.md +0 -24
  140. /package/.docs/{reference → docs}/mastra-platform/api.md +0 -0
  141. /package/.docs/{guides/agent-frameworks/ai-sdk.md → reference/ai-sdk/overview.md} +0 -0
@@ -1,578 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Deploy Mastra workers
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 or Kubernetes.
6
-
7
- > **Beta:** Breaking changes may occur without a major version bump until the API is stable.
8
-
9
- > **Note:** 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.
10
-
11
- ## Before you begin
12
-
13
- You'll need:
14
-
15
- - A [Mastra application](https://mastra.ai/guides/getting-started/quickstart)
16
- - [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/)
17
- - 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)
18
- - A shared database reachable from every container. See [supported storage backends](https://mastra.ai/reference/workers/overview) for the full list.
19
-
20
- > **Warning:** The default in-memory PubSub can't deliver events across processes. You must configure a distributed PubSub backend before splitting workers into separate containers.
21
-
22
- ## Configure shared infrastructure
23
-
24
- Point the `Mastra` instance at a distributed PubSub backend and a shared database. Use environment variables so the same image runs in every container.
25
-
26
- **Redis Streams + PostgreSQL**:
27
-
28
- ```typescript
29
- import { Mastra } from '@mastra/core/mastra'
30
- import { RedisStreamsPubSub } from '@mastra/redis-streams'
31
- import { PostgresStore } from '@mastra/pg'
32
-
33
- export const mastra = new Mastra({
34
- storage: new PostgresStore({
35
- connectionString: process.env.DATABASE_URL!,
36
- }),
37
- pubsub: new RedisStreamsPubSub({
38
- url: process.env.REDIS_URL!,
39
- }),
40
- })
41
- ```
42
-
43
- **Google Cloud Pub/Sub + LibSQL**:
44
-
45
- ```typescript
46
- import { Mastra } from '@mastra/core/mastra'
47
- import { GoogleCloudPubSub } from '@mastra/google-cloud-pubsub'
48
- import { LibSQLStore } from '@mastra/libsql'
49
-
50
- export const mastra = new Mastra({
51
- storage: new LibSQLStore({
52
- url: process.env.DATABASE_URL!,
53
- }),
54
- pubsub: new GoogleCloudPubSub({
55
- projectId: process.env.GCP_PROJECT_ID!,
56
- }),
57
- })
58
- ```
59
-
60
- Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database.
61
-
62
- ## Deploy
63
-
64
- 1. Build your Mastra application. The output runs in every container.
65
-
66
- ```bash
67
- mastra build
68
- ```
69
-
70
- This produces a self-contained `.mastra/output/` directory. See [Deploy a Mastra server](https://mastra.ai/docs/deployment/mastra-server) for details on the build output.
71
-
72
- 2. Create a Dockerfile that copies the pre-built output and installs production dependencies:
73
-
74
- ```dockerfile
75
- FROM node:22-alpine
76
-
77
- WORKDIR /app
78
-
79
- COPY .mastra/output/package.json .mastra/output/.npmrc* ./
80
- RUN npm install --omit=dev
81
-
82
- COPY .mastra/output/ .
83
-
84
- EXPOSE 4111
85
- CMD ["node", "index.mjs"]
86
- ```
87
-
88
- 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.
89
-
90
- 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.
91
-
92
- 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.
93
-
94
- **Docker Compose**:
95
-
96
- ```yaml
97
- services:
98
- postgres:
99
- image: postgres:16-alpine
100
- environment:
101
- POSTGRES_USER: mastra
102
- POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
103
- POSTGRES_DB: mastra
104
- ports:
105
- - '5432:5432'
106
- volumes:
107
- - pgdata:/var/lib/postgresql/data
108
- healthcheck:
109
- test: ['CMD-SHELL', 'pg_isready -U mastra']
110
- interval: 5s
111
- timeout: 3s
112
- retries: 5
113
-
114
- redis:
115
- image: redis:7-alpine
116
- ports:
117
- - '6379:6379'
118
- healthcheck:
119
- test: ['CMD', 'redis-cli', 'ping']
120
- interval: 5s
121
- timeout: 3s
122
- retries: 5
123
-
124
- api:
125
- build: ./app
126
- ports:
127
- - '4111:4111'
128
- environment:
129
- DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
130
- REDIS_URL: redis://redis:6379
131
- MASTRA_WORKERS: 'false'
132
- MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
133
- depends_on:
134
- postgres:
135
- condition: service_healthy
136
- redis:
137
- condition: service_healthy
138
- healthcheck:
139
- test: ['CMD', 'wget', '-qO-', 'http://localhost:4111/api/agents']
140
- interval: 5s
141
- timeout: 3s
142
- retries: 5
143
-
144
- orchestration-worker:
145
- build: ./app
146
- environment:
147
- DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
148
- REDIS_URL: redis://redis:6379
149
- MASTRA_WORKERS: orchestration
150
- MASTRA_STEP_EXECUTION_URL: http://api:4111/api
151
- MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
152
- depends_on:
153
- api:
154
- condition: service_healthy
155
-
156
- scheduler-worker:
157
- build: ./app
158
- environment:
159
- DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
160
- REDIS_URL: redis://redis:6379
161
- MASTRA_WORKERS: scheduler
162
- MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
163
- depends_on:
164
- api:
165
- condition: service_healthy
166
-
167
- background-task-worker:
168
- build: ./app
169
- environment:
170
- DATABASE_URL: postgres://mastra:${POSTGRES_PASSWORD}@postgres:5432/mastra
171
- REDIS_URL: redis://redis:6379
172
- MASTRA_WORKERS: backgroundTasks
173
- MASTRA_WORKER_AUTH_TOKEN: ${MASTRA_WORKER_AUTH_TOKEN}
174
- depends_on:
175
- api:
176
- condition: service_healthy
177
-
178
- volumes:
179
- pgdata:
180
- ```
181
-
182
- Create a `.env` file next to your `docker-compose.yml`:
183
-
184
- ```bash
185
- POSTGRES_PASSWORD=your-secure-password
186
- MASTRA_WORKER_AUTH_TOKEN=your-shared-secret-token
187
- ```
188
-
189
- > **Note:** Remember to set any other environment variables your application needs (e.g., your [model provider](https://mastra.ai/models/providers) API key).
190
-
191
- **Kubernetes**:
192
-
193
- Create a namespace and a Secret with your connection strings:
194
-
195
- ```yaml
196
- apiVersion: v1
197
- kind: Namespace
198
- metadata:
199
- name: mastra-workers
200
- ```
201
-
202
- ```bash
203
- kubectl apply -f k8s/namespace.yaml
204
- kubectl create secret generic mastra-secrets -n mastra-workers \
205
- --from-literal=POSTGRES_PASSWORD='your-password' \
206
- --from-literal=DATABASE_URL='postgresql://mastra:your-password@postgres:5432/mastra' \
207
- --from-literal=REDIS_URL='redis://redis:6379' \
208
- --from-literal=MASTRA_WORKER_AUTH_TOKEN='your-shared-token'
209
- ```
210
-
211
- > **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.
212
-
213
- Build and push the Docker image to a registry your cluster can pull from:
214
-
215
- ```bash
216
- docker build -t your-registry/mastra-workers:latest ./app
217
- docker push your-registry/mastra-workers:latest
218
- ```
219
-
220
- 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).
221
-
222
- ```yaml
223
- apiVersion: apps/v1
224
- kind: Deployment
225
- metadata:
226
- name: postgres
227
- namespace: mastra-workers
228
- spec:
229
- replicas: 1
230
- selector:
231
- matchLabels:
232
- app: postgres
233
- template:
234
- metadata:
235
- labels:
236
- app: postgres
237
- spec:
238
- containers:
239
- - name: postgres
240
- image: postgres:16-alpine
241
- ports:
242
- - containerPort: 5432
243
- env:
244
- - name: POSTGRES_USER
245
- value: mastra
246
- - name: POSTGRES_PASSWORD
247
- valueFrom:
248
- secretKeyRef:
249
- name: mastra-secrets
250
- key: POSTGRES_PASSWORD
251
- - name: POSTGRES_DB
252
- value: mastra
253
- volumeMounts:
254
- - name: pgdata
255
- mountPath: /var/lib/postgresql/data
256
- volumes:
257
- - name: pgdata
258
- emptyDir: {}
259
- ---
260
- apiVersion: v1
261
- kind: Service
262
- metadata:
263
- name: postgres
264
- namespace: mastra-workers
265
- spec:
266
- selector:
267
- app: postgres
268
- ports:
269
- - port: 5432
270
- targetPort: 5432
271
- ```
272
-
273
- > **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.
274
-
275
- ```yaml
276
- apiVersion: apps/v1
277
- kind: Deployment
278
- metadata:
279
- name: redis
280
- namespace: mastra-workers
281
- spec:
282
- replicas: 1
283
- selector:
284
- matchLabels:
285
- app: redis
286
- template:
287
- metadata:
288
- labels:
289
- app: redis
290
- spec:
291
- containers:
292
- - name: redis
293
- image: redis:7-alpine
294
- args: ['--appendonly', 'yes']
295
- ports:
296
- - containerPort: 6379
297
- ---
298
- apiVersion: v1
299
- kind: Service
300
- metadata:
301
- name: redis
302
- namespace: mastra-workers
303
- spec:
304
- selector:
305
- app: redis
306
- ports:
307
- - port: 6379
308
- targetPort: 6379
309
- ```
310
-
311
- ```yaml
312
- apiVersion: apps/v1
313
- kind: Deployment
314
- metadata:
315
- name: api
316
- namespace: mastra-workers
317
- spec:
318
- replicas: 1
319
- selector:
320
- matchLabels:
321
- app: api
322
- template:
323
- metadata:
324
- labels:
325
- app: api
326
- spec:
327
- containers:
328
- - name: api
329
- image: your-registry/mastra-workers:latest
330
- ports:
331
- - containerPort: 4111
332
- env:
333
- - name: MASTRA_WORKERS
334
- value: 'false'
335
- envFrom:
336
- - secretRef:
337
- name: mastra-secrets
338
- readinessProbe:
339
- httpGet:
340
- path: /api/agents
341
- port: 4111
342
- initialDelaySeconds: 10
343
- periodSeconds: 5
344
- livenessProbe:
345
- httpGet:
346
- path: /api/agents
347
- port: 4111
348
- initialDelaySeconds: 15
349
- periodSeconds: 10
350
- resources:
351
- requests:
352
- cpu: 500m
353
- memory: 512Mi
354
- ---
355
- apiVersion: v1
356
- kind: Service
357
- metadata:
358
- name: api
359
- namespace: mastra-workers
360
- spec:
361
- selector:
362
- app: api
363
- ports:
364
- - port: 4111
365
- targetPort: 4111
366
- ```
367
-
368
- ```yaml
369
- apiVersion: apps/v1
370
- kind: Deployment
371
- metadata:
372
- name: orchestration-worker
373
- namespace: mastra-workers
374
- spec:
375
- replicas: 1
376
- selector:
377
- matchLabels:
378
- app: orchestration-worker
379
- template:
380
- metadata:
381
- labels:
382
- app: orchestration-worker
383
- spec:
384
- containers:
385
- - name: worker
386
- image: your-registry/mastra-workers:latest
387
- env:
388
- - name: MASTRA_WORKERS
389
- value: orchestration
390
- - name: MASTRA_STEP_EXECUTION_URL
391
- value: http://api:4111/api
392
- envFrom:
393
- - secretRef:
394
- name: mastra-secrets
395
- resources:
396
- requests:
397
- cpu: 250m
398
- memory: 256Mi
399
- ```
400
-
401
- ```yaml
402
- apiVersion: apps/v1
403
- kind: Deployment
404
- metadata:
405
- name: scheduler-worker
406
- namespace: mastra-workers
407
- spec:
408
- replicas: 1
409
- selector:
410
- matchLabels:
411
- app: scheduler-worker
412
- template:
413
- metadata:
414
- labels:
415
- app: scheduler-worker
416
- spec:
417
- containers:
418
- - name: worker
419
- image: your-registry/mastra-workers:latest
420
- env:
421
- - name: MASTRA_WORKERS
422
- value: scheduler
423
- envFrom:
424
- - secretRef:
425
- name: mastra-secrets
426
- resources:
427
- requests:
428
- cpu: 250m
429
- memory: 256Mi
430
- ```
431
-
432
- ```yaml
433
- apiVersion: apps/v1
434
- kind: Deployment
435
- metadata:
436
- name: background-task-worker
437
- namespace: mastra-workers
438
- spec:
439
- replicas: 1
440
- selector:
441
- matchLabels:
442
- app: background-task-worker
443
- template:
444
- metadata:
445
- labels:
446
- app: background-task-worker
447
- spec:
448
- containers:
449
- - name: worker
450
- image: your-registry/mastra-workers:latest
451
- env:
452
- - name: MASTRA_WORKERS
453
- value: backgroundTasks
454
- envFrom:
455
- - secretRef:
456
- name: mastra-secrets
457
- resources:
458
- requests:
459
- cpu: 250m
460
- memory: 256Mi
461
- ```
462
-
463
- Apply all manifests and wait for the API to become ready:
464
-
465
- ```bash
466
- kubectl apply -f k8s/
467
- kubectl wait -n mastra-workers --for=condition=ready pod -l app=api --timeout=90s
468
- kubectl wait -n mastra-workers --for=condition=ready pod -l app=orchestration-worker --timeout=60s
469
- kubectl wait -n mastra-workers --for=condition=ready pod -l app=scheduler-worker --timeout=60s
470
- kubectl wait -n mastra-workers --for=condition=ready pod -l app=background-task-worker --timeout=60s
471
- ```
472
-
473
- 4. Verify the stack is running and the API responds:
474
-
475
- **Docker Compose**:
476
-
477
- ```bash
478
- docker compose up -d
479
- docker compose ps
480
- curl http://localhost:4111/api/agents
481
- ```
482
-
483
- **Kubernetes**:
484
-
485
- ```bash
486
- kubectl get pods -n mastra-workers
487
- kubectl port-forward -n mastra-workers svc/api 4111:4111
488
- ```
489
-
490
- In a separate terminal:
491
-
492
- ```bash
493
- curl http://localhost:4111/api/agents
494
- ```
495
-
496
- A JSON list of your agents confirms the API and workers are running.
497
-
498
- ## Step execution URL
499
-
500
- 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.
501
-
502
- Set `MASTRA_STEP_EXECUTION_URL` to the API's internal URL, including the `/api` prefix:
503
-
504
- ```bash
505
- MASTRA_STEP_EXECUTION_URL=http://api:4111/api
506
- ```
507
-
508
- The orchestration worker sends a `POST` request to `${MASTRA_STEP_EXECUTION_URL}/workflows/:workflowId/runs/:runId/steps/execute` for each step. The API resolves the workflow and executes the step locally.
509
-
510
- Without this variable, the orchestration worker attempts to execute steps in-process. That works when the worker runs alongside the API, but fails in split deployments where the worker doesn't have access to the full Mastra runtime.
511
-
512
- ## Scaling
513
-
514
- The orchestration and background task workers are safe to scale horizontally. PubSub consumer groups distribute events across instances, so each event is processed once:
515
-
516
- **Docker Compose**:
517
-
518
- ```bash
519
- docker compose up -d --scale orchestration-worker=3
520
- docker compose up -d --scale background-task-worker=2
521
- ```
522
-
523
- **Kubernetes**:
524
-
525
- ```bash
526
- kubectl scale deployment/orchestration-worker -n mastra-workers --replicas=3
527
- kubectl scale deployment/background-task-worker -n mastra-workers --replicas=2
528
- ```
529
-
530
- For automatic scaling, add a HorizontalPodAutoscaler:
531
-
532
- ```yaml
533
- apiVersion: autoscaling/v2
534
- kind: HorizontalPodAutoscaler
535
- metadata:
536
- name: orchestration-worker
537
- namespace: mastra-workers
538
- spec:
539
- scaleTargetRef:
540
- apiVersion: apps/v1
541
- kind: Deployment
542
- name: orchestration-worker
543
- minReplicas: 1
544
- maxReplicas: 10
545
- metrics:
546
- - type: Resource
547
- resource:
548
- name: cpu
549
- target:
550
- type: Utilization
551
- averageUtilization: 70
552
- ```
553
-
554
- > **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.
555
-
556
- The API can also scale horizontally behind a load balancer.
557
-
558
- **Don't scale the scheduler worker.** Run exactly one instance. Multiple schedulers polling the same storage fire duplicate events for the same schedule.
559
-
560
- ## Crash recovery
561
-
562
- Workers recover from crashes because the distributed PubSub backend persists unacknowledged events:
563
-
564
- - **Orchestration worker**: Pending events stay in the PubSub backend. When the worker restarts, it picks up where it left off.
565
- - **Scheduler worker**: No events are missed permanently. The scheduler computes the next fire time from the current time on restart, not from where it left off.
566
- - **API during step execution**: The orchestration worker's HTTP request fails. The event is nacked and redelivered on the next attempt.
567
-
568
- > **Warning:** If the API crashes while a step is already executing (e.g., mid-sleep), that step's work is lost. The workflow run may remain stuck in a `running` state. Mastra doesn't yet have automatic timeout-based recovery for this scenario.
569
-
570
- ## Related
571
-
572
- - [Workers](https://mastra.ai/docs/deployment/workers): What workers are and when to use them
573
- - [Worker authentication](https://mastra.ai/docs/server/auth/workers): Secure worker-to-API communication
574
- - [Workers reference](https://mastra.ai/reference/workers/overview): Configuration details for all worker types
575
- - [CLI reference](https://mastra.ai/reference/cli/mastra): `mastra worker build` and `mastra worker start`
576
- - [PubSub](https://mastra.ai/docs/server/pubsub): Event delivery backends
577
- - [Deploy a Mastra server](https://mastra.ai/docs/deployment/mastra-server): Build output and server configuration
578
- - [Deploy Mastra to Kubernetes](https://mastra.ai/integrations/deploy/kubernetes): Multi-pod deployment with durable agents
@@ -1,88 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Mastra Quickstart
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/reference/manual-install).
6
-
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
-
9
- For more control, see the [manual installation guide](https://mastra.ai/reference/manual-install). To add Mastra to an existing project, use [`mastra init`](https://mastra.ai/reference/cli/mastra).
10
-
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
-
13
- ## Before you begin
14
-
15
- You'll need an API key from OpenAI, Anthropic, Google Gemini, or xAI. You can skip entering it during setup and add it to `.env` later.
16
-
17
- ## Create the project
18
-
19
- Run the interactive setup:
20
-
21
- **npm**:
22
-
23
- ```bash
24
- npm create mastra@latest
25
- ```
26
-
27
- **pnpm**:
28
-
29
- ```bash
30
- pnpm create mastra@latest
31
- ```
32
-
33
- **Yarn**:
34
-
35
- ```bash
36
- yarn create mastra
37
- ```
38
-
39
- **Bun**:
40
-
41
- ```bash
42
- bunx create-mastra
43
- ```
44
-
45
- The command asks for a project name, model provider, and optional API key. It then installs dependencies, installs Mastra skills for your coding assistants, and creates an initial Git commit when you aren't already inside a repository.
46
-
47
- The generated `src/mastra` directory contains the Mastra entry point, agent, workspace tools, and supporting code. See the [project structure reference](https://mastra.ai/reference/project-structure) for the standard Mastra layout.
48
-
49
- > **Tip:** Use `--template <template>` to start from a template, or `--empty` to create a minimal provider-free project. Use `--no-skills` or `--no-git` to skip automatic setup. See the [`create-mastra` reference](https://mastra.ai/reference/cli/create-mastra) for all flags.
50
-
51
- ## Test your agent
52
-
53
- Follow the terminal instructions to enter the project directory and start the development server:
54
-
55
- **npm**:
56
-
57
- ```bash
58
- npm run dev
59
- ```
60
-
61
- **pnpm**:
62
-
63
- ```bash
64
- pnpm run dev
65
- ```
66
-
67
- **Yarn**:
68
-
69
- ```bash
70
- yarn dev
71
- ```
72
-
73
- **Bun**:
74
-
75
- ```bash
76
- bun run dev
77
- ```
78
-
79
- Open [Studio at localhost:4111](http://localhost:4111), select the agent, and send a message. Add the provider API key named in `.env.example` to an `.env` file if you skipped it during setup.
80
-
81
- [Studio](https://mastra.ai/docs/studio/overview) lets you build and test agents without creating a separate UI.
82
-
83
- ## Next steps
84
-
85
- - Integrate Mastra with [Next.js](https://mastra.ai/integrations/frameworks/next-js), [React](https://mastra.ai/integrations/frameworks/vite-react), or [Astro](https://mastra.ai/integrations/frameworks/astro)
86
- - Learn how to [build Mastra with AI](https://mastra.ai/reference/build-with-ai)
87
- - Build an agent from scratch with a [guide](https://mastra.ai/guides)
88
- - Watch the [Mastra YouTube channel](https://www.youtube.com/@mastra-ai)