@mastra/mcp-docs-server 1.2.18 → 1.2.19-alpha.13

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 (69) hide show
  1. package/.docs/docs/deployment/mastra-server.md +19 -0
  2. package/.docs/docs/deployment/workers.md +2 -2
  3. package/.docs/docs/evals/built-in-scorers.md +1 -0
  4. package/.docs/docs/evals/multi-turn.md +84 -1
  5. package/.docs/docs/evals/overview.md +63 -1
  6. package/.docs/docs/harness/durable-agents.md +1 -1
  7. package/.docs/docs/mastra-platform/deploy.md +101 -0
  8. package/.docs/docs/mastra-platform/server.md +6 -11
  9. package/.docs/docs/mastra-platform/studio.md +8 -10
  10. package/.docs/docs/observability/integrations/exporters/mastra-storage.md +19 -14
  11. package/.docs/docs/sandbox/filesystem.md +8 -8
  12. package/.docs/docs/sandbox/overview.md +33 -66
  13. package/.docs/docs/server/middleware.md +4 -0
  14. package/.docs/docs/server/server-adapters.md +12 -8
  15. package/.docs/docs/storage.md +1 -0
  16. package/.docs/integrations/databases/mongodb.md +1 -1
  17. package/.docs/integrations/databases/postgresql.md +2 -0
  18. package/.docs/integrations/databases/valkey.md +99 -0
  19. package/.docs/integrations/deploy/render.md +47 -61
  20. package/.docs/integrations/sandboxes/e2b.md +2 -0
  21. package/.docs/integrations/tools/parallel.md +240 -0
  22. package/.docs/integrations.md +2 -0
  23. package/.docs/models/environment-variables.md +2 -0
  24. package/.docs/models/gateways/merge-gateway.md +2 -1
  25. package/.docs/models/gateways/netlify.md +9 -5
  26. package/.docs/models/gateways/openrouter.md +8 -9
  27. package/.docs/models/gateways/vercel.md +7 -1
  28. package/.docs/models/index.md +1 -1
  29. package/.docs/models/providers/agentrouter.md +17 -34
  30. package/.docs/models/providers/aki-io.md +14 -13
  31. package/.docs/models/providers/chutes.md +2 -2
  32. package/.docs/models/providers/crof.md +3 -8
  33. package/.docs/models/providers/crossmodel.md +56 -55
  34. package/.docs/models/providers/deepseek.md +8 -7
  35. package/.docs/models/providers/digitalocean.md +8 -8
  36. package/.docs/models/providers/edenai.md +14 -14
  37. package/.docs/models/providers/google.md +3 -3
  38. package/.docs/models/providers/hyper.md +5 -5
  39. package/.docs/models/providers/inceptron.md +1 -1
  40. package/.docs/models/providers/kilo.md +24 -20
  41. package/.docs/models/providers/llmgateway-providers.md +11 -8
  42. package/.docs/models/providers/llmgateway.md +3 -5
  43. package/.docs/models/providers/nano-gpt.md +12 -6
  44. package/.docs/models/providers/nvidia.md +3 -1
  45. package/.docs/models/providers/ofox.md +114 -110
  46. package/.docs/models/providers/opencode-go.md +26 -23
  47. package/.docs/models/providers/opencode.md +1 -1
  48. package/.docs/models/providers/opper.md +112 -0
  49. package/.docs/models/providers/requesty.md +1 -1
  50. package/.docs/models/providers/scaleway.md +2 -1
  51. package/.docs/models/providers.md +2 -0
  52. package/.docs/reference/ai-sdk/handle-chat-stream.md +11 -0
  53. package/.docs/reference/ai-sdk/with-sse-heartbeat.md +47 -0
  54. package/.docs/reference/core/mastra-class.md +1 -1
  55. package/.docs/reference/evals/checks.md +6 -0
  56. package/.docs/reference/evals/multi-turn-judge.md +101 -0
  57. package/.docs/reference/index.md +4 -0
  58. package/.docs/reference/pubsub/valkey-streams.md +84 -0
  59. package/.docs/reference/rag/vector-databases.md +4 -4
  60. package/.docs/reference/server/express-adapter.md +6 -8
  61. package/.docs/reference/server/hono-adapter.md +19 -6
  62. package/.docs/reference/storage/turso.md +88 -0
  63. package/.docs/reference/streaming/ChunkType.md +29 -1
  64. package/.docs/reference/tools/mcp-client.md +41 -9
  65. package/.docs/reference/vectors/mongodb.md +11 -11
  66. package/.docs/reference/vectors/pg.md +2 -0
  67. package/.docs/reference/workspace/workspace-class.md +15 -3
  68. package/CHANGELOG.md +59 -0
  69. package/package.json +5 -5
@@ -139,6 +139,24 @@ This list isn't exhaustive. To view all endpoints, run `mastra dev` and visit `h
139
139
 
