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

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 (147) 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/regions.md +73 -0
  33. package/.docs/docs/mcp/overview.md +1 -1
  34. package/.docs/docs/memory/multi-user-threads.md +4 -4
  35. package/.docs/docs/memory/observational-memory.md +78 -3
  36. package/.docs/docs/memory/overview.md +4 -0
  37. package/.docs/docs/memory/working-memory.md +1 -1
  38. package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
  39. package/.docs/docs/observability/integrations/exporters/braintrust.md +34 -2
  40. package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
  41. package/.docs/docs/server/auth/simple-auth.md +1 -3
  42. package/.docs/docs/server/request-context.md +2 -0
  43. package/.docs/docs/studio/overview.md +2 -0
  44. package/.docs/docs/voice/livekit.md +1 -1
  45. package/.docs/docs/workflows/control-flow.md +1 -3
  46. package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -0
  47. package/.docs/guides/guide/signal-provider.md +2 -0
  48. package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
  49. package/.docs/models/environment-variables.md +1 -0
  50. package/.docs/models/gateways/openrouter.md +339 -345
  51. package/.docs/models/gateways/vercel.md +6 -5
  52. package/.docs/models/index.md +1 -1
  53. package/.docs/models/providers/ambient.md +12 -10
  54. package/.docs/models/providers/baseten.md +3 -2
  55. package/.docs/models/providers/crossmodel.md +2 -1
  56. package/.docs/models/providers/deepinfra.md +4 -7
  57. package/.docs/models/providers/empiriolabs.md +2 -1
  58. package/.docs/models/providers/evroc.md +3 -2
  59. package/.docs/models/providers/google.md +2 -2
  60. package/.docs/models/providers/kilo.md +1 -1
  61. package/.docs/models/providers/kimi-for-coding.md +10 -11
  62. package/.docs/models/providers/llmgateway.md +3 -8
  63. package/.docs/models/providers/moonshotai-cn.md +3 -2
  64. package/.docs/models/providers/moonshotai.md +3 -2
  65. package/.docs/models/providers/nebius.md +3 -1
  66. package/.docs/models/providers/ollama-cloud.md +25 -42
  67. package/.docs/models/providers/opencode-go.md +5 -3
  68. package/.docs/models/providers/orcarouter.md +1 -1
  69. package/.docs/models/providers/privatemode-ai.md +10 -10
  70. package/.docs/models/providers/thinkingmachines.md +73 -0
  71. package/.docs/models/providers/togetherai.md +2 -6
  72. package/.docs/models/providers/zenmux.md +2 -1
  73. package/.docs/models/providers.md +1 -0
  74. package/.docs/reference/acp/acp-agent.md +2 -0
  75. package/.docs/reference/acp/create-acp-tool.md +28 -0
  76. package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
  77. package/.docs/reference/agent-controller/session.md +15 -0
  78. package/.docs/reference/agents/agent.md +14 -2
  79. package/.docs/reference/agents/durable-agent.md +23 -0
  80. package/.docs/reference/agents/generate.md +19 -1
  81. package/.docs/reference/browser/firecrawl-browser.md +71 -0
  82. package/.docs/reference/cli/mastra.md +14 -6
  83. package/.docs/reference/code-sdk/mount-agent-controller.md +1 -3
  84. package/.docs/reference/core/getMCPServer.md +1 -3
  85. package/.docs/reference/core/getMCPServerById.md +1 -3
  86. package/.docs/reference/core/getTool.md +33 -0
  87. package/.docs/reference/core/getToolById.md +48 -0
  88. package/.docs/reference/core/getWorkflow.md +1 -3
  89. package/.docs/reference/core/listMCPServers.md +2 -6
  90. package/.docs/reference/core/listTools.md +38 -0
  91. package/.docs/reference/core/mastra-class.md +1 -1
  92. package/.docs/reference/datasets/addItem.md +1 -3
  93. package/.docs/reference/datasets/addItems.md +1 -3
  94. package/.docs/reference/datasets/compareExperiments.md +1 -3
  95. package/.docs/reference/datasets/create.md +1 -3
  96. package/.docs/reference/datasets/dataset.md +2 -6
  97. package/.docs/reference/datasets/datasets-manager.md +5 -15
  98. package/.docs/reference/datasets/delete.md +1 -3
  99. package/.docs/reference/datasets/deleteExperiment.md +1 -3
  100. package/.docs/reference/datasets/deleteItem.md +1 -3
  101. package/.docs/reference/datasets/deleteItems.md +1 -3
  102. package/.docs/reference/datasets/get.md +1 -3
  103. package/.docs/reference/datasets/getDetails.md +1 -3
  104. package/.docs/reference/datasets/getExperiment.md +1 -3
  105. package/.docs/reference/datasets/getItem.md +1 -3
  106. package/.docs/reference/datasets/getItemHistory.md +1 -3
  107. package/.docs/reference/datasets/list.md +1 -3
  108. package/.docs/reference/datasets/listExperimentResults.md +1 -3
  109. package/.docs/reference/datasets/listExperiments.md +1 -3
  110. package/.docs/reference/datasets/listItems.md +1 -3
  111. package/.docs/reference/datasets/listVersions.md +1 -3
  112. package/.docs/reference/datasets/startExperiment.md +1 -3
  113. package/.docs/reference/datasets/startExperimentAsync.md +1 -3
  114. package/.docs/reference/datasets/update.md +1 -3
  115. package/.docs/reference/datasets/updateItem.md +1 -3
  116. package/.docs/reference/editor/mastra-editor.md +1 -3
  117. package/.docs/reference/evals/create-scorer.md +4 -10
  118. package/.docs/reference/evals/mastra-scorer.md +1 -3
  119. package/.docs/reference/evals/run-evals.md +94 -2
  120. package/.docs/reference/file-based-agents/logger.md +1 -1
  121. package/.docs/reference/file-based-agents/tools.md +7 -6
  122. package/.docs/reference/index.md +5 -0
  123. package/.docs/reference/memory/observational-memory.md +21 -0
  124. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
  125. package/.docs/reference/processors/token-limiter-processor.md +1 -3
  126. package/.docs/reference/rag/database-config.md +12 -0
  127. package/.docs/reference/storage/clickhouse.md +1 -1
  128. package/.docs/reference/storage/convex.md +17 -10
  129. package/.docs/reference/storage/retention.md +1 -1
  130. package/.docs/reference/streaming/agents/stream.md +3 -1
  131. package/.docs/reference/tools/create-tool.md +78 -52
  132. package/.docs/reference/tools/mcp-client.md +104 -24
  133. package/.docs/reference/tools/mcp-server.md +143 -44
  134. package/.docs/reference/tools/task-tools.md +2 -2
  135. package/.docs/reference/tools/tavily.md +1 -1
  136. package/.docs/reference/tools/vector-query-tool.md +22 -0
  137. package/.docs/reference/vectors/mongodb.md +2 -0
  138. package/.docs/reference/vectors/turbopuffer.md +4 -0
  139. package/.docs/reference/voice/mistral.md +127 -0
  140. package/.docs/reference/workspace/daytona-sandbox.md +2 -6
  141. package/CHANGELOG.md +64 -0
  142. package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
  143. package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
  144. package/dist/index.js +1 -1
  145. package/dist/stdio.js +1 -1
  146. package/dist/tools/docs.d.ts.map +1 -1
  147. package/package.json +7 -7
