@mastra/mcp-docs-server 1.2.13-alpha.6 → 1.2.13-alpha.8

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 (36) hide show
  1. package/.docs/docs/agents/agent-approval.md +2 -2
  2. package/.docs/docs/deployment/workers.md +14 -14
  3. package/.docs/docs/evals/datasets/running-experiments.md +1 -1
  4. package/.docs/docs/index.md +1 -1
  5. package/.docs/docs/long-running-agents/durable-agents.md +2 -2
  6. package/.docs/docs/mastra-platform/overview.md +1 -1
  7. package/.docs/docs/mastra-platform/{workspace.md → workspaces.md} +48 -7
  8. package/.docs/docs/memory/observational-memory.md +5 -5
  9. package/.docs/docs/memory/overview.md +1 -1
  10. package/.docs/docs/server/auth/workers.md +7 -5
  11. package/.docs/docs/server/mastra-client.md +60 -0
  12. package/.docs/docs/server/pubsub.md +2 -2
  13. package/.docs/docs/what-is-mastra.md +10 -10
  14. package/.docs/docs/workflows/overview.md +1 -1
  15. package/.docs/docs/workflows/scheduled-workflows.md +1 -0
  16. package/.docs/guides/deployment/kubernetes.md +2 -0
  17. package/.docs/guides/deployment/mastra-workers.md +350 -6
  18. package/.docs/guides/deployment/vercel.md +2 -0
  19. package/.docs/models/gateways/openrouter.md +1 -4
  20. package/.docs/models/index.md +1 -1
  21. package/.docs/models/providers/hyper.md +2 -1
  22. package/.docs/models/providers/openai.md +2 -2
  23. package/.docs/models/providers/opencode-go.md +2 -1
  24. package/.docs/models/providers/opencode.md +1 -1
  25. package/.docs/reference/agents/durable-agent.md +3 -3
  26. package/.docs/reference/cli/mastra.md +30 -14
  27. package/.docs/reference/core/mastra-class.md +1 -1
  28. package/.docs/reference/evals/summarization.md +5 -5
  29. package/.docs/reference/processors/regex-filter-processor.md +1 -1
  30. package/.docs/reference/tools/isolated-vm-transport.md +1 -1
  31. package/.docs/reference/vectors/mongodb.md +13 -13
  32. package/.docs/reference/workers/overview.md +10 -8
  33. package/.docs/reference/workspace/platform-filesystem.md +5 -2
  34. package/.docs/reference/workspace/platform-sandbox.md +58 -4
  35. package/CHANGELOG.md +8 -0
  36. package/package.json +4 -4
@@ -108,7 +108,7 @@ A tool's own `requireApproval` setting takes precedence over the function above.
108
108
 
109
109
  For sensitive tools, bind the approval to the exact tool name and arguments that were shown to the reviewer. If those arguments drift before execution, the tool shouldn't run under the old approval.
110
110
 
111
- The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a simple JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
111
+ The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
112
112
 
113
113
  ```typescript
114
114
  import { Agent } from '@mastra/core/agent'
@@ -174,7 +174,7 @@ async function approveReviewedToolCall(runId: string, toolCallId: string, finger
174
174
  await consumeApprovalStream(stream)
175
175
  ```
176
176
 
177
- In production, store the approved fingerprint in durable storage scoped to the user, run, tool call, and policy version. The `Set` above is intentionally small so the boundary is easy to see: the approval is consumed once, and only for the same canonical tool arguments that were reviewed.
177
+ In production, store the approved fingerprint in durable storage scoped to the user, run, tool call, and policy version. The `Set` above is intentionally small so the boundary is clear: the approval is consumed once, and only for the same canonical tool arguments that were reviewed.
178
178
 
179
179
  ### Runtime suspension with `suspend()`
180
180
 
@@ -17,7 +17,7 @@ Workers matter when any of these apply:
17
17
  - Different parts of the system need to scale independently (e.g., more orchestration capacity without more API instances)
18
18
  - Background tool calls should run on dedicated compute
19
19
 
20
- If your application handles light traffic and workflows complete quickly, the default in-process setup works fine. Skip the worker infrastructure until you need it.
20
+ If your application handles light traffic and workflows complete fast, the default in-process setup works fine. Skip the worker infrastructure until you need it.
21
21
 
22
22
  ## Worker types
23
23
 