140
140
  To add your own endpoints, see [Custom API Routes](https://mastra.ai/docs/server/custom-api-routes).
141
141
 
142
+ ## Graceful shutdown and rolling deploys
143
+
144
+ By default, the generated server handles `SIGINT` and `SIGTERM`. It stops accepting connections, waits up to [`server.drainTimeout`](https://mastra.ai/reference/configuration) for active requests and streams, then runs `mastra.shutdown()`. The drain timeout defaults to 5 seconds. A second signal terminates the process immediately. See [`server.handleShutdownSignals`](https://mastra.ai/reference/configuration) if you need to manage signals yourself.
145
+
146
+ Increase `drainTimeout` when your hosting platform's termination grace period can accommodate longer turns. Keep enough time after the drain for shutdown cleanup.
147
+
148
+ ```typescript
149
+ import { Mastra } from '@mastra/core/mastra'
150
+
151
+ export const mastra = new Mastra({
152
+ server: {
153
+ drainTimeout: 240_000,
154
+ },
155
+ })
156
+ ```
157
+
158
+ A plain `agent.stream()` call can't resume after its server process exits. If a stream ends without its expected terminal event, treat the turn as interrupted and let the client retry or reconcile it. Use [durable agents](https://mastra.ai/docs/harness/durable-agents) when turns must survive process replacement. [Crash recovery](https://mastra.ai/docs/harness/durable-agents) requires shared persistent run storage and idempotent tools. Replaying missed events after a restart also requires a shared persistent cache such as Redis because the default event cache is in-memory. Multi-replica recovery doesn't yet use a distributed lease.
159
+
142
160
  ## Troubleshooting
143
161
 
144
162
  ### Memory errors during build
@@ -154,4 +172,5 @@ NODE_OPTIONS="--max-old-space-size=4096" mastra build
154
172
  - [Server Overview](https://mastra.ai/docs/server/overview): Configure server behavior, middleware, and authentication
155
173
  - [Server Adapters](https://mastra.ai/docs/server/server-adapters): Use Express or Hono instead of `mastra build`
156
174
  - [Custom API Routes](https://mastra.ai/docs/server/custom-api-routes): Add custom HTTP endpoints
175
+ - [Durable Agents](https://mastra.ai/docs/harness/durable-agents): Persist agent runs so they survive process restarts
157
176
  - [Configuration Reference](https://mastra.ai/reference/configuration): Full configuration options
@@ -29,7 +29,7 @@ Subscribes to workflow events on the [PubSub](https://mastra.ai/docs/server/pubs
29
29
 
30
30
  In a split deployment, the orchestration worker pulls events from a distributed PubSub backend and delegates step execution back to the API over HTTP. In-process, it runs steps directly.
31
31
 
32
- The orchestration worker requires a PubSub backend that supports pull mode (e.g., [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)).
32
+ The orchestration worker requires a PubSub backend that supports pull mode (e.g., [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), [`ValkeyStreamsPubSub`](https://mastra.ai/reference/pubsub/valkey-streams), or [`GoogleCloudPubSub`](https://mastra.ai/reference/pubsub/google-cloud-pubsub)).
33
33
 
34
34
  ### Scheduler worker
35
35
 
@@ -104,7 +104,7 @@ Any [supported storage backend](https://mastra.ai/reference/workers/overview) wo
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
- 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.
107
+ Split deployments require a distributed PubSub backend ([`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), [`ValkeyStreamsPubSub`](https://mastra.ai/reference/pubsub/valkey-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
109
  ### Select workers
110
110
 
@@ -22,6 +22,7 @@ These scorers evaluate how correct, truthful, and complete your agent's answers
22
22
  - [`tool-call-accuracy`](https://mastra.ai/reference/evals/tool-call-accuracy): Evaluates whether the LLM selects the correct tool from available options (`0-1`, higher is better)
23
23
  - [`trajectory-accuracy`](https://mastra.ai/reference/evals/trajectory-accuracy): Evaluates the expected action sequence for all span types. Covered spans include tool and model activity plus workflow steps (`0-1`, higher is better)
24
24
  - [`prompt-alignment`](https://mastra.ai/reference/evals/prompt-alignment): Measures how well agent responses align with user prompt intent, requirements, completeness, and format (`0-1`, higher is better)
25
+ - [`multi-turn-judge`](https://mastra.ai/reference/evals/multi-turn-judge): Grades every assistant turn of a [multi-turn conversation](https://mastra.ai/docs/evals/multi-turn) against a plain-English criterion (`0` or `1`)
25
26
 
26
27
  ### Context quality
27
28
 
@@ -35,6 +35,8 @@ const result = await runEvals({
35
35
 
36
36
  Each turn runs `agent.generate()` with the same thread ID, so the agent sees the full conversation history. Scorers receive the accumulated output messages from all turns.
37
37
 
38
+ > **Prebuilt LLM judges grade one turn:** Prebuilt LLM-judge scorers (rubric, answer relevancy, faithfulness, and the others listed in [Scorer compatibility](#scorer-compatibility)) read a single assistant message, so with `inputs` they grade only the last turn's response. For semantic grading across a conversation, use [`createMultiTurnJudgeScorer()`](https://mastra.ai/reference/evals/multi-turn-judge), which grades every assistant turn against one criterion, or per-turn [`turns[].scorers`](#per-turn-assertions-with-turns), where each turn grades its own output.
39
+
38
40
  ## Memory is required for cross-turn recall
39
41
 
40
42
  Multi-turn recall depends on the agent having a **memory store configured**. The shared thread ID is what lets each turn see the earlier ones, but a thread only persists history when the agent has memory. If the agent has no memory configured, the turns still run sequentially and their outputs still accumulate for scoring, but the agent won't recall earlier turns (each input runs in isolation). `runEvals` logs a warning when you use `inputs` on an agent without memory.
@@ -70,6 +72,85 @@ These details matter when writing scorers for multi-turn items:
70
72
  - **`run.output` is the accumulated output from every turn.** Output-based scorers: `checks.includes`, `checks.calledTool`, `checks.similarity`, and similar: evaluate the whole conversation. For example, `checks.calledTool('get_weather', { times: 2 })` counts calls across all turns.
71
73
  - **`run.input` is only the first turn's input.** Scorers that compare input against output (faithfulness, answer relevancy, and other input-relative LLM scorers) only see the first user message, not the full conversation. Prefer output-based checks for multi-turn, or build scorers that read the accumulated `run.output` directly.
72
74
 
75
+ ### Scorer compatibility
76
+
77
+ Accumulated output only helps if the scorer reads all of it:
78
+
79
+ | Scorer | What it sees with `inputs` |
80
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
81
+ | [Quick Checks](https://mastra.ai/docs/evals/quick-checks): `checks.calledTool`, `checks.includes`, `checks.similarity`, `checks.noToolErrors`, and the rest | The whole conversation. Tool-call checks count calls across every turn, and text checks search all assistant text |
82
+ | [Multi-turn Judge scorer](https://mastra.ai/reference/evals/multi-turn-judge) | Every assistant turn, graded together against one plain-English criterion |
83
+ | Prebuilt LLM-judge scorers: rubric, answer relevancy, answer similarity, faithfulness, hallucination, bias, toxicity, context precision, context recall, context relevance, noise sensitivity, prompt alignment, summarization | Only the last assistant message that carries text. Input-relative judges also see only the first turn's input |
84
+ | Trajectory scorers (`AgentScorerConfig.trajectory`) | The last turn's span when traces are available, otherwise tool calls from all accumulated messages |
85
+ | Custom scorers | Whatever they read from `run.output` |
86
+
87
+ ### Grading a whole conversation
88
+
89
+ To judge every turn together, use [`createMultiTurnJudgeScorer()`](https://mastra.ai/reference/evals/multi-turn-judge). It builds a transcript of every assistant turn and asks a judge model whether the conversation satisfies one plain-English criterion, scoring `1` or `0`:
90
+
91
+ ```typescript
92
+ import { runEvals } from '@mastra/core/evals'
93
+ import { createMultiTurnJudgeScorer } from '@mastra/evals/scorers/prebuilt'
94
+ import { weatherAgent } from '../agents'
95
+
96
+ const result = await runEvals({
97
+ data: [
98
+ {
99
+ inputs: [
100
+ "How's the weather in London?",
101
+ 'And Paris?',
102
+ 'Should I pack an umbrella for London?',
103
+ ],
104
+ },
105
+ ],
106
+ target: weatherAgent,
107
+ scorers: [
108
+ {
109
+ scorer: createMultiTurnJudgeScorer({
110
+ model: 'anthropic/claude-haiku-4-5',
111
+ criterion:
112
+ 'The agent provided forecasts for London and Paris, and gave weather-appropriate packing advice.',
113
+ }),
114
+ threshold: 1,
115
+ },
116
+ ],
117
+ })
118
+ ```
119
+
120
+ To grade something the criterion can't express, write your own scorer that reads the assistant messages out of `run.output`. [`extractAgentResponseMessages()`](https://mastra.ai/reference/evals/scorer-utils) returns the text of each assistant message, in order:
121
+
122
+ ```typescript
123
+ import { createScorer } from '@mastra/core/evals'
124
+ import { extractAgentResponseMessages } from '@mastra/evals/scorers/utils'
125
+ import { z } from 'zod'
126
+
127
+ export const conversationJudge = createScorer({
128
+ id: 'conversation-judge',
129
+ name: 'Conversation Judge',
130
+ description: 'Grades every assistant turn in a conversation against one criterion',
131
+ type: 'agent',
132
+ judge: {
133
+ model: 'anthropic/claude-haiku-4-5',
134
+ instructions: 'You grade multi-turn assistant transcripts against a single criterion.',
135
+ },
136
+ })
137
+ .analyze({
138
+ description: 'Judge the transcript as a whole',
139
+ outputSchema: z.object({ satisfied: z.boolean(), reason: z.string() }),
140
+ createPrompt: ({ run }) => {
141
+ const transcript = extractAgentResponseMessages(run.output)
142
+ .map((text, index) => `Turn ${index + 1}: ${text}`)
143
+ .join('\n\n')
144
+
145
+ return `Grade this conversation:\n\n${transcript}\n\nCriterion: the assistant keeps the forecast consistent across turns.`
146
+ },
147
+ })
148
+ .generateScore(({ results }) => (results.analyzeStepResult?.satisfied ? 1 : 0))
149
+ .generateReason(({ results }) => results.analyzeStepResult?.reason ?? '')
150
+ ```
151
+
152
+ Pass it to `runEvals` like any other scorer. See [Custom scorers](https://mastra.ai/docs/evals/custom-scorers) for the full `createScorer()` pipeline.
153
+
73
154
  ## Per-turn assertions with `turns`
74
155
 
75
156
  The `inputs` form scores the **accumulated** output as a whole, a single score over every turn's output. That can hide per-turn failures: an output-based check like `checks.includes('Brooklyn')` passes if _any_ turn mentions Brooklyn, even when the follow-up turn is broken.
@@ -175,4 +256,6 @@ await runEvals({
175
256
 
176
257
  - [`runEvals()` reference](https://mastra.ai/reference/evals/run-evals): Full API for `runEvals` parameters and returns
177
258
  - [Gates and verdicts](https://mastra.ai/docs/evals/gates-and-verdicts): Enforce hard requirements and quality thresholds
178
- - [Quick Checks](https://mastra.ai/docs/evals/quick-checks): Zero-LLM composable micro-scorers
259
+ - [Quick Checks](https://mastra.ai/docs/evals/quick-checks): Zero-LLM composable micro-scorers
260
+ - [Scorer utilities](https://mastra.ai/reference/evals/scorer-utils): Helpers for reading messages out of a scorer run
261
+ - [Multi-turn Judge scorer](https://mastra.ai/reference/evals/multi-turn-judge): LLM judge that grades every assistant turn together
@@ -115,15 +115,77 @@ For the step-level `scorers` API, see the [Step class reference](https://mastra.
115
115
 
116
116
  **Asynchronous execution**: Live evaluations run in the background without blocking your agent responses or workflow execution. Your AI systems remain responsive while live evaluations monitor them.
117
117
 
118
- **Sampling control**: The `sampling.rate` parameter (0-1) controls what percentage of outputs get scored:
118
+ **Sampling control**: The `sampling.rate` parameter (0-1) controls what fraction of outputs get scored:
119
119
 
120
120
  - `1.0`: Score every single response (100%)
121
121
  - `0.5`: Score half of all responses (50%)
122
122
  - `0.1`: Score 10% of responses
123
123
  - `0.0`: Disable scoring
124
124
 
125
+ Sampling is deterministic per trace: the decision is derived from the trace ID, not drawn at random. In practice:
126
+
127
+ - Scorers configured at the same rate score the same traces, so their scores are comparable on shared traffic.
128
+ - Re-running the same trace produces the same sampling decision, so sampled coverage is reproducible.
129
+
130
+ When a run has no trace (observability not configured), the decision is derived from the run ID instead. If [trace sampling](https://mastra.ai/docs/observability/tracing/overview) declined the trace, scorers skip that run entirely, so scores aren't created for traces that were never stored.
131
+
132
+ **Eligibility filters**: The optional `filter` parameter restricts which runs a scorer is eligible for, using a declarative predicate over the run's context. Filters are evaluated before sampling, so `sampling.rate` applies only to runs that match the filter:
133
+
134
+ ```typescript
135
+ export const myAgent = new Agent({
136
+ // ...
137
+ scorers: {
138
+ relevancy: {
139
+ scorer: createAnswerRelevancyScorer({ model: 'openai/gpt-5-mini' }),
140
+ filter: {
141
+ op: 'eq',
142
+ left: { path: 'requestContext.plan' },
143
+ right: { literal: 'enterprise' },
144
+ },
145
+ sampling: { type: 'ratio', rate: 0.1 },
146
+ },
147
+ },
148
+ })
149
+ ```
150
+
151
+ This scores 10% of enterprise-plan traffic and none of the rest. To score different segments at different rates, bind the same scorer twice with complementary filters.
152
+
153
+ Predicates can reference `requestContext.*`, `entity.*`, `entityType`, `source`, `threadId`, `resourceId`, and `projectId`. They support comparisons (`eq`, `ne`, `lt`, `lte`, `gt`, `gte`), membership (`in`, `notIn`), existence (`exists`, `notExists`), truthiness (`truthy`, `falsy`), and boolean composition (`and`, `or`, `not`). A filter that references an unknown root fails at agent construction rather than silently skipping scoring at runtime. Filters are plain JSON, so they're unaffected by durable agent state serialization.
154
+
155
+ Eligibility filters decide _whether a scorer runs_; to filter _which messages a scorer sees_ once it runs, use [`filterRun()`](https://mastra.ai/reference/evals/filter-run).
156
+
125
157
  **Automatic storage**: All scoring results are automatically stored in the `mastra_scorers` table in your configured database, allowing you to analyze performance trends over time.
126
158
 
159
+ ## Score persistence
160
+
161
+ Scores are persisted when the Mastra instance has `storage` configured, and when the scorer is registered on that instance. Registration is what lets Mastra resolve the scorer's metadata (name, description, type) through [`getScorerById()`](https://mastra.ai/reference/core/getScorerById) before writing the score.
162
+
163
+ Scorers you attach to an agent or a workflow step register themselves. Scorers you pass directly to [`runEvals()`](https://mastra.ai/reference/evals/run-evals), including [Quick Checks](https://mastra.ai/docs/evals/quick-checks), need the `scorers` option on the [`Mastra` class](https://mastra.ai/reference/core/mastra-class):
164
+
165
+ ```typescript
166
+ import { Mastra } from '@mastra/core'
167
+ import { LibSQLStore } from '@mastra/libsql'
168
+ import { checks } from '@mastra/evals/checks'
169
+ import { createAnswerRelevancyScorer } from '@mastra/evals/scorers/prebuilt'
170
+ import { myAgent } from './agents/my-agent'
171
+
172
+ export const mastra = new Mastra({
173
+ agents: { myAgent },
174
+ storage: new LibSQLStore({ url: 'file:./mastra.db' }),
175
+ scorers: {
176
+ calledTool: checks.calledTool('get_weather'),
177
+ includes: checks.includes('Brooklyn'),
178
+ relevancy: createAnswerRelevancyScorer({ model: 'openai/gpt-5-mini' }),
179
+ },
180
+ })
181
+ ```
182
+
183
+ The lookup only compares scorer IDs, so a registered instance can be configured differently from the one you evaluate with. Every `checks.calledTool()` instance has the id `check-called-tool`, so registering one covers all of them, whatever tool name you evaluate with.
184
+
185
+ The arguments still shape the `description` stored alongside each score, which comes from the registered instance, not the one you evaluate with. `checks.calledTool('')` is accepted and persists scores fine, but stores `Checks that "" was called`, so pass a representative value.
186
+
187
+ Skipping registration doesn't change scoring results, but each save fails with a `Scorer with id <id> not found` warning and the scores never reach the store.
188
+
127
189
  ## Trace evaluations
128
190
 
129
191
  In addition to live evaluations, you can use scorers to evaluate historical traces from your agent interactions and workflows.
@@ -241,7 +241,7 @@ await durableAgent.resume(runId, { approved: true })
241
241
 
242
242
  ## Crash recovery
243
243
 
244
- If the server process crashes while a durable agent run is in progress, that run remains in `running` status in storage with no automatic retry. On the next server start you can re-drive these orphaned runs so they pick up where they left off.
244
+ If the server process crashes while a durable agent run is in progress, that run remains in `running` status in storage with no automatic retry. For orderly shutdowns such as rolling deploys, the generated server can also drain in-flight turns before exiting. See [graceful shutdown and rolling deploys](https://mastra.ai/docs/deployment/mastra-server). On the next server start you can re-drive these orphaned runs so they pick up where they left off.
245
245
 
246
246
  ### Automatic recovery
247
247
 
@@ -67,6 +67,8 @@ A local `.env` file is optional. Environment variables stored on the platform ar
67
67
 
68
68
  > **Warning:** Set up [authentication](https://mastra.ai/docs/auth/overview) before exposing your endpoints publicly.
69
69
 
70
+ Each deploy replaces the running server process, which affects agent turns that are still streaming when the new version goes live. Because Mastra Platform doesn't currently provide a configurable or guaranteed termination grace period, don't rely on a raised `server.drainTimeout` for turns that may run longer than the default drain window. Use [durable agents](https://mastra.ai/docs/harness/durable-agents) with persistent storage and cache when turns must survive a deploy, or handle an interrupted stream in the client. See [graceful shutdown and rolling deploys](https://mastra.ai/docs/deployment/mastra-server) for the available strategies.
71
+
70
72
  The first deploy writes a `.mastra-project.json` file linking your directory to the platform project. Commit it so later deploys, CI runs, and [`mastra env`](https://mastra.ai/docs/mastra-platform/environments) commands target the same project without extra flags.
71
73
 
72
74
  ## Deploy to another environment
@@ -175,6 +177,105 @@ In CI, set `MASTRA_PROJECT_ID` and `MASTRA_API_TOKEN` and pass `--yes`:
175
177
  mastra deploy --env production --yes
176
178
  ```
177
179
 
180
+ ## Migrating from server and studio deploys
181
+
182
+ `mastra server deploy` and `mastra studio deploy` are deprecated. They'll be removed in the next major version. Once removed, both commands will fail and legacy-pipeline projects can't deploy a new build until they migrate.
183
+
184
+ Existing deployed services keep running. This only affects your ability to publish new deploys.
185
+
186
+ ### Who this affects
187
+
188
+ You are on the legacy pipeline if any of these are true:
189
+
190
+ - Your last deploy went out with `mastra server deploy` or `mastra studio deploy` and the deploy log printed a **Deprecated** banner.
191
+ - Your project's most recent successful deploy used `@mastra/core` older than `1.44`.
192
+ - Your organization hasn't been opted in to environment deploys.
193
+
194
+ The deploy log is the source of truth: the legacy pipeline prints a deprecation banner on every deploy.
195
+
196
+ ### Migrate
197
+
198
+ 1. Upgrade `@mastra/core` in your project. The environment pipeline calls `setStudio` on the built artifact, which requires `@mastra/core` `>= 1.44`.
199
+
200
+ **npm**:
201
+
202
+ ```bash
203
+ npm install @mastra/core@latest
204
+ ```
205
+
206
+ **pnpm**:
207
+
208
+ ```bash
209
+ pnpm add @mastra/core@latest
210
+ ```
211
+
212
+ **Yarn**:
213
+
214
+ ```bash
215
+ yarn add @mastra/core@latest
216
+ ```
217
+
218
+ **Bun**:
219
+
220
+ ```bash
221
+ bun add @mastra/core@latest
222
+ ```
223
+
224
+ If you are jumping several minor versions, paste the following into a coding agent (Claude Code, Cursor, etc.) to catch breaking changes in APIs you actually use:
225
+
226
+ ```text
227
+ Check whether this project is ready for the Mastra Platform environment pipeline.
228
+
229
+ 1. Find the installed version of `@mastra/core` (check package.json and the
230
+ lockfile for the version that actually resolved, not just the range).
231
+ 2. If it is >= 1.44.0, tell me I'm good — no further action needed.
232
+ 3. If it is < 1.44.0:
233
+ a. Fetch the `@mastra/core` changelog from
234
+ https://github.com/mastra-ai/mastra/blob/main/packages/core/CHANGELOG.md
235
+ and read every entry between my installed version and the latest release.
236
+ b. Scan my project (agents, workflows, tools, memory, storage, deployers,
237
+ telemetry — anywhere `@mastra/core`, `@mastra/*`, or `mastra` is imported)
238
+ and list every Mastra API surface I actually use.
239
+ c. For each used API, cross-reference the changelog and produce a table of:
240
+ API I use → breaking change → severity (breaks build / breaks runtime /
241
+ behavior change / none).
242
+ d. For each "breaks build" or "breaks runtime" row, implement the fix in my
243
+ codebase. For "behavior change" rows, leave a comment at the call site
244
+ explaining what changed so I can decide.
245
+ e. Bump `@mastra/core` (and any `@mastra/*` peers) to the latest matching
246
+ versions, then run typecheck and tests. Report anything still failing.
247
+ 4. Search my scripts, package.json, Dockerfiles, and CI config for
248
+ `mastra server deploy` and `mastra studio deploy`. Replace each
249
+ occurrence with `mastra deploy` — this is the unified command required
250
+ by the environment pipeline.
251
+
252
+ Do not restructure my CI, provision new infra, or change my environment
253
+ variable values — only the Mastra usage in my code and the deploy command
254
+ itself.
255
+ ```
256
+
257
+ 2. Replace the split command in your scripts and CI with the unified command:
258
+
259
+ ```diff
260
+ - mastra server deploy
261
+ - mastra studio deploy
262
+ + mastra deploy
263
+ ```
264
+
265
+ `mastra deploy` builds once and deploys both the server and the Studio UI shell for the target environment. Any recent `mastra` CLI supports it. If yours doesn't, upgrade with `npm install -g mastra@latest`.
266
+
267
+ 3. Deploy once. Your project is auto-adopted onto the environment pipeline and the `production` environment is created on first deploy. See [Environments](https://mastra.ai/docs/mastra-platform/environments) for the full model.
268
+
269
+ 4. Move any project-level environment variables to the environment that needs them, in the dashboard under **Environments → \<env> → Variables**. See [Environment variables](https://mastra.ai/docs/mastra-platform/environments).
270
+
271
+ ### FAQ
272
+
273
+ **My deploy fails with `MASTRA_CORE_TOO_OLD`.** The environment pipeline requires `@mastra/core` `>= 1.44`. Upgrade `@mastra/core` and redeploy.
274
+
275
+ **My organization isn't opted in yet.** Contact support. Opt-in will be automatic before the next major version.
276
+
277
+ **Can I roll back?** Yes. Environments retain deploy history and you can redeploy any prior successful artifact from the dashboard.
278
+
178
279
  ## Related
179
280
 
180
281
  - [Environments](https://mastra.ai/docs/mastra-platform/environments)
@@ -6,8 +6,6 @@ Server on Mastra platform is a production deployment target that runs your Mastr
6
6
 
7
7
  You get a stable API endpoint with environment variable management and custom domain support, plus deploy history out of the box.
8
8
 
9
- > **Note:** `mastra server deploy` is the earlier split deploy path. New projects should use the unified [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) command, which adds preflight validation, environments, and CLI-managed databases.
10
-
11
9
  > **Note:** Server deploy provisions hosted storage automatically. If you override storage with [LibSQLStore](https://mastra.ai/integrations/databases/libsql) and a file URL, switch to a remotely hosted database because Mastra platform uses an ephemeral filesystem.
12
10
 
13
11
  ## Quickstart
@@ -43,7 +41,7 @@ You get a stable API endpoint with environment variable management and custom do
43
41
  3. Deploy your project:
44
42
 
45
43
  ```bash
46
- mastra server deploy
44
+ mastra deploy
47
45
  ```
48
46
 
49
47
  If you're not already authenticated, the CLI prompts you to log in. It stores your credentials locally and any subsequent CLI commands use these credentials.
@@ -157,7 +155,7 @@ Automate deployments from GitHub Actions, GitLab CI, or any CI provider. After y
157
155
  Pass `--yes` (or `-y`) to skip all confirmation prompts. Without it, the CLI waits for interactive input and your CI job hangs.
158
156
 
159
157
  ```bash
160
- mastra server deploy --yes
158
+ mastra deploy --yes
161
159
  ```
162
160
 
163
161
  ### GitHub Actions
@@ -184,15 +182,13 @@ jobs:
184
182
  - name: Install dependencies
185
183
  run: npm install
186
184
  - name: Deploy to Mastra platform
187
- run: npx mastra server deploy --yes
185
+ run: npx mastra deploy --yes
188
186
  env:
189
187
  MASTRA_API_TOKEN: ${{ secrets.MASTRA_API_TOKEN }}
190
188
  ```
191
189
 
192
190
  Adjust the `paths` filter and `working-directory` if your Mastra project is in a subdirectory (e.g. a monorepo).
193
191
 
194
- > **Note:** For Studio deploys, replace `mastra server deploy` with `mastra studio deploy`. The flags and environment variables are the same.
195
-
196
192
  ### GitLab CI
197
193
 
198
194
  The following pipeline deploys on pushes to `main`:
@@ -206,7 +202,7 @@ deploy:
206
202
  before_script:
207
203
  - npm install
208
204
  script:
209
- - npx mastra server deploy --yes
205
+ - npx mastra deploy --yes
210
206
  ```
211
207
 
212
208
  Add `MASTRA_API_TOKEN` as a CI/CD variable in **Settings → CI/CD → Variables**.
@@ -217,7 +213,7 @@ Any CI system that runs Node.js and shell commands works with Mastra:
217
213
 
218
214
  1. Install dependencies.
219
215
  2. Set `MASTRA_API_TOKEN` as an environment variable.
220
- 3. Run `mastra server deploy --yes` (or `mastra studio deploy --yes`).
216
+ 3. Run `mastra deploy --yes`.
221
217
 
222
218
  ### Verify the deploy
223
219
 
@@ -253,8 +249,7 @@ The CLI reads `organizationId` and `projectId` from `.mastra-project.json` by de
253
249
 
254
250
  ## Related
255
251
 
256
- - [`mastra server deploy`](https://mastra.ai/reference/cli/mastra)
252
+ - [`mastra deploy`](https://mastra.ai/reference/cli/mastra)
257
253
  - [`mastra server pause`](https://mastra.ai/reference/cli/mastra)
258
254
  - [`mastra server restart`](https://mastra.ai/reference/cli/mastra)
259
- - [`mastra studio deploy`](https://mastra.ai/reference/cli/mastra)
260
255
  - [`mastra auth tokens`](https://mastra.ai/reference/cli/mastra)
@@ -6,8 +6,6 @@ Studio on Mastra platform is a hosted visual workspace for testing agents and ru
6
6
 
7
7
  You can deploy Studio from the CLI as shown below, or link a GitHub repository for push-to-deploy. See the [GitHub integration](https://mastra.ai/docs/mastra-platform/github) for the repository-linked flow.
8
8
 
9
- > **Note:** `mastra studio deploy` is the earlier split deploy path. New projects should use the unified [`mastra deploy`](https://mastra.ai/docs/mastra-platform/deploy) command, which adds preflight validation, environments, and CLI-managed databases.
10
-
11
9
  ## Quickstart
12
10
 
13
11
  1. Follow the [get started guide](https://mastra.ai/docs) to create your first Mastra project.
@@ -41,7 +39,7 @@ You can deploy Studio from the CLI as shown below, or link a GitHub repository f
41
39
  3. Deploy Studio with a single command:
42
40
 
43
41
  ```bash
44
- mastra studio deploy
42
+ mastra deploy
45
43
  ```
46
44
 
47
45
  On a successful deploy, the CLI outputs the URL of your deployed Studio instance.
@@ -50,11 +48,11 @@ On your first deploy, the CLI prompts you to create a new project or select an e
50
48
 
51
49
  ## How deploy works
52
50
 
53
- The `mastra studio deploy` command builds your project and compiles `src/mastra/` into `.mastra/output`. It packages that output as an artifact ZIP, then uploads and deploys it to a cloud sandbox.
51
+ The `mastra deploy` command builds your project and compiles `src/mastra/` into `.mastra/output`. It packages that output as an artifact ZIP, then uploads and deploys it to a cloud sandbox.
54
52
 
55
53
  A deploy transitions through **queued → uploading → starting → running** or **failed** if something goes wrong. If a sandbox is already running for your project, the platform updates it in place with no downtime. Otherwise, it creates a fresh sandbox. Your instance URL is assigned per project slug and remains stable across deploys.
56
54
 
57
- See the [`mastra studio deploy` CLI reference](https://mastra.ai/reference/cli/mastra) for the full list of flags and CI/CD usage.
55
+ See the [`mastra deploy` CLI reference](https://mastra.ai/reference/cli/mastra) for the full list of flags and CI/CD usage.
58
56
 
59
57
  ## Environment files
60
58
 
@@ -63,17 +61,17 @@ A local env file is optional. When a `.env` or `.env.*` file is present in the p
63
61
  When multiple env files are present, the CLI prompts you to pick one. To select non-interactively, pass `--env-file`:
64
62
 
65
63
  ```bash
66
- mastra studio deploy --env-file .env.production --yes
64
+ mastra deploy --env-file .env.production --yes
67
65
  ```
68
66
 
69
- To run the same codebase across `production` and `staging`, use the unified [`mastra deploy --env`](https://mastra.ai/docs/mastra-platform/deploy) command instead. [Environments](https://mastra.ai/docs/mastra-platform/environments) replace the earlier pattern of one project per environment.
67
+ To run the same codebase across `production` and `staging`, use [`mastra deploy --env`](https://mastra.ai/docs/mastra-platform/deploy). See [Environments](https://mastra.ai/docs/mastra-platform/environments) for the full model.
70
68
 
71
69
  ## Create a new project non-interactively
72
70
 
73
- `mastra studio deploy` can create a project on first run. If `--project <name>` doesn't match an existing project, the CLI uses the value as the new project name and creates it after confirmation. Combined with `--yes`, this is fully scriptable:
71
+ `mastra deploy` can create a project on first run. If `--project <name>` doesn't match an existing project, the CLI uses the value as the new project name and creates it after confirmation. Combined with `--yes`, this is fully scriptable:
74
72
 
75
73
  ```bash
76
- mastra studio deploy --project "my-new-project" --yes
74
+ mastra deploy --project "my-new-project" --yes
77
75
  ```
78
76
 
79
77
  Use this from CI or AI coding agents instead of `mastra studio projects create`, which is interactive only.
@@ -84,4 +82,4 @@ To deploy Studio on your own infrastructure, see [Studio deployment](https://mas
84
82
 
85
83
  ## Related
86
84
 
87
- - [`mastra studio deploy`](https://mastra.ai/reference/cli/mastra)
85
+ - [`mastra deploy`](https://mastra.ai/reference/cli/mastra)
@@ -87,11 +87,12 @@ MastraStorageExporter automatically selects the optimal tracing strategy based o
87
87
 
88
88
  ### Available Strategies
89
89
 
90
- | Strategy | Description | Use Case |
91
- | ---------------------- | --------------------------------------------------------- | ----------------------------------- |
92
- | **realtime** | Process each event immediately | Development, debugging, low traffic |
93
- | **batch-with-updates** | Buffer events and batch write with full lifecycle support | Low volume Production |
94
- | **insert-only** | Only process completed spans, ignore updates | High volume Production |
90
+ | Strategy | Description | Use Case |
91
+ | ---------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------ |
92
+ | **realtime** | Process each event immediately | Development, debugging, low traffic |
93
+ | **batch-with-updates** | Buffer events and batch write with full lifecycle support | Low volume Production |
94
+ | **insert-only** | Only process completed spans, ignore updates | High volume Production |
95
+ | **event-sourced** | Write one row when a span starts and another when it ends, then collapse them on read | High volume Production, in-progress traces |
95
96
 
96
97
  ### Strategy Configuration
97
98
 
@@ -99,7 +100,7 @@ MastraStorageExporter automatically selects the optimal tracing strategy based o
99
100
  new MastraStorageExporter({
100
101
  strategy: 'auto', // Default - let storage provider decide
101
102
  // or explicitly set:
102
- // strategy: 'realtime' | 'batch-with-updates' | 'insert-only'
103
+ // strategy: 'realtime' | 'batch-with-updates' | 'insert-only' | 'event-sourced'
103
104
 
104
105
  // Batching configuration (applies to both batch-with-updates and insert-only)
105
106
  maxBatchSize: 1000, // Max spans per batch
@@ -116,14 +117,17 @@ If you set the strategy to `'auto'`, the `MastraStorageExporter` automatically s
116
117
 
117
118
  ### Providers with Observability Support
118
119
 
119
- | Storage Provider | Preferred Strategy | Supported Strategies | Recommended Use |
120
- | --------------------------------------------------------------------- | ------------------ | ------------------------------- | ------------------------------------- |
121
- | **[ClickHouse](https://mastra.ai/integrations/databases/clickhouse)** | insert-only | insert-only | Production (high-volume) |
122
- | **[PostgreSQL](https://mastra.ai/integrations/databases/postgresql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
123
- | **[MSSQL](https://mastra.ai/integrations/databases/mssql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
124
- | **[MongoDB](https://mastra.ai/integrations/databases/mongodb)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
125
- | **[OracleDB](https://mastra.ai/integrations/databases/oracledb)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
126
- | **[libSQL](https://mastra.ai/integrations/databases/libsql)** | batch-with-updates | batch-with-updates, insert-only | Default storage, good for development |
120
+ | Storage Provider | Preferred Strategy | Supported Strategies | Recommended Use |
121
+ | ----------------------------------------------------------------------------- | ------------------ | ------------------------------- | ------------------------------------- |
122
+ | **[ClickHouse](https://mastra.ai/integrations/databases/clickhouse)** | insert-only | insert-only | Production (high-volume) |
123
+ | **[PostgresStore](https://mastra.ai/integrations/databases/postgresql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
124
+ | **[PostgresStoreVNext](https://mastra.ai/integrations/databases/postgresql)** | event-sourced | event-sourced | Production (high-volume) |
125
+ | **[MSSQL](https://mastra.ai/integrations/databases/mssql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
126
+ | **[MongoDB](https://mastra.ai/integrations/databases/mongodb)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
127
+ | **[OracleDB](https://mastra.ai/integrations/databases/oracledb)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
128
+ | **[libSQL](https://mastra.ai/integrations/databases/libsql)** | batch-with-updates | batch-with-updates, insert-only | Default storage, good for development |
129
+
130
+ > **Note:** Under `insert-only`, only completed spans are persisted, and span start and update events are ignored. A trace therefore becomes visible in Studio only after its root span ends, and filtering traces by `status: 'running'` returns no results. `PostgresStoreVNext` uses `event-sourced` tracing instead, so in-progress traces remain visible while preserving append-only writes.
127
131
 
128
132
  ### Providers without Observability Support
129
133
 
@@ -141,6 +145,7 @@ The following storage providers **don't support** the observability domain. If y
141
145
  - **realtime**: Immediate visibility, best for debugging
142
146
  - **batch-with-updates**: 10-100x throughput improvement, full span lifecycle
143
147
  - **insert-only**: Additional 70% reduction in database operations, perfect for analytics
148
+ - **event-sourced**: Append-only like insert-only, but in-progress traces stay visible in Studio while a run executes
144
149
 
145
150
  ## Production recommendations
146
151
 
@@ -7,7 +7,7 @@ A filesystem gives an agent tools for reading, writing, listing, and [searching]
7
7
  Configure files in two ways:
8
8
 
9
9
  - [Direct filesystem access](#direct-filesystem-access) uses `filesystem` with one filesystem provider or a [`CompositeFilesystem`](#manual-composition) that you create yourself.
10
- - [Mounts](#mounts) uses `mounts` to create a `CompositeFilesystem` from path-prefixed providers. When the workspace also has a static sandbox, Mastra attempts to mount each provider at its configured path inside the sandbox so commands can access the same files. Remote sandbox mounts typically use Filesystem in Userspace (FUSE).
10
+ - [Mounts](#mounts) uses `mounts` to create a `CompositeFilesystem` from path-prefixed providers. When a static sandbox and filesystem provider support mounting, Mastra automatically mounts the provider at its configured path. Remote sandbox mounts typically use Filesystem in Userspace (FUSE).
11
11
 
12
12
  Configure either `filesystem` or `mounts`, not both. Configuring both throws a `WorkspaceError` with the code `INVALID_CONFIG`.
13
13
 
@@ -71,7 +71,7 @@ See [Search](https://mastra.ai/docs/sandbox/search) to index the files for keywo
71
71
 
72
72
  ## Mounts
73
73
 
74
- Use `mounts` when programs inside a sandbox need to access persistent files by path. The agent still receives file tools, while command tools can run commands such as `ls`, `cat`, or `python` against the same files.
74
+ Use `mounts` when programs inside a sandbox need to access persistent files by path. Mastra creates the mount automatically when the sandbox and filesystem provider support it. The agent still receives file tools, while command tools can run commands such as `ls`, `cat`, or `python` against the same files.
75
75
 
76
76
  For example, mount an S3 bucket at `/workspace` inside a Daytona sandbox:
77
77
 
@@ -180,7 +180,7 @@ Use manual composition when another part of your application needs the composite
180
180
 
181
181
  ## Mount availability
182
182
 
183
- File tools and composite routing work without FUSE. Remote sandboxes can use FUSE to make cloud storage visible to commands. `LocalSandbox` uses symlinks instead.
183
+ File tools and composite routing work without a sandbox mount. When a remote sandbox and filesystem provider support mounting, `mounts` automatically uses FUSE to make the files visible to commands. `LocalSandbox` uses symlinks instead.
184
184
 
185
185
  Built-in sandbox mounting currently includes:
186
186
 
@@ -195,27 +195,27 @@ Remote mounts may require `s3fs`, `gcsfuse`, or `blobfuse2` inside the sandbox.
195
195
 
196
196
  If a sandbox mount is unavailable or fails, the workspace remains usable. File tools continue to access the provider through its SDK, but commands can't see that path. Mastra describes these providers to the agent as available through file tools only.
197
197
 
198
- ## Multi-tenant filesystems
198
+ ## Filesystems per user or thread
199
199
 
200
200
  The `filesystem` option accepts a resolver when storage should vary by request, user, role, or tenant:
201
201
 
202
202
  ```typescript
203
203
  const workspace = new Workspace({
204
204
  filesystem: ({ requestContext }) => {
205
- const tenantId = requestContext.get('tenant-id') as string
205
+ const userId = requestContext.get('user-id') as string
206
206
 
207
207
  return new S3Filesystem({
208
208
  bucket: process.env.S3_BUCKET!,
209
209
  region: process.env.S3_REGION!,
210
- prefix: `tenants/${tenantId}`,
210
+ prefix: `users/${userId}`,
211
211
  })
212
212
  },
213
213
  })
214
214
  ```
215
215
 
216
- Each tenant gets its own filesystem view, and file tools resolve the provider from the request context automatically.
216
+ Each user gets a separate filesystem view, and file tools resolve the provider from the request context automatically.
217
217
 
218
- `mounts` doesn't accept a resolver and can't be combined with a sandbox resolver. When each user or thread needs separate storage inside a separate sandbox, create and mount the provider inside the sandbox resolver. See [Multi-tenant sandboxes](https://mastra.ai/docs/sandbox/overview).
218
+ `mounts` doesn't accept a resolver and can't be combined with a sandbox resolver. When each user or thread needs separate storage inside a separate sandbox, create and mount the provider inside the sandbox resolver. See [Sandboxes per user or thread](https://mastra.ai/docs/sandbox/overview).
219
219
 
220
220
  ## Policies and containment
221
221