@@ -53,7 +53,7 @@ export const yourAgent = new Agent({
53
53
 
54
54
  ## Create a Slack app
55
55
 
56
- To connect your agent, create a Slack app in the workspace where you want it to run. The Slack app controls how your agent appears in Slack, what it can do, and which events it receives.
56
+ To connect your agent, create a Slack app in the workspace where you want it to run. The Slack app controls your agent's display in Slack, its capabilities, and the events it receives.
57
57
 
58
58
  This guide uses a [manifest](https://docs.slack.dev/app-manifests/configuring-apps-with-app-manifests/#creating_manifests): a configuration file that creates the Slack app settings for you. This is the fastest path when you are adding your agent to your own workspace. It doesn't cover the platform OAuth flow where other workspaces install your agent.
59
59
 
@@ -63,7 +63,59 @@ Create the Slack app from a manifest:
63
63
  2. Select **Create an app**.
64
64
  3. Select **From a manifest**.
65
65
  4. Choose the workspace where the agent should run.
66
- 5. Paste this manifest, then select **Create**:
66
+ 5. Paste this manifest, then select **Create**. Slack accepts JSON or YAML, so use whichever tab matches the format shown in the app creation modal:
67
+
68
+ **JSON**:
69
+
70
+ ```json
71
+ {
72
+ "display_information": {
73
+ "name": "mastra-agent"
74
+ },
75
+ "features": {
76
+ "app_home": {
77
+ "home_tab_enabled": false,
78
+ "messages_tab_enabled": true,
79
+ "messages_tab_read_only_enabled": false
80
+ },
81
+ "bot_user": {
82
+ "display_name": "mastra-agent",
83
+ "always_online": true
84
+ }
85
+ },
86
+ "oauth_config": {
87
+ "scopes": {
88
+ "bot": [
89
+ "im:write",
90
+ "app_mentions:read",
91
+ "channels:history",
92
+ "channels:read",
93
+ "chat:write",
94
+ "users:read",
95
+ "im:read",
96
+ "im:history"
97
+ ]
98
+ },
99
+ "pkce_enabled": false
100
+ },
101
+ "settings": {
102
+ "event_subscriptions": {
103
+ "request_url": "https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook",
104
+ "bot_events": ["app_mention", "message.channels", "message.im"]
105
+ },
106
+ "interactivity": {
107
+ "is_enabled": true,
108
+ "request_url": "https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook"
109
+ },
110
+ "org_deploy_enabled": false,
111
+ "socket_mode_enabled": false,
112
+ "token_rotation_enabled": false,
113
+ "is_mcp_enabled": false
114
+ }
115
+ }
116
+ ```
117
+
118
+ **YAML**:
67
119
 
68
120
  ```yaml
69
121
  display_information:
@@ -109,7 +161,7 @@ This manifest configures:
109
161
  - `display_information.name` and `features.bot_user.display_name`: Set your agent's name in Slack. You can update it at any time; remember to reinstall the app after changing names or permissions.
110
162
  - `app_home.messages_tab_enabled` and `app_home.messages_tab_read_only_enabled`: Enable direct messages from the Slack app's **Messages** tab.
111
163
  - `always_online`: Shows the Slack bot user as always available.
112
- - `oauth_config.scopes.bot`: Grants the bot permission to post messages, read channel messages where it is present, read mentions, read and write direct messages, and look up users.
164
+ - `oauth_config.scopes.bot`: Grants the bot permission to post messages, read channel messages where it's present, read mentions, read and write direct messages, and look up users.
113
165
  - `event_subscriptions`: Tells Slack which message events to send to the webhook.
114
166
  - `interactivity`: Enables interactive cards and tells Slack where to send card actions.
115
167
 
@@ -211,12 +263,70 @@ Mention the bot in the channel:
211
263
 
212
264
  The agent responds in the thread. Response content depends on the model, instructions, memory, and tools configured on the agent.
213
265
 
266
+ ## Authentication
267
+
268
+ The Slack adapter has no built-in user allowlist. Once the app is installed, anyone in the workspace can talk to the agent by sending it a direct message or mentioning it in a channel where it's a member. Slack verifies each request with the signing secret, and Mastra runs the agent for every valid message the webhook receives.
269
+
270
+ The main mechanism for controlling access is channel membership. The bot only receives events from direct messages and from channels it has been invited to, so the set of channels the bot belongs to defines who can reach it. Keep the bot out of channels where it shouldn't respond, and remove it from a channel to cut off access.
271
+
272
+ For finer control, gate on the sender's identity. Every request carries the sender's Slack user ID in the channel [request context](#request-context), so you can allow or deny specific users in an input processor or tool before the agent acts.
273
+
274
+ ### Server authentication
275
+
276
+ The Slack webhook route is exempt from Mastra's [server authentication](https://mastra.ai/docs/server/auth). Slack can't send a bearer token, so Mastra registers the channel webhook as a public route and verifies each request with the Slack signing secret instead. This holds even when you enable a provider like [`MastraAuthSimple`](https://mastra.ai/docs/server/auth/simple-auth): the rest of your API stays protected, but the webhook route relies on the signing secret rather than your server auth. Keep `SLACK_SIGNING_SECRET` set so the adapter can reject requests that Slack didn't sign.
277
+
278
+ ### External channels
279
+
280
+ Shared channels ([Slack Connect](https://slack.com/connect)) let people from other workspaces join a conversation. If a workspace member adds the bot to a shared channel, everyone in that channel can talk to the agent, including external members outside your organization. Anyone who can reach the agent can also reach the tools and data it has access to.
281
+
282
+ Treat adding the bot to a shared or external channel as granting those participants access to the agent. Before you do, confirm the agent's tools and data are safe to expose to outside members, and gate on the sender's user ID when you need to restrict who the agent responds to.
283
+
284
+ ## Request context
285
+
286
+ On every message, Mastra places a channel context object on the [request context](https://mastra.ai/docs/server/request-context) under the `channel` key. It carries the sender's Slack display name and user ID, the bot's own identity, and details about where the message came from. Read it from an input processor or a tool to identify the user or branch on the conversation type:
287
+
288
+ ```typescript
289
+ import { createTool } from '@mastra/core/tools'
290
+ import type { ChannelContext } from '@mastra/core/channels'
291
+ import { z } from 'zod'
292
+
293
+ export const whoami = createTool({
294
+ id: 'whoami',
295
+ description: 'Return the Slack identity of the current user',
296
+ inputSchema: z.object({}),
297
+ execute: async (_input, context) => {
298
+ const channel = context?.requestContext?.get('channel') as ChannelContext | undefined
299
+
300
+ return {
301
+ platform: channel?.platform,
302
+ userId: channel?.userId,
303
+ userName: channel?.userName,
304
+ isDM: channel?.isDM,
305
+ }
306
+ },
307
+ })
308
+ ```
309
+
310
+ The channel context includes:
311
+
312
+ - `botMention`, `botUserId`, and `botUserName`: The bot's own identity on Slack.
313
+ - `channelId` and `threadId`: The Slack channel and thread the message arrived on.
314
+ - `isDM`: Whether the message is a direct message.
315
+ - `platform`: The platform identifier, `slack` for this adapter.
316
+ - `userId` and `userName`: The sender's Slack user ID and display name.
317
+
318
+ Mastra also turns this context into a short system message. The agent learns the platform and its own identity, plus whether the conversation is a direct message or a public channel. See [thread context](https://mastra.ai/docs/capabilities/channels/overview) in the channels overview for how to change that behavior.
319
+
214
320
  ## Production deployment
215
321
 
216
322
  When you deploy the Mastra server, update both request URLs in the Slack app settings to the production webhook URL. The tunnel URL used for local development is temporary and changes when the tunnel restarts.
217
323
 
218
324
  Channels on serverless platforms may need `waitUntil` and shared pub/sub configuration so background responses and thread leases work across short-lived instances. See [serverless deployment](https://mastra.ai/docs/capabilities/channels/overview) in the channels overview.
219
325
 
326
+ ### Idle servers
327
+
328
+ Platform servers scale down to idle when they aren't receiving traffic, and that's fine for Slack. The next event, such as a mention or direct message, wakes the server by delivering its webhook request, and the server resumes handling requests. The first response after the server has been idle can take a little longer while it starts up, which is expected. Slack expects a `200` acknowledgement within 3 seconds and retries the event up to three times when delivery fails or times out, so a very slow cold start may take a retry before the agent responds. Subsequent messages respond at normal speed while the server stays warm.
329
+
220
330
  ## Related
221
331
 
222
332
  - [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
@@ -61,6 +61,41 @@ Read the [`mastra start`](https://mastra.ai/reference/cli/mastra) reference for
61
61
 
62
62
  ## Build configuration
63
63
 
64
+ ### Build-time configuration
65
+
66
+ Mastra reads the `bundler`, `deployer`, and `server` options while it builds your application. Keep those options as direct properties of the object passed to `new Mastra()` so the build can extract them.
67
+
68
+ The following entry-file shape works:
69
+
70
+ ```typescript
71
+ import { Mastra } from '@mastra/core/mastra'
72
+
73
+ export const mastra = new Mastra({
74
+ bundler: {
75
+ externals: ['sharp'],
76
+ },
77
+ server: {
78
+ port: 4111,
79
+ },
80
+ })
81
+ ```
82
+
83
+ The value of each option can come from a variable, import, or function call. The option itself must remain a direct property. Do not hide build-time options behind a factory call or an object spread:
84
+
85
+ ```typescript
86
+ const options = {
87
+ bundler: {
88
+ externals: ['sharp'],
89
+ },
90
+ }
91
+
92
+ // These patterns prevent Mastra from extracting `bundler` during the build.
93
+ export const mastra = new Mastra(createMastraOptions())
94
+ export const otherMastra = new Mastra({ ...options })
95
+ ```
96
+
97
+ When Mastra can't extract an option, it uses the default build behavior for that option. See the [configuration reference](https://mastra.ai/reference/configuration) for the available `bundler`, `deployer`, and `server` settings.
98
+
64
99
  ### Public folder
65
100
 
66
101
  If a `public` folder exists in your Mastra directory (`src/mastra/public`), its contents are copied to the output directory during build. These files are served as static assets by the server.
@@ -97,6 +97,8 @@ export const mastra = new Mastra({
97
97
  })
98
98
  ```
99
99
 
100
+ Keep `bundler` as a direct property in the object passed to `new Mastra()`. See [build-time configuration](https://mastra.ai/docs/deployment/mastra-server) for the supported entry-file shape.
101
+
100
102
  ## Environment variables
101
103
 
102
104
  Store `.env` files in the Mastra application directory (e.g., `apps/api/.env`), not the monorepo root.
@@ -51,6 +51,12 @@ Use this option for auto-scaling, minimal infrastructure management, or when you
51
51
  - [Netlify](https://mastra.ai/guides/deployment/netlify)
52
52
  - [Vercel](https://mastra.ai/guides/deployment/vercel)
53
53
 
54
+ ### Sandbox
55
+
56
+ Deploy a Mastra server into an ephemeral workspace sandbox (such as Vercel Sandbox or E2B) and get a live public URL in seconds.
57
+
58
+ Use this option for instant previews, deploys from your CI pipeline, verifying agent-built apps, or running untrusted per-user instances. Read the [sandbox deployment guide](https://mastra.ai/docs/deployment/sandbox).
59
+
54
60
  ### Web Framework
55
61
 
56
62
  When Mastra is integrated with a web framework, it deploys alongside your application using the framework's standard deployment process. The guides below cover framework-specific configuration requirements for deployment.
@@ -0,0 +1,277 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Deploy to a sandbox
4
+
5
+ `@mastra/deployer-sandbox` deploys a full Mastra server, including Studio, into an ephemeral workspace sandbox and returns a live public URL. Repeat deployments can finish faster because the deployer skips dependency installation.
6
+
7
+ Use sandbox deployments for:
8
+
9
+ - Agent-built apps: An agent generates a Mastra project and deploys it to verify the result.
10
+ - Continuous integration (CI): Spin up a real server for checks, then tear it down.
11
+ - Instant previews: Share a working agent with your team before merging.
12
+ - Multi-tenant untrusted code: Run per-user Mastra instances isolated from your infrastructure.
13
+
14
+ Sandboxes have provider-enforced runtime caps and expire. For production hosting, see the [deployment overview](https://mastra.ai/docs/deployment/overview).
15
+
16
+ ## Supported sandboxes
17
+
18
+ The deployer works with any workspace sandbox that supports networking (public port URLs):
19
+
20
+ - [Vercel Sandbox](https://mastra.ai/reference/workspace/vercel-sandbox) (`@mastra/vercel`)
21
+ - [E2B](https://mastra.ai/reference/workspace/e2b-sandbox) (`@mastra/e2b`)
22
+ - [Daytona](https://mastra.ai/reference/workspace/daytona-sandbox) (`@mastra/daytona`)
23
+
24
+ Provider authors can add support by implementing the optional `networking` capability on [`WorkspaceSandbox`](https://mastra.ai/reference/workspace/sandbox).
25
+
26
+ ## Quickstart
27
+
28
+ Install the deployer and a sandbox provider of your choice. This example uses Vercel Sandbox:
29
+
30
+ **npm**:
31
+
32
+ ```bash
33
+ npm install @mastra/deployer-sandbox @mastra/vercel
34
+ ```
35
+
36
+ **pnpm**:
37
+
38
+ ```bash
39
+ pnpm add @mastra/deployer-sandbox @mastra/vercel
40
+ ```
41
+
42
+ **Yarn**:
43
+
44
+ ```bash
45
+ yarn add @mastra/deployer-sandbox @mastra/vercel
46
+ ```
47
+
48
+ **Bun**:
49
+
50
+ ```bash
51
+ bun add @mastra/deployer-sandbox @mastra/vercel
52
+ ```
53
+
54
+ Configure the deployer in your `src/mastra/index.ts` file. The `sandboxName` identifies the deployment, so subsequent deployments with the same name reuse the existing sandbox.
55
+
56
+ ```typescript
57
+ import { Mastra } from '@mastra/core/mastra'
58
+ import { SandboxDeployer } from '@mastra/deployer-sandbox'
59
+ import { VercelSandbox } from '@mastra/vercel'
60
+
61
+ export const mastra = new Mastra({
62
+ deployer: new SandboxDeployer({
63
+ sandbox: new VercelSandbox({
64
+ sandboxName: 'my-preview',
65
+ timeout: 3_600_000, // 1 hour
66
+ ports: [4111],
67
+ }),
68
+ }),
69
+ })
70
+ ```
71
+
72
+ Build and deploy in one command:
73
+
74
+ ```bash
75
+ mastra build
76
+ ```
77
+
78
+ When a `SandboxDeployer()` is configured, `mastra build` bundles your project and deploys it into the sandbox. The deploy prints the API and Studio URLs and writes a `sandbox-deployment.json` manifest into `.mastra/output`:
79
+
80
+ ```text
81
+ API: https://<sandbox-id>-4111.vercel.run/api
82
+ Studio: https://<sandbox-id>-4111.vercel.run
83
+ ```
84
+
85
+ The manifest includes `expiresAt` when the sandbox provider reports an expiration time. Redeploys to the same sandbox skip the dependency install when the install inputs (`package.json`, bundled lockfiles, and the install command) are unchanged.
86
+
87
+ ### Using E2B
88
+
89
+ For E2B, the `id` identifies the deployment, so subsequent deployments with the same value reconnect to the existing sandbox, whether it's running or paused.
90
+
91
+ ```typescript
92
+ import { SandboxDeployer } from '@mastra/deployer-sandbox'
93
+ import { E2BSandbox } from '@mastra/e2b'
94
+
95
+ const deployer = new SandboxDeployer({
96
+ sandbox: new E2BSandbox({
97
+ id: 'my-preview',
98
+ template: 'base',
99
+ timeout: 3_600_000, // 1 hour
100
+ }),
101
+ })
102
+ ```
103
+
104
+ Pass `template: 'base'` unless you need filesystem mounts; without it, the provider builds a custom Filesystem in Userspace (FUSE) template on first use. E2B pauses instead of stopping: `stop()` snapshots the whole virtual machine (VM), including memory and running processes. When a paused sandbox wakes, the Mastra server resumes where it left off, and there's no relaunch step like on Vercel.
105
+
106
+ ### Using Daytona
107
+
108
+ For Daytona, the `id` identifies the deployment, so subsequent deployments with the same value reconnect to the existing sandbox. Set `public: true` to make the preview URL accessible without a token.
109
+
110
+ ```typescript
111
+ import { SandboxDeployer } from '@mastra/deployer-sandbox'
112
+ import { DaytonaSandbox } from '@mastra/daytona'
113
+
114
+ const deployer = new SandboxDeployer({
115
+ sandbox: new DaytonaSandbox({
116
+ id: 'my-preview',
117
+ public: true,
118
+ autoStopInterval: 30, // minutes
119
+ }),
120
+ })
121
+ ```
122
+
123
+ Stopping a Daytona sandbox persists its filesystem but not running processes, so waking works like Vercel: the resolver relaunches the server on `wake: true`.
124
+
125
+ ## Deploying programmatically
126
+
127
+ `deployToSandbox()` deploys a prebuilt output directory without the bundler. Unlike `SandboxDeployer()`, it doesn't include Studio unless you pass `studio: true`. Use it in CI or from agent code:
128
+
129
+ ```typescript
130
+ import { deployToSandbox } from '@mastra/deployer-sandbox'
131
+ import { VercelSandbox } from '@mastra/vercel'
132
+
133
+ const deployment = await deployToSandbox({
134
+ sandbox: new VercelSandbox({ sandboxName: 'ci-smoke', ports: [4111] }),
135
+ dir: '.mastra/output',
136
+ })
137
+
138
+ console.info(deployment.url) // https://<sandbox-id>-4111.vercel.run
139
+ await deployment.logs() // tail the server log
140
+ await deployment.stop() // stop the sandbox (resumable)
141
+ await deployment.destroy() // permanently delete the sandbox
142
+ ```
143
+
144
+ ## Lifecycle
145
+
146
+ ### Managing a deployment
147
+
148
+ Use the server-only `getDeployment()` export from `@mastra/deployer-sandbox/client` to retrieve an existing deployment. It identifies the sandbox through provider-specific configuration, such as a Vercel `sandboxName` or an E2B or Daytona `id`. The lookup isn't tied to the process that created the deployment, so you can use it from another server-side service or in CI.
149
+
150
+ ```typescript
151
+ import { getDeployment } from '@mastra/deployer-sandbox/client'
152
+ import { VercelSandbox } from '@mastra/vercel'
153
+
154
+ const deployment = await getDeployment({
155
+ sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
156
+ port: 4111,
157
+ })
158
+
159
+ console.info(deployment.status, deployment.url)
160
+ await deployment.logs() // tail the server log
161
+ await deployment.stop() // stop the sandbox (resumable)
162
+ await deployment.destroy() // permanently delete the sandbox
163
+ ```
164
+
165
+ Pass `wake: true` to resume a stopped sandbox before returning. The server is relaunched only if it isn't healthy after the resume. Provider tooling works too, for example `vercel sandbox ls`, `vercel sandbox stop`, and `vercel sandbox rm`.
166
+
167
+ ### Expiry and URLs
168
+
169
+ Sandboxes expire according to the provider's runtime limits. When the provider reports an expiration time, the deploy logs it and `deployment.expiresAt` exposes it programmatically.
170
+
171
+ Sandbox URLs can change when a sandbox stops and resumes. Treat the URL as plumbing and the sandbox identity (for example, the `sandboxName`) as the stable handle. The routing tiers below deal with URL rotation.
172
+
173
+ ## Routing tiers
174
+
175
+ ### Tier 1: Direct URL
176
+
177
+ Use the printed URL directly for development, demos, and CI where a fresh URL per deploy is acceptable.
178
+
179
+ ### Tier 2: Resolve at runtime
180
+
181
+ `getDeployment()` resolves the current URL at runtime, so consumers never hold a stale URL. Any server that knows the sandbox name can resolve it, including one in a different codebase than the Mastra project:
182
+
183
+ ```typescript
184
+ import { getDeployment } from '@mastra/deployer-sandbox/client'
185
+ import { VercelSandbox } from '@mastra/vercel'
186
+
187
+ const deployment = await getDeployment({
188
+ sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
189
+ wake: true,
190
+ })
191
+
192
+ console.info(deployment.url, deployment.status)
193
+ ```
194
+
195
+ With `wake: false` (the default) the sandbox isn't started and you get `{ url, status }` to act on. Resolving the URL, `stop()`, and `destroy()` attach to the existing sandbox by name without resuming it, so lifecycle operations on a stopped sandbox never wake it or start billing. With `wake: true` the sandbox resumes and the server is relaunched if it isn't answering. Whether a relaunch is needed depends on the provider: Vercel and Daytona restore the filesystem but not running processes, while E2B resumes the whole VM including the server process.
196
+
197
+ > **Warning:** `@mastra/deployer-sandbox/client` is server-only. Resolving a sandbox uses provider credentials that must never reach the browser. The module throws if imported in a browser context.
198
+
199
+ ### Tier 3: Stable URL for end users
200
+
201
+ Give end users a stable URL on your own domain and forward to the sandbox server-side, using either a route handler proxy or an Edge Config alias.
202
+
203
+ The example below shows a Vercel & Next.js setup, but the concept applies to any server-side framework or provider that can forward requests.
204
+
205
+ - **Route handler proxy.** `createSandboxHandler()` caches the sandbox URL and re-resolves after a connection-level failure, which covers URL rotation and cold wakes:
206
+
207
+ ```typescript
208
+ import { createSandboxHandler, getDeployment } from '@mastra/deployer-sandbox/client'
209
+ import { VercelSandbox } from '@mastra/vercel'
210
+
211
+ const handler = createSandboxHandler({
212
+ resolve: async () => {
213
+ const deployment = await getDeployment({
214
+ sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
215
+ wake: true,
216
+ })
217
+ return deployment.url!
218
+ },
219
+ })
220
+
221
+ export { handler as GET, handler as POST }
222
+ ```
223
+
224
+ - **Edge Config alias.** Set the `alias` option on the deployer to keep a [Vercel Edge Config](https://vercel.com/docs/edge-config) item pointed at the current URL on every deploy:
225
+
226
+ ```typescript
227
+ const deployer = new SandboxDeployer({
228
+ sandbox: new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] }),
229
+ alias: { edgeConfigId: 'ecfg_...', key: 'my-preview', token: process.env.VERCEL_TOKEN! },
230
+ })
231
+ ```
232
+
233
+ Then rewrite requests in Next.js middleware with `createSandboxProxy()`:
234
+
235
+ ```typescript
236
+ import { createSandboxProxy } from '@mastra/deployer-sandbox/client'
237
+
238
+ export const middleware = createSandboxProxy({ key: 'my-preview' })
239
+ export const config = { matcher: '/api/:path*' }
240
+ ```
241
+
242
+ ## CI example
243
+
244
+ Deploy a preview on every pull request:
245
+
246
+ ```yaml
247
+ name: Sandbox preview
248
+ on: pull_request
249
+
250
+ jobs:
251
+ preview:
252
+ runs-on: ubuntu-latest
253
+ env:
254
+ VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
255
+ VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
256
+ VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
257
+ steps:
258
+ - uses: actions/checkout@v4
259
+ - uses: actions/setup-node@v4
260
+ with:
261
+ node-version: 22
262
+ - run: npm ci
263
+ - run: npx mastra build
264
+ - run: curl --fail "$(jq -r .url .mastra/output/sandbox-deployment.json)/api"
265
+ ```
266
+
267
+ ## Security
268
+
269
+ - The sandbox URL is public. Anyone with the URL can reach your Mastra server, including Studio. Enable [server auth](https://mastra.ai/docs/server/auth) for anything beyond throwaway previews.
270
+ - Environment variables from your `.env` files are injected into the remote sandbox VM so the server can run. The deploy logs a warning when this happens. Don't deploy secrets you wouldn't put on a shared preview server.
271
+ - To restrict access to Tier 3 traffic, pass a `secret` to `createSandboxHandler()` or `createSandboxProxy()`. The helpers attach it as the `x-mastra-sandbox-secret` header on forwarded requests. Configure [server auth](https://mastra.ai/docs/server/auth) to require that header, and direct hits to the sandbox URL get rejected while traffic through your domain works.
272
+
273
+ ## Related
274
+
275
+ - [Deployment overview](https://mastra.ai/docs/deployment/overview)
276
+ - [Server authentication](https://mastra.ai/docs/server/auth)
277
+ - [`WorkspaceSandbox` reference](https://mastra.ai/reference/workspace/sandbox)
@@ -57,9 +57,7 @@ import { Mastra } from '@mastra/core'
57
57
  import { MastraEditor } from '@mastra/editor'
58
58
 
59
59
  export const mastra = new Mastra({
60
- agents: {
61
- /* your existing agents */
62
- },
60
+ agents: {/* your existing agents */},
63
61
  editor: new MastraEditor(),
64
62
  })
65
63
  ```
@@ -84,9 +82,7 @@ import { Mastra } from '@mastra/core'
84
82
  import { MastraEditor } from '@mastra/editor'
85
83
 
86
84
  export const mastra = new Mastra({
87
- agents: {
88
- /* your existing agents */
89
- },
85
+ agents: {/* your existing agents */},
90
86
  editor: new MastraEditor({
91
87
  source: 'code',
92
88
  }),
@@ -62,9 +62,7 @@ Integration providers connect external tool platforms to the editor. Once regist
62
62
  import { ComposioToolProvider } from '@mastra/editor/composio'
63
63
 
64
64
  export const mastra = new Mastra({
65
- agents: {
66
- /* your agents */
67
- },
65
+ agents: {/* your agents */},
68
66
  editor: new MastraEditor({
69
67
  toolProviders: {
70
68
  composio: new ComposioToolProvider({
@@ -91,9 +89,7 @@ Integration providers connect external tool platforms to the editor. Once regist
91
89
  import { ArcadeToolProvider } from '@mastra/editor/arcade'
92
90
 
93
91
  export const mastra = new Mastra({
94
- agents: {
95
- /* your agents */
96
- },
92
+ agents: {/* your agents */},
97
93
  editor: new MastraEditor({
98
94
  toolProviders: {
99
95
  arcade: new ArcadeToolProvider({