@@ -33,11 +33,11 @@ The orchestration worker requires a PubSub backend that supports pull mode (e.g.
33
33
 
34
34
  ### Scheduler worker
35
35
 
36
- Polls storage for due cron schedules and publishes `workflow.start` events. It is a producer only, meaning it creates work for the orchestration worker to pick up.
36
+ Polls storage for due cron schedules and publishes `workflow.start` events. It's a producer only, meaning it creates work for the orchestration worker to pick up.
37
37
 
38
38
  The scheduler reads declarative `schedule` fields from your workflow definitions automatically. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows) for how to declare schedules.
39
39
 
40
- **Do not run more than one scheduler instance.** Multiple schedulers polling the same storage would fire duplicate events for the same schedule.
40
+ **Don't run more than one scheduler instance.** Multiple schedulers polling the same storage would fire duplicate events for the same schedule.
41
41
 
42
42
  ### Background task worker
43
43
 
@@ -47,7 +47,7 @@ The background task worker manages concurrency limits, task lifecycle, and resul
47
47
 
48
48
  ## How workers run
49
49
 
50
- ### In-process (default)
50
+ ### In-process mode (default)
51
51
 
52
52
  With no configuration, Mastra creates and starts workers inside the API process. Events flow through an in-memory PubSub, and everything shares a single Node.js runtime.
53
53
 
@@ -64,7 +64,7 @@ This setup needs no external infrastructure beyond your storage adapter. It does
64
64
 
65
65
  ### Split processes
66
66
 
