@mastra/mcp-docs-server 1.2.8-alpha.0 → 1.2.8-alpha.19

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 (157) hide show
  1. package/.docs/docs/agent-builder/deploying.md +1 -0
  2. package/.docs/docs/agent-builder/integrations.md +1 -3
  3. package/.docs/docs/agent-builder/overview.md +1 -1
  4. package/.docs/docs/agent-controller/overview.md +1 -1
  5. package/.docs/docs/agents/overview.md +17 -13
  6. package/.docs/docs/agents/skills.md +1 -3
  7. package/.docs/docs/agents/structured-output.md +14 -7
  8. package/.docs/docs/agents/using-tools.md +80 -26
  9. package/.docs/docs/browser/agent-browser.md +1 -0
  10. package/.docs/docs/browser/firecrawl.md +129 -0
  11. package/.docs/docs/browser/overview.md +16 -2
  12. package/.docs/docs/capabilities/channels/other-adapters.md +1 -1
  13. package/.docs/docs/capabilities/channels/overview.md +1 -0
  14. package/.docs/docs/capabilities/channels/slack.md +113 -3
  15. package/.docs/docs/deployment/mastra-server.md +35 -0
  16. package/.docs/docs/deployment/monorepo.md +2 -0
  17. package/.docs/docs/deployment/overview.md +6 -0
  18. package/.docs/docs/deployment/sandbox.md +277 -0
  19. package/.docs/docs/editor/overview.md +2 -6
  20. package/.docs/docs/editor/tools.md +2 -6
  21. package/.docs/docs/evals/multi-turn.md +178 -0
  22. package/.docs/docs/evals/overview.md +1 -0
  23. package/.docs/docs/evals/running-in-ci.md +3 -9
  24. package/.docs/docs/getting-started/file-based-agents.md +2 -2
  25. package/.docs/docs/index.md +17 -13
  26. package/.docs/docs/long-running-agents/background-tasks.md +2 -2
  27. package/.docs/docs/long-running-agents/durable-agents.md +2 -1
  28. package/.docs/docs/long-running-agents/schedules.md +2 -2
  29. package/.docs/docs/mastra-platform/database.md +13 -6
  30. package/.docs/docs/mastra-platform/deploy.md +17 -8
  31. package/.docs/docs/mastra-platform/environments.md +5 -4
  32. package/.docs/docs/mastra-platform/overview.md +1 -1
  33. package/.docs/docs/mastra-platform/regions.md +73 -0
  34. package/.docs/docs/mastra-platform/workspace.md +111 -0
  35. package/.docs/docs/mcp/overview.md +1 -1
  36. package/.docs/docs/memory/multi-user-threads.md +4 -4
  37. package/.docs/docs/memory/observational-memory.md +78 -3
  38. package/.docs/docs/memory/overview.md +4 -0
  39. package/.docs/docs/memory/working-memory.md +1 -1
  40. package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
  41. package/.docs/docs/observability/integrations/exporters/braintrust.md +34 -2
  42. package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
  43. package/.docs/docs/server/auth/simple-auth.md +1 -3
  44. package/.docs/docs/server/request-context.md +2 -0
  45. package/.docs/docs/studio/overview.md +2 -0
  46. package/.docs/docs/voice/livekit.md +1 -1
  47. package/.docs/docs/workflows/control-flow.md +1 -3
  48. package/.docs/docs/workspace/filesystem.md +1 -0
  49. package/.docs/docs/workspace/sandbox.md +1 -0
  50. package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -0
  51. package/.docs/guides/guide/signal-provider.md +2 -0
  52. package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
  53. package/.docs/models/environment-variables.md +1 -0
  54. package/.docs/models/gateways/openrouter.md +340 -345
  55. package/.docs/models/gateways/vercel.md +6 -5
  56. package/.docs/models/index.md +1 -1
  57. package/.docs/models/providers/alibaba-token-plan-cn.md +22 -21
  58. package/.docs/models/providers/alibaba-token-plan.md +22 -21
  59. package/.docs/models/providers/ambient.md +12 -10
  60. package/.docs/models/providers/baseten.md +3 -2
  61. package/.docs/models/providers/crossmodel.md +2 -1
  62. package/.docs/models/providers/deepinfra.md +4 -7
  63. package/.docs/models/providers/empiriolabs.md +2 -1
  64. package/.docs/models/providers/evroc.md +3 -2
  65. package/.docs/models/providers/google.md +2 -2
  66. package/.docs/models/providers/kilo.md +1 -1
  67. package/.docs/models/providers/kimi-for-coding.md +10 -11
  68. package/.docs/models/providers/llmgateway.md +3 -8
  69. package/.docs/models/providers/moonshotai-cn.md +3 -2
  70. package/.docs/models/providers/moonshotai.md +3 -2
  71. package/.docs/models/providers/nebius.md +3 -1
  72. package/.docs/models/providers/novita-ai.md +3 -1
  73. package/.docs/models/providers/ollama-cloud.md +25 -42
  74. package/.docs/models/providers/opencode-go.md +5 -3
  75. package/.docs/models/providers/orcarouter.md +1 -1
  76. package/.docs/models/providers/privatemode-ai.md +10 -10
  77. package/.docs/models/providers/thinkingmachines.md +73 -0
  78. package/.docs/models/providers/togetherai.md +2 -6
  79. package/.docs/models/providers/zenmux.md +3 -1
  80. package/.docs/models/providers.md +1 -0
  81. package/.docs/reference/acp/acp-agent.md +2 -0
  82. package/.docs/reference/acp/create-acp-tool.md +28 -0
  83. package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
  84. package/.docs/reference/agent-controller/session.md +15 -0
  85. package/.docs/reference/agents/agent.md +14 -2
  86. package/.docs/reference/agents/durable-agent.md +23 -0
  87. package/.docs/reference/agents/generate.md +19 -1
  88. package/.docs/reference/browser/firecrawl-browser.md +71 -0
  89. package/.docs/reference/cli/mastra.md +14 -6
  90. package/.docs/reference/code-sdk/mount-agent-controller.md +1 -3
  91. package/.docs/reference/core/getMCPServer.md +1 -3
  92. package/.docs/reference/core/getMCPServerById.md +1 -3
  93. package/.docs/reference/core/getTool.md +33 -0
  94. package/.docs/reference/core/getToolById.md +48 -0
  95. package/.docs/reference/core/getWorkflow.md +1 -3
  96. package/.docs/reference/core/listMCPServers.md +2 -6
  97. package/.docs/reference/core/listTools.md +38 -0
  98. package/.docs/reference/core/mastra-class.md +1 -1
  99. package/.docs/reference/datasets/addItem.md +1 -3
  100. package/.docs/reference/datasets/addItems.md +1 -3
  101. package/.docs/reference/datasets/compareExperiments.md +1 -3
  102. package/.docs/reference/datasets/create.md +1 -3
  103. package/.docs/reference/datasets/dataset.md +2 -6
  104. package/.docs/reference/datasets/datasets-manager.md +5 -15
  105. package/.docs/reference/datasets/delete.md +1 -3
  106. package/.docs/reference/datasets/deleteExperiment.md +1 -3
  107. package/.docs/reference/datasets/deleteItem.md +1 -3
  108. package/.docs/reference/datasets/deleteItems.md +1 -3
  109. package/.docs/reference/datasets/get.md +1 -3
  110. package/.docs/reference/datasets/getDetails.md +1 -3
  111. package/.docs/reference/datasets/getExperiment.md +1 -3
  112. package/.docs/reference/datasets/getItem.md +1 -3
  113. package/.docs/reference/datasets/getItemHistory.md +1 -3
  114. package/.docs/reference/datasets/list.md +1 -3
  115. package/.docs/reference/datasets/listExperimentResults.md +1 -3
  116. package/.docs/reference/datasets/listExperiments.md +1 -3
  117. package/.docs/reference/datasets/listItems.md +1 -3
  118. package/.docs/reference/datasets/listVersions.md +1 -3
  119. package/.docs/reference/datasets/startExperiment.md +1 -3
  120. package/.docs/reference/datasets/startExperimentAsync.md +1 -3
  121. package/.docs/reference/datasets/update.md +1 -3
  122. package/.docs/reference/datasets/updateItem.md +1 -3
  123. package/.docs/reference/editor/mastra-editor.md +1 -3
  124. package/.docs/reference/evals/context-recall.md +205 -0
  125. package/.docs/reference/evals/create-scorer.md +4 -10
  126. package/.docs/reference/evals/mastra-scorer.md +1 -3
  127. package/.docs/reference/evals/run-evals.md +94 -2
  128. package/.docs/reference/file-based-agents/logger.md +1 -1
  129. package/.docs/reference/file-based-agents/tools.md +7 -6
  130. package/.docs/reference/index.md +8 -0
  131. package/.docs/reference/memory/observational-memory.md +21 -0
  132. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
  133. package/.docs/reference/processors/token-limiter-processor.md +1 -3
  134. package/.docs/reference/rag/database-config.md +12 -0
  135. package/.docs/reference/storage/clickhouse.md +1 -1
  136. package/.docs/reference/storage/convex.md +17 -10
  137. package/.docs/reference/storage/retention.md +1 -1
  138. package/.docs/reference/streaming/agents/stream.md +3 -1
  139. package/.docs/reference/tools/create-tool.md +78 -52
  140. package/.docs/reference/tools/mcp-client.md +104 -24
  141. package/.docs/reference/tools/mcp-server.md +143 -44
  142. package/.docs/reference/tools/task-tools.md +2 -2
  143. package/.docs/reference/tools/tavily.md +1 -1
  144. package/.docs/reference/tools/vector-query-tool.md +22 -0
  145. package/.docs/reference/vectors/mongodb.md +2 -0
  146. package/.docs/reference/vectors/turbopuffer.md +4 -0
  147. package/.docs/reference/voice/mistral.md +127 -0
  148. package/.docs/reference/workspace/daytona-sandbox.md +2 -6
  149. package/.docs/reference/workspace/platform-filesystem.md +182 -0
  150. package/.docs/reference/workspace/platform-sandbox.md +200 -0
  151. package/CHANGELOG.md +71 -0
  152. package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
  153. package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
  154. package/dist/index.js +1 -1
  155. package/dist/stdio.js +1 -1
  156. package/dist/tools/docs.d.ts.map +1 -1
  157. package/package.json +8 -8