67
- To run workers separately, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
67
+ To run workers in their own processes, configure a distributed [PubSub](https://mastra.ai/docs/server/pubsub) backend and use the `MASTRA_WORKERS` environment variable to control which workers start in each process.
68
68
 
69
69
  **Redis Streams + PostgreSQL**:
70
70
 
@@ -100,38 +100,38 @@ export const mastra = new Mastra({
100
100
  })
101
101
  ```
102
102
 
103
- Any [supported storage backend](https://mastra.ai/reference/workers/overview) works swap the storage adapter for your preferred database.
103
+ Any [supported storage backend](https://mastra.ai/reference/workers/overview) works. Swap the storage adapter for your preferred database.
104
104
 
105
105
  Run the same build artifact in multiple containers, each with a different [`MASTRA_WORKERS`](https://mastra.ai/reference/workers/overview) value to control which worker starts in each process.
106
106
 
107
107
  Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)), a shared [storage backend](https://mastra.ai/reference/workers/overview), and network connectivity between the orchestration worker and the API.
108
108
 
109
- The [worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers) walks through this setup with a Docker Compose example.
109
+ The [worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers) walks through this setup with Docker Compose and Kubernetes examples.
110
110
 
111
111
  ## Network architecture
112
112
 
113
- Workers are internal infrastructure. They are not exposed to end users and do not need their own subdomain, public URL, or inbound HTTP route.
113
+ Workers are internal infrastructure. They're not exposed to end users and don't need their own subdomain, public URL, or inbound HTTP route.
114
114
 
115
115
  In a split deployment:
116
116
 
117
- - **The API server is the only public-facing process.** It serves all client HTTP requests REST endpoints, agent interactions, workflow triggers, and any custom routes.
118
- - **Workers connect outbound only.** They pull events from the distributed PubSub backend and read/write to the shared storage database. They do not accept inbound traffic from clients.
119
- - **The orchestration worker calls the API internally.** It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
117
+ - **The API server is the only public-facing process**: It serves all client HTTP requests, including REST endpoints, agent interactions, workflow triggers, and any custom routes.
118
+ - **Workers connect outbound only**: They pull events from the distributed PubSub backend and read/write to the shared storage database. They don't accept inbound traffic from clients.
119
+ - **The orchestration worker calls the API internally**: It sends step execution requests to the API over the container network using `MASTRA_STEP_EXECUTION_URL`. This is internal service-to-service communication, not a public endpoint.
120
120
 
121
121
  All three worker types (orchestration, scheduler, background task) sit behind the API on a private network. They share access to the PubSub backend and storage database but never receive traffic directly from clients. If a worker-related feature needs an HTTP route (for example, token minting for a voice integration), that route runs on the API server, not on the worker process.
122
122
 
123
123
  ## Known limitations
124
124
 
125
- - **No dead-letter queue**: Failed events are nacked and retried, but there is no DLQ for events that repeatedly fail.
125
+ - **No dead-letter queue**: Failed events are nacked and retried, but there's no DLQ for events that fail after all retries.
126
126
  - **No built-in health endpoint**: Workers don't expose an HTTP health check. Use container-level liveness probes or process monitoring.
127
127
  - **Scheduler is single-instance**: Running multiple scheduler processes causes duplicate schedule fires.
128
128
  - **Runs stuck in "running" after API crash**: If the API process crashes while executing a workflow step, the run remains in `running` status with no automatic retry. For [durable agents](https://mastra.ai/docs/long-running-agents/durable-agents), set `recovery.durableAgents` to `'auto'` in the Mastra config to automatically re-drive orphaned runs on server restart. See [Crash recovery](https://mastra.ai/docs/long-running-agents/durable-agents) for details.
129
129
 
130
130
  ## Related
131
131
 
132
- - [Worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers): Docker Compose example and topology options
132
+ - [Worker deployment guide](https://mastra.ai/guides/deployment/mastra-workers): Docker Compose and Kubernetes examples
133
133
  - [Worker authentication](https://mastra.ai/docs/server/auth/workers): Secure worker-to-API communication
134
- - [Workers reference](https://mastra.ai/reference/workers/overview): Environment variables, worker types, and storage backends
134
+ - [Workers reference](https://mastra.ai/reference/workers/overview): Details about worker environment variables and types, with a list of supported storage backends
135
135
  - [CLI reference](https://mastra.ai/reference/cli/mastra): `mastra worker build` and `mastra worker start`
136
136
  - [PubSub](https://mastra.ai/docs/server/pubsub): Event delivery backends
137
137
  - [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows): Declare cron schedules on workflows
@@ -133,7 +133,7 @@ Visit the [Scorers overview](https://mastra.ai/docs/evals/overview) for details
133
133
 
134
134
  ## Tool mocks
135
135
 
136
- When an experiment runs an agent that calls side-effecting tools, you can make the run deterministic by attaching static tool mocks to individual dataset items. During the experiment, a mocked tool returns its declared output instead of executing. By default, tools that have no mock on the item run live.
136
+ When an experiment runs an agent that calls side-effecting tools, attach static tool mocks to individual dataset items to make the run deterministic. During the experiment, a mocked tool returns its declared output instead of executing. Tools without a mock on the item run live by default.
137
137
 
138
138
  Mocks live on the dataset item, so they version with the row and travel with the test case. Each mock declares a tool name, the arguments it expects, and the output to return:
139
139
 
@@ -166,4 +166,4 @@ For other frameworks, see the [framework integration guides](https://mastra.ai/g
166
166
 
167
167
  Browse [templates](https://mastra.ai/templates) for complete Mastra projects you can clone and adapt.
168
168
 
169
- > **Note:** New to Mastra? Read [What is Mastra?](https://mastra.ai/docs/what-is-mastra) for an overview of the framework, its capabilities, and what you can build with it.
169
+ > **Note:** New to Mastra? Read [What's Mastra?](https://mastra.ai/docs/what-is-mastra) for an overview of the framework, its capabilities, and what you can build with it.
@@ -245,7 +245,7 @@ On startup, this discovers every registered durable agent with runs stuck in `ru
245
245
 
246
246
  ### Manual recovery
247
247
 
248
- If you need finer control for example gating recovery behind a leader election or running it on a schedule call the methods directly:
248
+ If you need finer control, such as gating recovery behind a leader election or running it on a schedule, call the methods directly:
249
249
 
250
250
  ```typescript
251
251
  // Recover all durable agents
@@ -261,7 +261,7 @@ await durableAgent.recoverActiveRuns({ runId: 'run-abc-123' })
261
261
 
262
262
  ### Multi-instance deployments
263
263
 
264
- There is no distributed lease or lock yet. In multi-replica deployments, every replica that starts with `recovery.durableAgents: 'auto'` will race to recover the same runs. For now, either gate recovery behind your own leader election or run it from a single replica.
264
+ Mastra doesn't provide a distributed lease or lock yet. In multi-replica deployments, every replica that starts with `recovery.durableAgents: 'auto'` will race to recover the same runs. For now, either gate recovery behind your own leader election or run it from a single replica.
265
265
 
266
266
  ## Related
267
267
 
@@ -10,7 +10,7 @@ The [Mastra platform](https://projects.mastra.ai) provides three products for de
10
10
 
11
11
  Deploy with a single command, [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy), or connect a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
12
12
 
13
- Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`), provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data, and get a managed [**Workspace**](https://mastra.ai/docs/mastra-platform/workspace) per environment that gives agents a filesystem and a sandbox with no manual configuration.
13
+ Each project can run multiple [**Environments**](https://mastra.ai/docs/mastra-platform/environments) (for example `production` and `staging`), provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data, and get a managed [**Workspaces**](https://mastra.ai/docs/mastra-platform/workspaces) per environment that gives agents a filesystem and a sandbox with no manual configuration.
14
14
 
15
15
  [**Trace Intelligence**](https://mastra.ai/docs/mastra-platform/trace-intelligence) finds recurring goals, outcomes, behaviors, and sentiment across your agent traces. Trace Intelligence is available in private beta for selected projects.
16
16
 
@@ -1,13 +1,15 @@
1
1
  > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
2
 
3
- # Workspace
3
+ # Workspaces
4
4
 
5
- A workspace gives an environment two things your agents can use at runtime:
5
+ A workspace is a set of runtime resources the Mastra platform provisions and hands to your agents at deploy time. Each environment gets its own workspace so `production` and `staging` stay isolated.
6
6
 
7
- - A **bucket** for filesystem storage, exposed to your code as [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem).
8
- - A **sandbox** for executing commands, exposed as [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox).
7
+ Every workspace exposes two capabilities:
9
8
 
10
- Workspaces are provisioned per [environment](https://mastra.ai/docs/mastra-platform/environments), so `production` and `staging` each get their own bucket and sandbox. The platform manages provisioning, credentials, and lifecycle. Your deploy code only needs to construct the providers.
9
+ - One **bucket** for filesystem storage, wrapped by [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem). The bucket is a durable, environment-scoped store agents read from and write to across runs.
10
+ - A pool of **on-demand sandboxes** for command execution, wrapped by [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox). Each `PlatformSandbox` instance provisions its own remote sandbox on `start()` and destroys it on `destroy()`. Agents typically spin up many sandboxes per session, use them for a task, and let them go.
11
+
12
+ Workspaces are scoped to a single [environment](https://mastra.ai/docs/mastra-platform/environments), so `production` and `staging` don't share buckets or sandbox pools. The platform manages provisioning, credentials, and idle cleanup. Your deploy only constructs the providers.
11
13
 
12
14
  ## When workspaces are provisioned
13
15
 
@@ -15,7 +17,7 @@ New projects have workspaces enabled by default. When you create an environment,
15
17
 
16
18
  Existing projects that haven't opted in show an **Enable workspaces** action in the Workspaces tab. Enabling provisions a bucket for every environment on the project.
17
19
 
18
- If provisioning fails for an environment, for example while Railway is under load, the Workspaces tab shows the failure and offers a retry. The environment itself is still created. Only the workspace is unavailable until you retry.
20
+ If provisioning fails for an environment, for example while the sandbox provider is under load, the Workspaces tab shows the failure and offers a retry. The environment itself is still created. Only the workspace is unavailable until you retry.
19
21
 
20
22
  ## Use the workspace from your code
21
23
 
@@ -68,6 +70,45 @@ export const mastra = new Mastra({
68
70
 
69
71
  `PlatformFilesystem` and `PlatformSandbox` read their credentials from environment variables the platform injects at deploy time, so you don't pass any options on the platform.
70
72
 
73
+ ## One bucket, many sandboxes
74
+
75
+ The two providers have different lifecycles, and the difference matters when you design agents.
76
+
77
+ **`PlatformFilesystem` is a long-lived handle to the environment's bucket.** All requests, all agents, and all sandboxes in the environment read and write the same object storage. Anything an agent writes is visible on the next request unless you explicitly delete it.
78
+
79
+ **`PlatformSandbox` is a client for provisioning ephemeral sandboxes.** Each `PlatformSandbox` instance owns one remote sandbox:
80
+
81
+ - `start()` provisions a fresh sandbox (or reattaches when you passed `sandboxId`).
82
+ - `executeCommand()` runs commands against it.
83
+ - `destroy()` tears the sandbox down. `stop()` is an alias.
84
+
85
+ The `sandbox` you pass to `Workspace` provides the tools an agent uses inside its own request. When your agent needs another isolated environment, for example a per-task workspace, a per-user tenant, or a background job that shouldn't touch the caller's shell state, construct another `PlatformSandbox`:
86
+
87
+ ```typescript
88
+ import { PlatformSandbox } from '@mastra/platform-workspace'
89
+
90
+ export async function runInFreshSandbox(command: string) {
91
+ const sandbox = new PlatformSandbox()
92
+ await sandbox.start()
93
+ try {
94
+ return await sandbox.executeCommand(command)
95
+ } finally {
96
+ await sandbox.destroy()
97
+ }
98
+ }
99
+ ```
100
+
101
+ Or clone a configured sandbox as the template for a fleet, so the clones inherit credentials, environment, network isolation, and defaults without repeating them:
102
+
103
+ ```typescript
104
+ const template = new PlatformSandbox({ networkIsolation: 'PRIVATE' })
105
+
106
+ const perProjectSandbox = template.clone({ id: `project-${projectId}` })
107
+ await perProjectSandbox.start()
108
+ ```
109
+
110
+ See [`PlatformSandbox` reference](https://mastra.ai/reference/workspace/platform-sandbox) for the full lifecycle, checkpoint recovery, reattachment, and clone options.
111
+
71
112
  ## Injected environment variables
72
113
 
73
114
  Every deploy that runs on a platform environment with a workspace receives these variables:
@@ -107,5 +148,5 @@ The Workspaces tab in your platform project shows, per environment:
107
148
  ## See also
108
149
 
109
150
  - [`PlatformFilesystem`](https://mastra.ai/reference/workspace/platform-filesystem): reference for the filesystem provider.
110
- - [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox): reference for the sandbox provider.
151
+ - [`PlatformSandbox`](https://mastra.ai/reference/workspace/platform-sandbox): reference for the sandbox provider, including checkpoint recovery and cloning.
111
152
  - [Environments](https://mastra.ai/docs/mastra-platform/environments): how environments scope workspaces, variables, and databases.
@@ -399,7 +399,7 @@ Example: An agent using Playwright MCP might see 50,000+ tokens per page snapsho
399
399
 
400
400
  When observations exceed their threshold (default: 40,000 tokens), the Reflector condenses them and combines related items, plus reflects on patterns.
401
401
 
402
- Reflections don't accumulate as a separate, ever-growing layer. Each reflection rewrites the entire observation log: the Reflector's output becomes the new log, and new observations append after it. When the log next hits the threshold, the Reflector re-processes everything including earlier reflections condensing older information more aggressively while keeping recent detail. Memory stays bounded around the reflection threshold no matter how long the conversation runs.
402
+ Reflections don't accumulate as a separate, ever-growing layer. Each reflection rewrites the entire observation log. The Reflector's output becomes the new log, and new observations append after it. When the log next hits the threshold, the Reflector re-processes everything, including earlier reflections. It condenses older information more aggressively while keeping recent detail. Memory stays bounded around the reflection threshold no matter how long the conversation runs.
403
403
 
404
404
  The result is a three-tier system:
405
405
 
@@ -407,7 +407,7 @@ The result is a three-tier system:
407
407
  2. **Observations**: A log of what the Observer has seen
408
408
  3. **Reflections**: Condensed observations when memory becomes too long
409
409
 
410
- ### Context over time
410
+ ### How context changes over time
411
411
 
412
412
  With default settings, the context window doesn't grow unbounded. It oscillates through an observe-and-shrink cycle:
413
413
 
@@ -416,11 +416,11 @@ With default settings, the context window doesn't grow unbounded. It oscillates
416
416
  1. **0 → 30k tokens**: Message history grows normally. In the background, the Observer buffers observations every \~6k tokens (`bufferTokens: 0.2`).
417
417
  2. **30k reached**: Buffered observations activate instantly. Observed messages are removed from the context window and only \~6k tokens of recent history remain (`bufferActivation: 0.8` retains 20% of the threshold). The \~24k tokens of removed messages become roughly 1-5k tokens of observations at typical 5-40x compression.
418
418
  3. **Repeat**: History grows from \~6k back toward 30k and shrinks again. Each cycle appends to the observation log, which grows much more slowly than raw history.
419
- 4. **Observations reach 40k**: The Reflector condenses the observation log including any earlier reflections — into a new, smaller log.
419
+ 4. **Observations reach 40k**: The Reflector creates a smaller log from the current observations and any earlier reflections.
420
420
 
421
- The result: in the normal buffered cycle, raw history oscillates between roughly 6k and 30k tokens and the observation log stays around 40k tokens, however long the conversation runs. These are activation thresholds rather than hard caps if background buffering falls behind, history can grow past the threshold until `blockAfter` (default `1.2`) forces a synchronous observation at \~36k tokens (\~48k for reflection) as a safety ceiling.
421
+ In the normal buffered cycle, raw history oscillates between roughly 6k and 30k tokens. The observation log stays around 40k tokens, however long the conversation runs. These are activation thresholds rather than hard caps. If background buffering doesn't keep pace, history can grow past the threshold until `blockAfter` (default `1.2`) forces a synchronous observation at \~36k tokens (\~48k for reflection) as a safety ceiling.
422
422
 
423
- With [`shareTokenBudget`](https://mastra.ai/reference/memory/observational-memory) enabled, the two budgets pool together: while the observation log is small, message history can expand into the unused observation space (up to \~70k tokens with the defaults) before observation triggers, then shrinks back as observations accumulate.
423
+ With [`shareTokenBudget`](https://mastra.ai/reference/memory/observational-memory) enabled, the two budgets pool together. While the observation log is small, message history can expand into the unused observation space (up to \~70k tokens with the defaults) before observation triggers. It then shrinks as observations accumulate.
424
424
 
425
425
  ### Retrieval mode
426
426
 
@@ -174,7 +174,7 @@ See [Observational Memory](https://mastra.ai/docs/memory/observational-memory) f
174
174
 
175
175
  ## What the model sees
176
176
 
177
- Each memory feature lands in one of two places in the request sent to the model: the system messages or the conversation messages. Which layers are present depends on which features you've enabled working memory, semantic recall, and Observational Memory only appear when configured, while message history is on by default. The diagram shows where each enabled layer is placed in the request; the list below describes what each layer contributes:
177
+ Each memory feature is added to either the system messages or the conversation messages in the request sent to the model. The layers depend on the features you've enabled. Working memory and semantic recall only appear when configured. The same applies to Observational Memory, while message history is on by default. The diagram shows where each enabled layer is placed in the request. The list below describes what each layer contributes:
178
178
 
179
179
  ![Diagram showing how Mastra assembles the model context: system messages containing agent instructions, call-time system messages, working memory, cross-thread semantic recall, and Observational Memory, followed by conversation messages where message history and same-thread semantic recall interleave by timestamp, then call-time context messages, and finally the new user message](/img/memory/memory-context-window-light.svg)
180
180
 
@@ -57,7 +57,7 @@ services:
57
57
  orchestration-worker:
58
58
  environment:
59
59
  MASTRA_WORKER_AUTH_TOKEN: ${WORKER_TOKEN}
60
- MASTRA_STEP_EXECUTION_URL: http://api:4111/api
60
+ MASTRA_STEP_EXECUTION_URL: http://api:4111/api # Use HTTPS in production
61
61
  # ... other env vars
62
62
  ```
63
63
 
@@ -65,6 +65,8 @@ services:
65
65
  WORKER_TOKEN=sk-worker-secret-token
66
66
  ```
67
67
 
68
+ These examples use `http://` for local development. In production, use HTTPS URLs and terminate TLS with a service mesh or ingress controller. See [Security recommendations](#security-recommendations).
69
+
68
70
  The orchestration worker reads `MASTRA_WORKER_AUTH_TOKEN` and sends it as a `Bearer` token in the `Authorization` header on every step execution request.
69
71
 
70
72
  ## Auth credential types
@@ -87,7 +89,7 @@ Send the credential as `x-worker-api-key` instead of `Authorization`:
87
89
  import { HttpRemoteStrategy } from '@mastra/core/worker'
88
90
 
89
91
  const strategy = new HttpRemoteStrategy({
90
- serverUrl: 'http://api:4111/api',
92
+ serverUrl: 'http://api:4111/api', // Use HTTPS in production
91
93
  auth: { type: 'api-key', key: process.env.WORKER_API_KEY! },
92
94
  })
93
95
  ```
@@ -102,7 +104,7 @@ Use any header name and value:
102
104
  import { HttpRemoteStrategy } from '@mastra/core/worker'
103
105
 
104
106
  const strategy = new HttpRemoteStrategy({
105
- serverUrl: 'http://api:4111/api',
107
+ serverUrl: 'http://api:4111/api', // Use HTTPS in production
106
108
  auth: {
107
109
  type: 'header',
108
110
  name: 'X-Internal-Service-Key',
@@ -111,7 +113,7 @@ const strategy = new HttpRemoteStrategy({
111
113
  })
112
114
  ```
113
115
 
114
- ## Push-mode broker authentication
116
+ ## Push-mode broker auth
115
117
 
116
118
  When using a push-mode PubSub (like Google Cloud Pub/Sub), the broker POSTs events directly to the `/api/workflows/events` endpoint. The broker attaches its own credentials. For example, Google Cloud Pub/Sub sends a Google-signed OIDC token.
117
119
 
@@ -121,7 +123,7 @@ Your auth provider's `authenticateToken` callback must recognize whatever creden
121
123
 
122
124
  - **Use different tokens for different worker types.** This lets you revoke access to one worker without affecting others.
123
125
  - **Rotate tokens on a schedule.** Update the `WORKER_TOKEN` environment variable and restart the affected containers.
124
- - **Use TLS in production.** Worker-to-API communication should go over HTTPS to protect tokens in transit. Within a private network (Docker bridge, Kubernetes cluster), plain HTTP is acceptable.
126
+ - **Use TLS in production.** Worker-to-API communication should go over HTTPS to protect tokens in transit. This applies to all environments, including Kubernetes clusters and Docker networks. Use a service mesh (e.g., Istio, Linkerd) or TLS-terminating ingress to encrypt internal traffic.
125
127
  - **Restrict network access.** The step execution and event endpoints are internal. If possible, keep them off the public internet using network policies or firewall rules.
126
128
 
127
129
  ## Related
@@ -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)
@@ -1,10 +1,10 @@
1
1
  > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
2
 
3
- # What is Mastra?
3
+ # What's Mastra?
4
4
 
5
- Mastra is an open-source TypeScript framework for building AI applications and autonomous AI systems. Use it for anything from an AI feature inside an existing product to long-running agents that run entire processes on their own, such as a software factory that plans, builds, reviews, and ships code.
5
+ Mastra is an open-source TypeScript framework for building AI applications and autonomous AI systems. Use it for anything from an AI feature inside an existing product to long-running agents that run entire processes on their own, such as a software factory that plans, builds, reviews, and releases code.
6
6
 
7
- Mastra gives you everything you need to build an agent harness out of the box. It's built on established patterns, so you make fewer integration decisions and spend more time on your product. And, as you'd expect from an AI framework, it includes a [skill and CLI](https://mastra.ai/docs/getting-started/build-with-ai) that help your coding agent write accurate, up-to-date Mastra code.
7
+ Mastra gives you everything you need to build an agent harness out of the box. It's built on established patterns, so you make fewer integration decisions and spend more time on your product. It also includes a [skill and CLI](https://mastra.ai/docs/getting-started/build-with-ai) that help your coding agent write accurate, up-to-date Mastra code.
8
8
 
9
9
  Run Mastra standalone or inside your existing web server, and call your agents from your own code, over HTTP using the [Mastra client](https://mastra.ai/docs/server/mastra-client), or from channels (for example, Slack).
10
10
 
@@ -29,10 +29,10 @@ export const supportAgent = new Agent({
29
29
 
30
30
  Then add the capabilities your agent needs:
31
31
 
32
- - **Act in real environments**: Use [workspaces](https://mastra.ai/docs/workspace/overview) so agents can read and write files, run commands, and work inside a sandbox.
32
+ - **Act in real environments**: Use [workspaces](https://mastra.ai/docs/workspace/overview) so agents can read and write files or run commands. They can also work inside a sandbox.
33
33
  - **Bring the right context**: Use tools, [memory](https://mastra.ai/docs/memory/observational-memory), [skills](https://mastra.ai/docs/agents/skills), and domain knowledge so agents remember what matters and stay within the context window.
34
34
  - **Coordinate complex work**: Run typed [workflows](https://mastra.ai/docs/workflows/overview), [tasks](https://mastra.ai/docs/agents/using-tools), and [subagents](https://mastra.ai/docs/agents/supervisor-agents) when work needs multiple steps or parallel execution.
35
- - **Control the agent loop**: [Suspend](https://mastra.ai/docs/agents/agent-approval) for human approval, steer an in-flight loop with [signals](https://mastra.ai/docs/long-running-agents/signals), or queue input for the next turn.
35
+ - **Control the agent loop**: [Suspend](https://mastra.ai/docs/agents/agent-approval) for human approval or steer an in-flight loop with [signals](https://mastra.ai/docs/long-running-agents/signals). You can also queue input for the next turn.
36
36
  - **Meet users where they work**: Connect agents to Slack, Discord, GitHub, and other [channels](https://mastra.ai/docs/capabilities/channels/overview).
37
37
  - **Manage risk and cost**: Configure authentication, multi-tenant isolation, and [guardrails](https://mastra.ai/docs/agents/guardrails), including [`CostGuardProcessor`](https://mastra.ai/reference/processors/cost-guard-processor).
38
38
 
@@ -42,13 +42,13 @@ See the left-hand sidebar for the full menu of features.
42
42
 
43
43
  ![Agents page in Mastra Studio. A sidebar lists primitives like agents, workflows, and tools, a middle panel lists recent chats, and a chat panel shows the agent responding to a prompt with collapsible tool calls and a task list tracking progress. Below the chat is a message box with a model picker.](/assets/images/studio-agent-chat-e516834f26abd332aa54cbffa7553028.png)
44
44
 
45
- [Studio](https://mastra.ai/docs/studio/overview) is usually the first place you go after creating a Mastra app. It gives you a live environment for testing agents, inspecting runs, and iterating quickly.
45
+ [Studio](https://mastra.ai/docs/studio/overview) is usually the first place you go after creating a Mastra app. It gives you a live environment where you can test agents and inspect runs as you iterate.
46
46
 
47
- Studio isn't just for engineers. Deploy it and share it with your team, so collaborators can try an agent before it ships. With the [Editor](https://mastra.ai/docs/editor/overview) and [Agent Builder](https://mastra.ai/docs/agent-builder/overview), non-technical teammates can create and iterate on agents themselves, with every change versioned in code.
47
+ Studio isn't limited to engineers. Deploy it and share it with your team, so collaborators can try an agent before it goes to production. With the [Editor](https://mastra.ai/docs/editor/overview) and [Agent Builder](https://mastra.ai/docs/agent-builder/overview), non-technical teammates can create and iterate on agents themselves, with every change versioned in code.
48
48
 
49
49
  ## Observability and evals
50
50
 
51
- ![Traces page in Mastra Studio. A table lists recent agent runs with timestamps and inputs. A details panel shows the selected trace as an expandable tree of model, tool, and workspace spans with per-span timings, plus actions to evaluate the trace or save it as a dataset item.](/assets/images/studio-traces-e061dbd62a9c7f2ac2d61ad172125be6.png)
51
+ ![Traces page in Mastra Studio. A table lists recent agent runs with timestamps and inputs. Beside it, a details panel shows the selected trace as an expandable tree of model, tool, and workspace spans with per-span timings, plus actions to evaluate the trace or save it as a dataset item.](/assets/images/studio-traces-e061dbd62a9c7f2ac2d61ad172125be6.png)
52
52
 
53
53
  Mastra has built-in logs, traces, and metrics, so you can understand every run in development and production. See [Observability](https://mastra.ai/docs/observability/overview).
54
54
 
@@ -59,9 +59,9 @@ Evals close the loop. Score outputs with rule-based or LLM-as-judge [scorers](ht
59
59
  Some agents finish in a single request. Others run for hours or days, like a sales agent that watches for signups or an SRE agent that handles incidents. Mastra supports [long-running agents](https://mastra.ai/docs/long-running-agents/durable-agents) with these capabilities:
60
60
 
61
61
  - **Survive restarts and disconnects**: [Durable agents](https://mastra.ai/docs/long-running-agents/durable-agents) persist run state so work resumes and clients reconnect.
62
- - **Wake and steer agents mid-run**: Send [messages and signals](https://mastra.ai/docs/long-running-agents/signals) to wake an agent, add context, or queue input.
62
+ - **Wake and steer agents mid-run**: Send [messages and signals](https://mastra.ai/docs/long-running-agents/signals) to wake an agent or add context. You can also queue input.
63
63
  - **Keep working toward a goal**: [Goals](https://mastra.ai/docs/long-running-agents/goals) persist an objective until it's met or the run budget is spent.
64
- - **Run work outside the request**: Use [schedules](https://mastra.ai/docs/long-running-agents/schedules) and [background tasks](https://mastra.ai/docs/long-running-agents/background-tasks) for recurring jobs, slow tools, and work that shouldn't block the agent loop.
64
+ - **Run work outside the request**: Use [schedules](https://mastra.ai/docs/long-running-agents/schedules) and [background tasks](https://mastra.ai/docs/long-running-agents/background-tasks) for recurring jobs or slow tools. They also handle work that shouldn't block the agent loop.
65
65
 
66
66
  For long-running interactive applications, [AgentController](https://mastra.ai/docs/agent-controller/overview) manages threads, modes, tool approvals, and model switching. It powers [Mastra Code](https://code.mastra.ai/) and lets you build a Claude Code-style experience for your own domain.
67
67
 
@@ -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): Offload workflow orchestration to dedicated processes in production
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`.
@@ -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)