@@ -0,0 +1,178 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Multi-turn evals
4
+
5
+ Multi-turn evals test agent behavior across a conversation. Instead of a single `input`, you provide an `inputs` array. Each entry is sent sequentially to the agent on the same thread, and scorers see the accumulated output from all turns.
6
+
7
+ ## When to use multi-turn evals
8
+
9
+ - The agent uses memory and must recall context from earlier turns
10
+ - The agent handles follow-up questions that depend on prior responses
11
+ - You need to verify tool-call sequences across a conversation
12
+ - The agent runs a multi-step workflow (search, confirm, execute)
13
+
14
+ ## Quickstart
15
+
16
+ ```typescript
17
+ import { runEvals } from '@mastra/core/evals'
18
+ import { checks } from '@mastra/evals/checks'
19
+ import { weatherAgent } from '../agents'
20
+
21
+ const result = await runEvals({
22
+ data: [
23
+ {
24
+ inputs: [
25
+ 'What is the weather in Brooklyn?',
26
+ 'What about tomorrow?',
27
+ 'Compare the two forecasts.',
28
+ ],
29
+ },
30
+ ],
31
+ target: weatherAgent,
32
+ scorers: [checks.calledTool('get_weather', { times: 2 }), checks.includes('Brooklyn')],
33
+ })
34
+ ```
35
+
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
+
38
+ ## Memory is required for cross-turn recall
39
+
40
+ 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 will not recall earlier turns (each input runs in isolation). `runEvals` logs a warning when you use `inputs` on an agent without memory.
41
+
42
+ `runEvals` manages the conversation identity for you: it generates the shared `threadId` and injects a `resourceId` (Mastra memory scopes messages by resource + thread, so both are required for recall to work). By default the resource is derived from the generated thread so each conversation is isolated. To pin a specific resource — for example to reuse an existing user's memory — pass `targetOptions.memory.resource`; `runEvals` still owns the thread, so you don't provide one:
43
+
44
+ ```typescript
45
+ await runEvals({
46
+ target: weatherAgent,
47
+ data: [{ inputs: ['What is the weather in Brooklyn?', 'What about tomorrow?'] }],
48
+ scorers: [checks.similarity('weather forecast')],
49
+ targetOptions: { memory: { resource: 'user-42' } },
50
+ })
51
+ ```
52
+
53
+ See [Memory](https://mastra.ai/docs/memory/overview) for how to configure a memory store.
54
+
55
+ ## How it works
56
+
57
+ When a data item has an `inputs` array, `runEvals`:
58
+
59
+ 1. Creates a fresh thread (unique `threadId`) and resource for the conversation (a caller-provided `targetOptions.memory.resource` is preserved)
60
+ 2. Sends each input sequentially via `agent.generate()` on that thread
61
+ 3. Accumulates all output messages across turns
62
+ 4. Passes the full accumulated output to scorers for evaluation
63
+
64
+ Scorers see the complete conversation output, not just the last turn.
65
+
66
+ ## Scoring semantics
67
+
68
+ Two details matter when writing scorers for multi-turn items:
69
+
70
+ - **`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
+ - **`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
+
73
+ ## Per-turn assertions with `turns`
74
+
75
+ The `inputs` form scores the **accumulated** output holistically — 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.
76
+
77
+ When you need to assert that a **specific turn** behaved correctly, use `turns` instead. Each turn is an object with its own `input` and optional `gates`/`scorers` that evaluate **only that turn's** input and output:
78
+
79
+ ```typescript
80
+ import { runEvals } from '@mastra/core/evals'
81
+ import { checks } from '@mastra/evals/checks'
82
+ import { weatherAgent } from '../agents'
83
+
84
+ const result = await runEvals({
85
+ data: [
86
+ {
87
+ turns: [
88
+ {
89
+ input: 'What is the weather in Brooklyn?',
90
+ gates: [checks.calledTool('get_weather')],
91
+ },
92
+ {
93
+ // The follow-up must call the tool again — it can't be satisfied
94
+ // by the first turn's tool call.
95
+ input: 'What about tomorrow?',
96
+ gates: [checks.calledTool('get_weather')],
97
+ scorers: [{ scorer: checks.similarity('tomorrow forecast'), threshold: 0.5 }],
98
+ },
99
+ ],
100
+ },
101
+ ],
102
+ target: weatherAgent,
103
+ })
104
+
105
+ result.verdict // 'passed' | 'scored' | 'failed'
106
+ result.turnResults // per-turn gate/threshold/scorer outcomes
107
+ ```
108
+
109
+ Semantics:
110
+
111
+ - A per-turn gate or scorer sees **only that turn's** `run.input` and `run.output` — never the accumulated conversation. This fixes both blind spots of `inputs`: the wrong turn can't satisfy a check, and `run.input` is correct for each turn.
112
+ - Per-turn outcomes fold into the overall [verdict](https://mastra.ai/docs/evals/gates-and-verdicts): a failing turn gate makes the verdict `failed`; a missed turn threshold (with gates passing) makes it `scored`.
113
+ - `result.turnResults[i]` reports each turn's `gateResults`, `thresholdResults`, and `scores`, so a failure points at the exact turn. Across multiple conversations, turn results are averaged by turn index.
114
+ - A turn with no `gates`/`scorers` just advances the conversation.
115
+ - Top-level `scorers`/`gates` still run holistically over the accumulated output, so you can combine "this turn must call the tool" with "the overall answer mentions Brooklyn."
116
+ - When the agent has storage configured, each per-turn scorer/gate result is persisted like top-level scores, so per-turn outcomes appear in your scores store. Each stored per-turn score is labeled with its turn index (`metadata.turnIndex`), shares the conversation's `threadId`, and links to that turn's own trace span.
117
+
118
+ Use `inputs` when a single holistic score over the whole conversation is enough; use `turns` when correctness depends on individual turns. `turns` cannot be combined with `input` or `inputs` in the same data item.
119
+
120
+ ## Combining with gates and thresholds
121
+
122
+ Multi-turn data items work with [gates and verdicts](https://mastra.ai/docs/evals/gates-and-verdicts). Use output-based scorers so gating reflects the full conversation:
123
+
124
+ ```typescript
125
+ import { runEvals } from '@mastra/core/evals'
126
+ import { checks } from '@mastra/evals/checks'
127
+
128
+ const result = await runEvals({
129
+ data: [
130
+ {
131
+ inputs: ['My favorite city is Brooklyn.', 'What is the weather in my favorite city?'],
132
+ },
133
+ ],
134
+ target: weatherAgent,
135
+ gates: [checks.calledTool('get_weather')],
136
+ scorers: [{ scorer: checks.similarity('Brooklyn weather forecast'), threshold: 0.5 }],
137
+ })
138
+
139
+ result.verdict // 'passed' | 'scored' | 'failed'
140
+ ```
141
+
142
+ ## Mixing single-turn and multi-turn
143
+
144
+ A single `runEvals` call can include both single-turn and multi-turn data items:
145
+
146
+ ```typescript
147
+ const result = await runEvals({
148
+ data: [
149
+ { input: 'What is the weather in Brooklyn?' },
150
+ {
151
+ inputs: ['My favorite city is Brooklyn.', 'What is the weather in my favorite city?'],
152
+ },
153
+ ],
154
+ target: weatherAgent,
155
+ scorers: [checks.includes('Brooklyn')],
156
+ })
157
+ ```
158
+
159
+ Single-turn items use `input` as usual. Multi-turn items use `inputs` — `input` can be omitted entirely.
160
+
161
+ ## Validation
162
+
163
+ `runEvals` throws a `MastraError` if `inputs` is present but empty:
164
+
165
+ ```typescript
166
+ // Throws: 'inputs' must be a non-empty array
167
+ await runEvals({
168
+ data: [{ inputs: [] }],
169
+ target: myAgent,
170
+ scorers: [myScorer],
171
+ })
172
+ ```
173
+
174
+ ## Related
175
+
176
+ - [`runEvals()` reference](https://mastra.ai/reference/evals/run-evals): Full API for `runEvals` parameters and returns
177
+ - [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
@@ -142,6 +142,7 @@ Once registered, you can score traces interactively within Studio under the **Ob
142
142
 
143
143
  - Use [Quick Checks](https://mastra.ai/docs/evals/quick-checks) for fast, deterministic assertions on text and tool usage
144
144
  - Add [gates and verdicts](https://mastra.ai/docs/evals/gates-and-verdicts) to enforce hard requirements and quality thresholds
145
+ - Test [multi-turn conversations](https://mastra.ai/docs/evals/multi-turn) where behavior emerges across sequential turns
145
146
  - Learn how to create your own scorers in the [Creating Custom Scorers](https://mastra.ai/docs/evals/custom-scorers) guide
146
147
  - Explore built-in scorers in the [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers) section
147
148
  - Test scorers with [Studio](https://mastra.ai/docs/studio/overview)
@@ -71,24 +71,18 @@ Create separate test cases for different evaluation scenarios:
71
71
 
72
72
  ```typescript
73
73
  describe('Weather Agent Tests', () => {
74
- const locationScorer = createScorer({
75
- /* ... */
76
- })
74
+ const locationScorer = createScorer({/* ... */})
77
75
 
78
76
  it('should handle location disambiguation', async () => {
79
77
  const result = await runEvals({
80
78
  data: [
81
79
  {
82
80
  input: 'weather in Berlin',
83
- groundTruth: {
84
- /* ... */
85
- },
81
+ groundTruth: {/* ... */},
86
82
  },
87
83
  {
88
84
  input: 'weather in Berlin, Maryland',
89
- groundTruth: {
90
- /* ... */
91
- },
85
+ groundTruth: {/* ... */},
92
86
  },
93
87
  ],
94
88
  target: weatherAgent,
@@ -10,9 +10,9 @@ File-based agents are an experimental, convention-based way to define [Mastra ag
10
10
 
11
11
  This approach reduces glue code and makes the file system itself a direct representation of your [project structure](https://mastra.ai/reference/project-structure), so both you and your coding agent can understand it at a glance.
12
12
 
13
- You can build your entire project with file-based agents or combine this approach with agents and other primitives defined directly in code, making it easy to adopt incrementally.
13
+ You can build your entire project with file-based agents or combine this approach with agents and other primitives defined directly in code for incremental adoption.
14
14
 
15
- File-based agents have some limitations while in beta. Not every Mastra feature can be defined in a file yet, and they are not the best fit for dynamic configuration or runtime wiring. When needed, you can define agents and related primitives directly in code.
15
+ File-based agents have some limitations while in beta. Not every Mastra feature can be defined in a file yet, and they're not the best fit for dynamic configuration or runtime wiring. When needed, you can define agents and related primitives directly in code.
16
16
 
17
17
  > **Note:** All Mastra documentation currently shows agents and primitives defined directly in code. File-based agents use the same underlying concepts and APIs, so the guidance elsewhere in the docs still applies. As file-based agents mature, more examples may use this structure where appropriate.
18
18
 
@@ -44,17 +44,31 @@ export const weatherTool = createTool({
44
44
  location: z.string().describe('City name'),
45
45
  }),
46
46
  outputSchema: z.object({
47
- output: z.string(),
47
+ location: z.string(),
48
+ temperatureCelsius: z.number(),
49
+ conditions: z.string(),
48
50
  }),
49
51
  execute: async ({ location }) => {
50
52
  return {
51
- output: `The weather in ${location} is sunny`,
53
+ location,
54
+ temperatureCelsius: 21,
55
+ conditions: 'sunny',
52
56
  }
53
57
  },
54
58
  })
55
59
  ```
56
60
 
57
- If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`. For OpenAI models, use `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
61
+ If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
62
+
63
+ By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`. Example: Any `openai/<model>` requires the `OPENAI_API_KEY` environment variable. Go to <https://mastra.ai/models/environment-variables> for a full list of supported providers and their environment variable names.
64
+
65
+ Short list of known model IDs are:
66
+
67
+ - `openai/gpt-5.5`, `openai/gpt-5-mini`
68
+ - `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-7`, `anthropic/claude-haiku-4-5`
69
+ - `google/gemini-2.5-flash`
70
+
71
+ Go to <https://mastra.ai/models> for a full list of supported models.
58
72
 
59
73
  Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
60
74
 
@@ -83,16 +97,6 @@ export const weatherAgent = new Agent({
83
97
  })
84
98
  ```
85
99
 
86
- By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`. Example: Any `openai/<model>` requires the `OPENAI_API_KEY` environment variable. Go to <https://mastra.ai/models/environment-variables> for a full list of supported providers and their environment variable names.
87
-
88
- Short list of known model IDs are:
89
-
90
- - `openai/gpt-5.5`, `openai/gpt-5-mini`
91
- - `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-7`, `anthropic/claude-haiku-4-5`
92
- - `google/gemini-2.5-flash`
93
-
94
- Go to <https://mastra.ai/models> for a full list of supported models.
95
-
96
100
  Create a Mastra entry point at `src/mastra/index.ts` and register the agent:
97
101
 
98
102
  ```ts
@@ -66,8 +66,8 @@ export const researchTool = createTool({
66
66
  timeoutMs: 600_000,
67
67
  maxRetries: 1,
68
68
  },
69
- execute: async ({ context }) => {
70
- // ...
69
+ execute: async ({ topic }) => {
70
+ // Run the research job for topic
71
71
  },
72
72
  })
73
73
  ```
@@ -159,8 +159,9 @@ cleanup()
159
159
  ```typescript
160
160
  import { createDurableAgent } from '@mastra/core/agent/durable'
161
161
  import { RedisServerCache } from '@mastra/redis'
162
+ import Redis from 'ioredis'
162
163
 
163
- const cache = new RedisServerCache({ url: 'redis://localhost:6379' })
164
+ const cache = new RedisServerCache({ client: new Redis('redis://localhost:6379') })
164
165
 
165
166
  export const durableAgent = createDurableAgent({
166
167
  agent,
@@ -30,7 +30,7 @@ const pinger = new Agent({
30
30
 
31
31
  const mastra = new Mastra({
32
32
  agents: { pinger },
33
- storage: new LibSQLStore({ url: 'file:./mastra.db' }),
33
+ storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' }),
34
34
  })
35
35
 
36
36
  await mastra.schedules.create({
@@ -164,7 +164,7 @@ Hooks let you run code at key points in an agent schedule's lifecycle, for examp
164
164
  ```typescript
165
165
  const mastra = new Mastra({
166
166
  agents: { pinger },
167
- storage: new LibSQLStore({ url: 'file:./mastra.db' }),
167
+ storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' }),
168
168
  schedules: {
169
169
  prepare: async ({ agentId, schedule, trigger }) => {
170
170
  // Return overrides, null to skip this fire, or undefined for defaults
@@ -34,8 +34,8 @@ For most agent-focused projects, **Turso** is the simplest starting point. It pr
34
34
 
35
35
  A database is attached at one of two scopes:
36
36
 
37
- - **Project scope**: The default. One database shared by all of the project's [environments](https://mastra.ai/docs/mastra-platform/environments). Its variables are injected into every deploy.
38
- - **Environment scope**: Attached to a single environment. Use this to isolate data between environments, for example separate production and staging databases.
37
+ - **Environment scope**: The default. Attached to a single environment so data stays isolated between environments (for example separate production and staging databases). When your project has one environment, `mastra env db create` picks it automatically; with several, the CLI prompts you to select one.
38
+ - **Project scope**: One database shared by all of the project's [environments](https://mastra.ai/docs/mastra-platform/environments). Opt in with `--shared`. Its variables are injected into every deploy.
39
39
 
40
40
  The scope is set when you attach the database and shown in `mastra env db list`.
41
41
 
@@ -43,22 +43,28 @@ The two scopes can't overlap for the same provider. Because a project-scoped dat
43
43
 
44
44
  ## Attach with the CLI
45
45
 
46
- Create and attach a database in one command. The CLI polls until it's ready, which takes a few seconds:
46
+ You don't have to run this command up front. If your project needs a hosted database but doesn't have one yet, `mastra deploy` offers to attach one for you when the deploy preflight check runs. Say yes and the deploy continues without leaving the CLI.
47
+
48
+ Alternatively, create and attach a database ahead of time. The CLI polls until it's ready, which takes a few seconds:
47
49
 
48
50
  ```bash
49
- # Shared by all environments
51
+ # Scoped to a single environment (the CLI picks the only one, or prompts if there are several)
50
52
  mastra env db create --kind turso
51
53
 
52
- # Scoped to the staging environment
54
+ # Scoped to a specific environment
53
55
  mastra env db create staging --kind turso
56
+
57
+ # Shared by all environments
58
+ mastra env db create --kind turso --shared
54
59
  ```
55
60
 
56
61
  Supported kinds are `turso` and `neon` (Postgres). Useful flags:
57
62
 
63
+ - `--shared`: Attach a project-scoped database shared by every environment. Cannot be combined with an environment argument.
58
64
  - `--name <name>`: Database name. Defaults to a name derived from the project slug.
59
65
  - `--region <region>`: Provider region ID for project-scoped databases (for example `fra`). Environment-scoped databases are placed near the environment's region automatically, and an explicit `--region` is ignored.
60
66
  - `--no-wait`: Return immediately instead of polling. Check progress later with `mastra env db show`.
61
- - `--json`: Machine-readable output.
67
+ - `--json`: Machine-readable output. When the project has multiple environments, `--json` requires an environment argument or `--shared` (no interactive prompt).
62
68
 
63
69
  Inspect and manage attached databases:
64
70
 
@@ -99,6 +105,7 @@ Turso exposes two environment variables: `TURSO_DATABASE_URL` and `TURSO_AUTH_TO
99
105
  import { LibSQLStore } from '@mastra/libsql'
100
106
 
101
107
  export const storage = new LibSQLStore({
108
+ id: 'mastra-storage',
102
109
  url: process.env.TURSO_DATABASE_URL!,
103
110
  authToken: process.env.TURSO_AUTH_TOKEN!,
104
111
  })
@@ -26,24 +26,31 @@ A local `.env` file is optional. Environment variables stored on the platform ar
26
26
 
27
27
  On the first run the CLI prompts you to create the platform project (named after your `package.json`) and the `production` environment. Accept the prompts, or pass `--yes` to accept defaults without confirmation.
28
28
 
29
- 2. The CLI runs a preflight check before anything ships. Storage that would fall back to a local file path blocks the deploy, because local files don't survive on the platform's ephemeral filesystem:
29
+ 2. The CLI runs a preflight check before anything ships. Storage that would fall back to a local file path (which doesn't survive on the platform's ephemeral filesystem) would normally block the deploy:
30
30
 
31
31
  ```text
32
- [LOCAL_STORAGE_PATH] file:./mastra.db will be used at runtime because TURSO_DATABASE_URL is not set
32
+ file:./mastra.db will be used at runtime because TURSO_DATABASE_URL is not set
33
33
  ```
34
34
 
35
- Attach a [hosted database](https://mastra.ai/docs/mastra-platform/database) that provides the missing variables:
35
+ Instead of erroring out, the CLI offers to fix it inline for you:
36
+
37
+ ```text
38
+ Preflight needs TURSO_DATABASE_URL for the production environment. Create a managed turso database now and attach it? (Y/n)
39
+ ```
40
+
41
+ Accept the prompt and provisioning takes a few seconds — the database's connection variables are injected into your deploys automatically, with nothing to copy into an `.env` file. Decline it, or run in a non-interactive shell (CI, `--yes`), and the CLI falls back to the previous behavior: it prints the exact command to run yourself.
36
42
 
37
43
  ```bash
38
- mastra env db create --kind turso
44
+ mastra env db create production --kind turso
39
45
  ```
40
46
 
41
- Provisioning takes a few seconds. The database's connection variables are injected into your deploys automatically, with nothing to copy into an `.env` file.
47
+ The environment slug (`production` above) matches the environment the CLI would have deployed to this is important because `mastra env db create` requires an environment argument in non-interactive shells when the project has more than one environment.
42
48
 
43
- > **Note:** If preflight reports a hard-coded local path instead (`Build contains a host-local storage URL`), guard it with an environment variable first so the file is only used during local development:
49
+ > **Note:** If preflight reports a hard-coded local path instead (`Build contains a host-local storage URL`), it can't offer the inline fix — guard the path with an environment variable first so the file is only used during local development:
44
50
  >
45
51
  > ```ts
46
52
  > new LibSQLStore({
53
+ > id: 'mastra-storage',
47
54
  > // Uses the hosted database when deployed, a local file during development
48
55
  > url: process.env.TURSO_DATABASE_URL ?? 'file:./mastra.db',
49
56
  > authToken: process.env.TURSO_AUTH_TOKEN,
@@ -76,18 +83,19 @@ Pass `--region` when a deploy creates a new environment to control where it runs
76
83
  mastra deploy --env production --region eu
77
84
  ```
78
85
 
79
- The region is fixed when the environment is created. Databases attached to an environment are placed near that environment's region automatically.
86
+ The region is fixed when the environment is created. Databases attached to an environment are placed near that environment's region automatically, and observability data is routed to the ingest region that matches the environment's residency zone. See [Regions](https://mastra.ai/docs/mastra-platform/regions) for the full list of supported regions, database placement, and observability co-location.
80
87
 
81
88
  ## Preflight checks
82
89
 
83
90
  Preflight validates the built output before anything ships, and only flags issues in your own code:
84
91
 
85
- - **Local storage paths**: A hard block. File-backed storage (for example `file:./mastra.db`) is lost on every deploy. Preflight passes when the path is guarded by an environment variable that is set locally, stored on the platform, or provided by a managed database:
92
+ - **Local storage paths**: A hard block. File-backed storage (for example `file:./mastra.db`) is lost on every deploy. Preflight passes when the path is guarded by an environment variable that's set locally, stored on the platform, or provided by a managed database:
86
93
 
87
94
  ```ts
88
95
  import { LibSQLStore } from '@mastra/libsql'
89
96
 
90
97
  export const storage = new LibSQLStore({
98
+ id: 'mastra-storage',
91
99
  // Uses the hosted database when deployed, a local file during development
92
100
  url: process.env.TURSO_DATABASE_URL ?? 'file:./mastra.db',
93
101
  authToken: process.env.TURSO_AUTH_TOKEN,
@@ -137,6 +145,7 @@ mastra deploy --env production --yes
137
145
  ## Related
138
146
 
139
147
  - [Environments](https://mastra.ai/docs/mastra-platform/environments)
148
+ - [Regions](https://mastra.ai/docs/mastra-platform/regions)
140
149
  - [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
141
150
  - [`mastra deploy` CLI reference](https://mastra.ai/reference/cli/mastra)
142
151
  - [Configuration](https://mastra.ai/docs/mastra-platform/configuration)
@@ -26,7 +26,7 @@ mastra deploy --env staging
26
26
  mastra env create eu-preview --type preview --region eu
27
27
  ```
28
28
 
29
- Each project has a single `production` environment, created by your first deploy. The region is fixed at creation. Databases attached to an environment are placed near the environment's region automatically. The number of environments per project depends on your plan.
29
+ Each project has a single `production` environment, created by your first deploy. The region is fixed at creation. Databases attached to an environment are placed near the environment's region automatically, and observability data is routed to the ingest region for the matching residency zone. See [Regions](https://mastra.ai/docs/mastra-platform/regions) for the supported regions, database placement, and observability co-location. The number of environments per project depends on your plan.
30
30
 
31
31
  ## List environments
32
32
 
@@ -77,16 +77,16 @@ Each row shows the deploy status, environment, timestamp, and which deploy is cu
77
77
 
78
78
  ## Isolate an environment's data
79
79
 
80
- By default a hosted database attached to the project is shared by all environments. To isolate production data from staging data, attach a separate database to each environment instead:
80
+ Hosted databases are scoped to a single environment by default, so production and staging each read and write their own database:
81
81
 
82
82
  ```bash
83
83
  mastra env db create production --kind turso --name my-project-production-db
84
84
  mastra env db create staging --kind turso --name my-project-staging-db
85
85
  ```
86
86
 
87
- Each environment then reads and writes only its own database.
87
+ If you'd rather share one database across every environment, attach it with `--shared` instead: `mastra env db create --kind turso --shared`.
88
88
 
89
- An environment can only use one database per provider. If the project already has a shared project-scoped database of the same provider, attaching an environment-scoped one is rejected with a variable name conflict — delete the shared database with `mastra env db delete` first. Deleting a database destroys it with the provider along with all of its data, so export anything you need to keep. See [Hosted databases](https://mastra.ai/docs/mastra-platform/database) for the full scoping model.
89
+ An environment can only use one database per provider. If the project already has a shared (`--shared`) database of the same provider, attaching an environment-scoped one is rejected with a variable name conflict — delete the shared database with `mastra env db delete` first. Deleting a database destroys it with the provider along with all of its data, so export anything you need to keep. See [Hosted databases](https://mastra.ai/docs/mastra-platform/database) for the full scoping model.
90
90
 
91
91
  ## Delete an environment
92
92
 
@@ -99,5 +99,6 @@ The CLI asks for confirmation before deleting. Deleting an environment removes i
99
99
  ## Related
100
100
 
101
101
  - [Deploy](https://mastra.ai/docs/mastra-platform/deploy)
102
+ - [Regions](https://mastra.ai/docs/mastra-platform/regions)
102
103
  - [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
103
104
  - [`mastra env` CLI reference](https://mastra.ai/reference/cli/mastra)
@@ -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`) and provision [**Hosted databases**](https://mastra.ai/docs/mastra-platform/database) from the CLI or project settings to persist application data 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 [**Workspace**](https://mastra.ai/docs/mastra-platform/workspace) per environment that gives agents a filesystem and a sandbox with no manual configuration.
14
14
 
15
15
  ## Get started
16
16
 
@@ -0,0 +1,73 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Regions
4
+
5
+ A region controls where a platform environment runs, where its [hosted database](https://mastra.ai/docs/mastra-platform/database) is placed, and where its observability data is stored. The region is fixed when the environment is created and can't be changed later.
6
+
7
+ Mastra platform offers two residency zones today, `us` and `eu`, backed by specific compute regions on Railway. Databases and observability follow the environment's region automatically.
8
+
9
+ ## Choose a region
10
+
11
+ Pass `--region` when creating or first deploying to an environment:
12
+
13
+ ```bash
14
+ mastra deploy --env production --region eu
15
+ mastra env create staging --region us
16
+ ```
17
+
18
+ Both `mastra deploy --region` and `mastra env create --region` accept either the `us` / `eu` shorthand or a canonical Railway region code from the table below. Shorthand is the recommended form.
19
+
20
+ The default when no region is passed is `us`, which resolves to `pdx` (Portland, Oregon).
21
+
22
+ ## Available regions
23
+
24
+ The residency selector offers four Railway regions across two zones. `us` and `eu` shorthand resolve to the underlined default in each zone.
25
+
26
+ | Zone | Railway code | Location |
27
+ | ---- | --------------- | ------------------------- |
28
+ | `us` | `pdx` (default) | Portland, Oregon |
29
+ | `us` | `iad` | Ashburn, Virginia |
30
+ | `us` | `sfo` | San Francisco, California |
31
+ | `eu` | `ams` (default) | Amsterdam, Netherlands |
32
+
33
+ Pass a Railway code directly when you need to pin an environment to a specific data center. Passing `us` selects `pdx`, and passing `eu` selects `ams`.
34
+
35
+ > **Note:** Additional Railway regions exist in the deploy pipeline (for example Singapore, `sin`) but aren't offered in the residency selector yet, because hosted databases and observability don't have local placement outside the US and EU. Passing an unrecognized region falls back to the US default rather than pinning to it.
36
+
37
+ ## Hosted database placement
38
+
39
+ When you attach an [environment-scoped database](https://mastra.ai/docs/mastra-platform/database), the platform picks the provider region closest to the environment. This is server-authoritative, so an explicit `--region` on `mastra env db create <env>` is ignored. The environment's region is the source of truth.
40
+
41
+ | Environment region | Turso region | Postgres (Neon) region |
42
+ | ------------------ | ----------------- | ------------------------------ |
43
+ | `pdx` | `sjc` (San Jose) | `aws-us-west-2` (Oregon) |
44
+ | `iad` | `iad` (Ashburn) | `aws-us-east-1` (N. Virginia) |
45
+ | `sfo` | `sjc` (San Jose) | `aws-us-west-2` (Oregon) |
46
+ | `ams` | `ams` (Amsterdam) | `aws-eu-central-1` (Frankfurt) |
47
+
48
+ Project-scoped databases (shared across environments) accept an explicit `--region` because they aren't bound to a single environment. Use a provider region ID for the flag, not the `us` / `eu` shorthand:
49
+
50
+ ```bash
51
+ mastra env db create --kind turso --region fra
52
+ mastra env db create --kind neon --region aws-us-east-1
53
+ ```
54
+
55
+ Turso offers 20+ regions and Postgres (Neon) is available across AWS and Azure regions in the US, EU, and APAC. See the [Turso regions list](https://docs.turso.tech/features/data-edge#locations) and [Neon regions list](https://neon.com/docs/introduction/regions) for the full set. Passing a code not offered by the provider fails at attach time with the provider's error.
56
+
57
+ ## Observability co-location
58
+
59
+ Observability ingest runs in two regions today: **US** (Iowa, `us-central1`) and **EU** (Amsterdam). Every environment's traces, logs, and metrics are routed to the ingest region that matches its residency zone:
60
+
61
+ | Environment region | Observability region |
62
+ | ----------------------------------- | -------------------- |
63
+ | `pdx`, `iad`, `sfo`, `us` shorthand | US (Iowa) |
64
+ | `ams`, `eu` shorthand | EU (Amsterdam) |
65
+
66
+ Compute and databases can be placed in more Railway and provider regions than observability supports, so co-location isn't perfect for every combination. A `us`-zone environment always sends telemetry to US ingest, and an `eu`-zone environment always sends telemetry to EU ingest, even if the underlying Railway region is a specific city not directly served by an ingest endpoint. Data residency is preserved at the zone level. Telemetry from an `eu` environment never crosses into the US.
67
+
68
+ ## Related
69
+
70
+ - [Deploy](https://mastra.ai/docs/mastra-platform/deploy)
71
+ - [Environments](https://mastra.ai/docs/mastra-platform/environments)
72
+ - [Hosted databases](https://mastra.ai/docs/mastra-platform/database)
73
+ - [Observability](https://mastra.ai/docs/mastra-platform/observability)